Hi, I'm wanting to configure a CentOS 6 server to have a fall-back default route via a second network interface. Given: - eth0 with 192.168.0.10 on subnet 192.168.0.0/24 gateway 192.168.0.1 - eth1 with 192.168.1.10 on subnet 192.168.1.0/24 gateway 192.168.1.1 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 192.168.1.1 dev eth1 weight 1 \ nexthop via 192.168.0.1 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)? Cheers, Nick ps. Hints about this obtained from http://lkml.indiana.edu/hypermail/linux/net/0201.0/0000.html http://lartc.org/lartc.html#AEN298
On 02/01/2012 02:03 PM, Nick wrote:> Hi, > > I'm wanting to configure a CentOS 6 server to have a fall-back default route via > a second network interface. > > Given: > > - eth0 with 192.168.0.10 on subnet 192.168.0.0/24 gateway 192.168.0.1 > - eth1 with 192.168.1.10 on subnet 192.168.1.0/24 gateway 192.168.1.1 > > 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 192.168.1.1 dev eth1 weight 1 \ > nexthop via 192.168.0.1 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. -- Stephen Clark *NetWolves* Director of Technology Phone: 813-579-3200 Fax: 813-882-0209 Email: steve.clark at netwolves.com http://www.netwolves.com
On 02/01/2012 11:03 AM, Nick wrote:> I believe I can configure the routing table manually like this: > ip route default scope global \ > nexthop via 192.168.1.1 dev eth1 weight 1 \ > nexthop via 192.168.0.1 dev eth0 weight 2 > > 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.It doesn't really matter that the route isn't "for" a specific interface. The route just has to be valid when the file is evaluated. You'd want to create route-eth1 and add a single line starting with "default" and containing the rest of the command you listed above.> 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)?If you're not specifying one elsewhere, the system won't "pick" one as far as I know. Having said that, I don't think that the kernel will do automatic route detection failures. IIRC, "weight" is used for load balancing, and connections will be pinned to whatever route is selected. You probably don't want to do any of this. Instead, you'd want to use a package that's set up to handle the routes and rules that are required for multiple ISP handling, and scripts that are written to detect link failure and adjust the system accordingly. Consider: http://www.shorewall.net/MultiISP.html#LinkMonitor