Linux – To use two ethernet ports with the same subnet, problems with IP

linuxnetworking

I have a box with Linux Ubuntu 8.04 and 4 Ethernet ports. I enabled 2 ports, eth0 and eth1, and am trying to configure them with static IPs (eth0 = 192.168.0.205 and eth1 = 192.168.0.206).

If I plug 2 cables, one for each, I can to ping my equipment by each IP as expected. But, if I remove the cable from eth1, I still can ping both IPs still. After this I can disable eth1 and the 2 IPs still will be available for me on eth0.

If I to plug the cable in eth1 there is no difference, just eth0 port workings.

I did a test, and if I configure the 2 IPs in distinct subnets this problem doesn't occur.

Best Answer

This happens because by default Linux consider an IP address as a property of the whole host, not just a particular interface; therefore an ARP request from outside (which will be received by both interfaces) will cause a reply from all interfaces, not just the one with the requested IP.

Look at this answer to a question similar to yours (there is also another way involving arptables described there).

Related Topic