[CentOS] ip route and nexthop: the "CentOS" way

Wed Feb 1 21:22:25 UTC 2012
Steve Clark <sclark at netwolves.com>

On 02/01/2012 04:06 PM, Les Mikesell wrote:
> On Wed, Feb 1, 2012 at 1:35 PM, Steve Clark<sclark at netwolves.com>  wrote:
>>> I'm wanting to configure a CentOS 6 server to have a fall-back default route via
>>> a second network interface.
>>> Given:
>>>    - eth0 with on subnet gateway
>>>    - eth1 with on subnet gateway
>>> Where eth0's network is a "back door" to the internet, and eth1's is the "front
>>> door", I believe I can configure the routing table manually like this:
>>>    ip route default scope global \
>>>      nexthop via dev eth1 weight 1 \
>>>      nexthop via dev eth0 weight 2
>>> However, I've re-read the RHEL6 documents for configuring static routes here:
>>> http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s1-networkscripts-static-routes.html
>>> This kind of thing doesn't seem to fit into the scheme of
>>> /etc/sysconfig/network-scripts/route-eth? described there, since the route isn't
>>> "for" any single interface.  Is there a "RHEL/CentOS" way to do this, or do I
>>> need to resort to some sort of script containing the above ip route command
>>> inserted somewhere?
>>> And how do I stop CentOS from trying to pick its own default gateway settings
>>> (since /etc/sysconfig/network likely won't have a GATEWAY parameter)?
>> Hmm...
>> I just tried this and besides needing ip route "add" default
>> It does not seem to work when I unplug the cable on my primary link.
> I don't think CentOS is smart enough to automatically drop routes
> associated with a NIC that is down like a Cisco would.  If you put
> routes in /etc/sysconfig/network-scripts/routes-eth? to match the
> device names, the ifup and ifdown scripts will add/remove routes when
> you manually run time to enable/disable a particular NIC, but that
> doesn't get you automatic failover.  And with ethernet type devices it
> is pretty rare for the link to go away at the same time the packets
> stop getting through anyway.
I got it sort of work - but even with the weights and flushing the routing cache sometimes
it seemed to want to go on the higher weighted route. Could be something in my

I did onetime have if fail from the lower weight to the higher weighted route when I pulled
the cable on the preferred route.

Stephen Clark
Director of Technology
Phone: 813-579-3200
Fax: 813-882-0209
Email: steve.clark at netwolves.com