route 66Static routing is the term used to refer to the manual method used to set up routing. An administrator enters routes into the router using configuration commands. This method has the advantage of being predictable, and simple to set up. It is easy to manage in small networks but does not scale well.

Question: How can I save static routes I set up in my Fedora/RedHat/CentOS Linux after I reboot server?

Answer: In Fedora Linux (or RedHat, CentOS) you can set up static routes for certain network interface (for example eth1) by editing file /etc/sysconfig/network-scripts/route-eth1.

For example, you have to save static route added by the following command:

route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.100.1 dev eth1

To do it, just add the following line to /etc/sysconfig/network-scripts/route-eth1:

ADDRESS0=192.168.0.0
NETMASK0=255.255.255.0
GATE
WAY0=192.168.100.1

Information improvisation: We provide guaranteed pass 1z0-451 exam with online microsoft mcp training and 70-681. You can also get best quality NS0-154 along with 70-620 for your guaranteed success.

 

6 Comments

 

  1. May 9, 2008  11:24 pm by confiq Reply

    hey... nice tip... keep those comming :)

  2. May 10, 2008  12:24 pm by artiomix Reply

    Thank you, confiq. Keep commenting! ;)

  3. May 13, 2008  1:06 am by daveg Reply

    The alternate way of doing it is to put the routes in /etc/sysconfig/static-routes. So the above route would like this like in the static-routes file:

    any net 192.168.0.0 netmask 255.255.255.0 gw 192.168.100.1

    Where any is specified above you can also set specific interfaces (such as eth1).

  4. May 13, 2008  7:28 am by artiomix Reply

    Thanks for the tip, daveg!

    Here is the part /etc/init.d/interfaces code:


    # Add non interface-specific static-routes.
    if [ -f /etc/sysconfig/static-routes ]; then
    grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do
    /sbin/route add -$args
    done
    fi


    Looks like any must be at the beginning of each line in /etc/sysconfig/static-routes. At the same time Fedora is able to determine interface name packet should be routed through (like eth1) by destination IP. :)

  5. April 15, 2009  4:31 pm by How to Get Six Pack Fast Reply

    Hey, cool tips. I'll buy a bottle of beer to that man from that chat who told me to visit your site :)

  6. July 14, 2009  4:08 pm by Joey Trungale Reply

    /usr/share/doc/initscripts-${VERSION}/sysconfig.txt is a good place to look for these things as well

Leave a reply

 

Your email address will not be published.