Communication two hosts have same ip on different network interface

489 views Asked by At

I'v two identical network devices that have hardcoded same ip address but different mac adressess. Both of them are connected to different nic on my windows machine. Both of them listen same udp port, accept udp messages only from preconfigured source address and reply to preconfigured destination ip:port address. How can i manage this devices simultaneously? If it possible to handle this on linux with like that iptables or ip routing?

I'v tried to use raw sockets to build and send ethernet packet. For this i assign different ip address to each nic. And give predefined ip address on ethernet packet when sending it with raw socket. But packet didn't send. It' seems windows blocking the ip packet if the source ip is not real. I'v also tried build and send raw udp-ip-ethernet packet with npcap. But it didn't work also.

2

There are 2 answers

2
DubStep On

You can't give two network devices the same IP address. That's akin to having two houses with the exact same postal mailing address and expecting mail to be delivered to the correct house. I think you need to start with what are you trying to do. If I had to guess, you want to have two NICs, so one isn't a single failure point? If so, what you are looking for in Windows is NIC Teaming. In Windows server, you enable this in server manager, in Windows 10/11 via PowerShell. Here is a link explaining both: https://woshub.com/configure-nic-teaming-windows/

1
user1863497 On

I did it on both windows and linux by ip forwarding. The trick is map the ip addresses to some other ip address.

For example the network devices real ip address would be 10.10.1.20/24 and reply address would be 10.10.1.10/24. We decide to some other ip address for each network device and send packets to this ip. For example the application which want to communicate to first device on interface-1 would send udp packets to destination address 10.20.1.20 and would send to destination address 10.20.2.20 for communicate to second device on interface-2. And after that we need to something like that collect all packets, rewrite the destination and source ip address to real ip address and finalliy send it from corresponding nic. I made it with iptables and ebtables on linux.

But windows doesn't has iptables. So i made custom application using raw socket to make do it. The application simply catch the ip pakets that has destination address 10.20.1.20 and buil a new eth packet by change the source address to 10.10.1.10 and destination ip addresses to 10.10.1.20 and send it to corresponding nic-1. And do something for packets the destination address is 10.10.2.20 and send it to nic-2.