I 'm using Sharppcap to convert multicast udp packets to unicast then forward the packet to another network I established a tunnel IPsec connection between two networks like the following scenario IPsec-tools and racoon and it works fine
But in gateway1 I run a simple program using sharppcap that listen to eth1 to capture all multicast udp packets from network A and change the destination address to the eth1 address of gateway2 then resend it then the other gateway change the packet to multicast and forward it to network B. I did this because IPsec tunnel mode doesn't work with multicast For example in gatway1:
private static void device_PcapOnPacketArrival(object sender, PcapCaptureEventArgs e)
{
if(e.Packet is UDPPacket)
{
UDPPacket udp = (UDPPacket)e.Packet;
System.Net.IPAddress dstIp = udp.DestinationAddress;
if (dstIp.ToString() == "224.5.6.7")
{
udp.DestinationAddress= IPAddress.Parse("192.168.2.1");
udp.SourceHwAddress= System.Net.NetworkInformation.PhysicalAddress.Parse("A0-48-1C-D6-7E-C0");
udp.DestinationHwAddress= System.Net.NetworkInformation.PhysicalAddress.Parse("A0-48-1C-D6-D5-90");
udp.TimeToLive=20;
udp.ipv4.IPChecksum= udp.ComputeIPChecksum();
device1.SendPacket(udp);
}
}
}
The modified packet gets to its destination in the other network but still not encrypted in the tunnel between gateway1 and gateway2 I think the solution is to let the operating system handle sending the packets But I don’t know how to do it using sharppcap.