Linux sends a packet from a source IP of one interface but a source MAC of another

1.7k views Asked by At

My Linux (Debian) server has eth0 and eth1, and both are on the same subnet. It receives packets from both interfaces, but it only replies from eth0. Packets that are sent to eth1 are replied from eth0, and the reply has eth0's src mac and eth1's src IP. I verified this by sending a ping to eth1 while running tcpdump on the Linux server.

This is a problem because: Since no packets are sent with a source mac of eth1 (with the exception of the initial arp), the switch forgets the eth1 mac. Then, every packet with the destination mac of eth1 that is received by the switch is broadcasted across the network, flooding it which makes us sad.

I want: My Linux server to send packets out from both eth0 and eth1. I think the nicest solution is that for each packet we get, we reply from the same interface. Another way to put it is that I want to bind each interface to its IP and MAC - so that it will only send packets from these addresses.

More details: My Linux server is an ISCSI Target communicating with an ESX which is an ISCSI Initiator - though a Cisco switch. The switch forgets MACs after 5 minutes, and the ESX probably remembers them for 20 minutes (as discussed here and here). So while the ESX remembers the mac of the Linux, the ESX keeps sending ISCSI requests which flood the network, while my server sends ISCSI replies through only one of the interfaces.

1

There are 1 answers

1
hobbs On

This isn't what you asked for, but if you just set up a cron job on the box that did

ping -c 1 -I eth1 <address of eth1's default gateway>

every minute, then you would have at least one packet per minute leaving eth1 with eth1's MAC address on it. -I tells ping to bind to a specific interface, so it won't use eth0 even if that's the preferred route.