Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Having read "two gateways / two providers with different ips", and the Clinton East article that it links to, I have successfully set up a multi-homed RHEL5 system. However, I am hoping for a better way to preserve this state than by calling the ip rule and ip route commands from rc.local. Is there a configuration file that I could edit that would get read as the interfaces come up? Something like iptables-save and iptables-restore perhaps?

share|improve this question
My related question: – Zoredache Sep 15 '09 at 19:49
up vote 0 down vote accepted

In RHEL, there's two places where these things should probably go.

For adding static routes in RHEL, you add them to /etc/sysconfig/network-scripts/route-INTERFACE where INTERFACE matches the name of the ifcfg-INTERFACE entries. The statements in the route-* files will be passed to ip route add and ip route del when the interface is brought up or down.

Now, for the ip rule commands, the best place I can think of would probably be in /sbin/ifup-local. If this file exists, it gets run after an interface is brought up. One note with this one, if /sbin/ifup-local exists, it will get called as an executable and passed an argument of the interface name. So you'll have to write handler code to check that argument against the interfaces you want to add configs for and then take the appropriate action.

As an example:


case $1 in
    /sbin/ip rule foo
    /sbin/ip rule bar
    /sbin/ip rule baz
    /sbin/ip rule quux
    /usr/bin/logger -t 'ifup-local' 'Called with unknown interface:  $1'

If you wanted to, you could include the ip route rules for each interface in ifup-local, too. If you wanted to remove the corresponding rules when an interface is downed, you could create a similar /sbin/ifdown-local script to handle that.

If it were me, even though RHEL provides a standardized way of handling static routes, I'd probably do everything in ifup-local and ifdown-local, just to keep all my interface specific bits together.

share|improve this answer

RedHat: I don't have any boxes on hand to check, but there should be something like a /etc/sysconfig/network/routes file in which to configure static routes.


$ cat /etc/sysconfig/network/ifroute-eth-id-MAC:


$ cat /etc/network/interfaces
auto eth0
iface eth0 inet static
up ip route add via
down ip route del via
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.