I have a Linux machine with two interfaces that have IPv4 addresses belonging to the same subnet. In my application, I create two sockets (AF_INET, SOCK_DGRAM), bind them to the respective interface IP addresses and apply the SO_BINDTODEVICE socket option with the corresponding interface name. The understanding is that when I send a UDP unicast packet through each socket, it goes out through the corresponding NIC. (see Linux: Bind UDP listening socket to specific interface (or find out the interface a datagram came in from)?).
My query is about the ARP request that precedes the actual UDP packet. Does SO_BINDTODEVICE also ensure that the ARP request goes out through the same NIC to which the socket responsible for generation of ARP is bound? Or does it depend only on the destination IP address?
This information is significant for me as the two NICs of a host connect to two independent networks managed by two switches. So if host A wants to communicate to host B's second address, the packet (both UDP and ARP) has to go out through A's second NIC.
PS: I'm aware that the problem will go away if I simply use two different subnets for the two networks.