Monday, June 3, 2013

RHEL / CentOS 6 Multiple Interfaces on same subnet - network unreachable

I ran into an interesting issue with CentOS 6.4 when I added a second nic on the same subnet as the first. What happens is that I can ping the first interface from outside its subnet but not the second. Also, if from the CentOS host using the second interface I try to ping local IPs it works but IP's that need to use the default gateway fail and show network unreachable even though the default gateway is correctly configured.

Thanks to a very helpful post at http://www.centos.org/modules/newbb/viewtopic.php?topic_id=40726&forum=58 I learned that this is due to a change between version 5 and 6 regarding Reverse Path Filtering. To fix this issue in RHEL 6 and CentOS 6 you need to modify the /etc/sysctl.conf file like the below:

rp_filter - BOOLEAN
1 - do source validation by reversed path, as specified in RFC1812
Recommended option for single homed hosts and stub network
routers. Could cause troubles for complicated (not loop free)
networks running a slow unreliable protocol (sort of RIP),
or using static routes.

0 - No source validation.

conf/all/rp_filter must also be set to TRUE to do source validation
on the interface

Default value is 0. Note that some distributions enable it
in startup scripts.

whereas in RHEL6 (cf. /usr/share/doc/kernel-doc-2.6.32/Documentation/networking/ip-sysctl.txt) there are three possible values for this setting:

rp_filter - INTEGER
0 - No source validation.
1 - Strict mode as defined in RFC3704 Strict Reverse Path
Each incoming packet is tested against the FIB and if the interface
is not the best reverse path the packet check will fail.
By default failed packets are discarded.
2 - Loose mode as defined in RFC3704 Loose Reverse Path
Each incoming packet's source address is also tested against the FIB
and if the source address is not reachable via any interface
the packet check will fail.

Full credit to the centos.org forum user who had the original fix, I just thought I would share since it was a bit hard to find.