Follow

Routing Multiple Nic's within the same subnet

You may find that when working with multiple Ethernet cards within the same subnet that outgoing traffic may default to only one Nic. This is due to the routing table that Linux uses by default and while this works in most cases, you may want to customize your routing to ensure that traffic is routed through a specific card.

Example:

Fiber Card : ens8f0 xxx.xxx.xxx.129 255.255.254.0

Non Fiber Card : enp1s0f0 xxx.xxx.xxx.130 255.255.254.0

Default Route output:

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default xxx.xxx.xxx.1 0.0.0.0 UG 0 0 0 ens8f0
xxx.xxx.xxx.0 * 255.255.254.0 U 0 0 0 ens8f0
xxx.xxx.xxx.0 * 255.255.254.0 U 0 0 0 enp1s0f0

To ensure that you control how the traffic is routed via the hardware then you will need to remove the default routes and add them explicitly for each card.

route delete default gw <IP><NIC>

route add -net <IP> netmask <IP> gw <NIC>

route delete default gw xxx.xxx.xxx.1 ens8f0

route delete default gw xxx.xxx.xxx.1 enp1s0f0

route add -net xxx.xxx.xxx.0 netmask 255.255.254.0 xxx.xxx.xxx.129 gw ens8f0

route add -net xxx.xxx.xxx.0 netmask 255.255.254.0 xxx.xxx.xxx.130 gw ens8f0

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk