When a Linux box has two NICs, both connected to the same subnet, is there any way to tell which one is being used as the default gateway?
There are a couple of conditions.
In this case, the routing table is queried, so in my example, I have two IPs on the same subnet
Which one to choose? Well the answer to this is dominated by the routes. So if we check that out..
Of course, if I have a default route for a destination that will be where I would go and it would be quite obvious. Normally the same routing table wont accept duplicate rules for destination networks.
Other factors in the route might weigh one over the other, the
Well, simply put if all else fails and both rules are equal the kernel just chooses the one that is first in the list. If you have a preference, then you choose that one.
If you want to make a preference, you'll need to add rules (such as in my case) to the route like this:
Which will alter the routing rules out of the host. You might need to clear your arp cache after doing that.