Linux - Same Subnet Communication
Ever faced an intermediate connection issue to a linux server, sometimes it responds to your curl/app requests and sometimes it fails.
In this Article i will discuss the default behavior of linux when it has more than one interface on the same subnet.
By default The kernel can respond to ARP requests with addresses from other interfaces as mentioned Here
i.e if an ARP request is designated to the interface with the following IP 192.168.1.2/24 and mac address 29-DE-D5-01-73-5F and you have another interface with the following 192.168.1.15/24 and mac address AF-19-8A-BB-66-AD any of them can respond the ARP request with the mac address assigned to it.
Example
An ARP request for 192.168.1.2 is broadcasted the anticipated mac address would be 29-DE-D5-01-73-5F, but if 192.168.1.2 couldn't reply fast enough 192.168.1.15 would then reply with its mac address AF-19-8A-BB-66-AD
Then in the ARP table you would have 192.168.1.2 with AF-19-8A-BB-66-AD with points to 192.168.1.15 and then communication fails as the IP doesn't match the mac address.
If you want the ARP request to be responded by the specified interface you should change the kernel variable: net.ipv4.conf.interface.arp_filter to 1
I faced this issue(intended behavior,issue for me) i kept troubleshooting until i found this solution.
So i decided to write this article to save some time for the next person who faces the same issue.