How does kernel make decisions for adding routes to reach a destination if the interfaces are in same network in RHEL?
Issue
- We have a setup where, we have two interfaces having ips from same network but with different subnet mask such as below:
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.100.0 0.0.0.0 255.255.255.128 U 0 0 0 eth2
192.168.100.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
- We see that,
eth2interface always precedes overeth1routes. - If the network masks are inter-changed,
eth1gets selected and stays on top as expected. - We note that, if the interfaces are configured to have same network mask values, the local routes are randomly placed on top in main route table, such that if the interfaces are reloaded/restarted, the local route is placed in the main table based on which interface comes up first.
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.100.0 0.0.0.0 255.255.255.128 U 0 0 0 eth1
192.168.100.0 0.0.0.0 255.255.255.128 U 0 0 0 eth2
- This behavior sometimes causes the gateway from
eth1to be unreachable. - Why do we see such a behavior?
- How does kernel take decision to place a route from an interface in the routing table?
Environment
- Red Hat Enterprise Linux (RHEL) All Version.
- Kernel Routing table.
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.