Where are the Linux routing table entries stored on disk?

I know the routing tables on Linux is in memory after being set. However, where are the routing table entries stored on disk? I mean where are the routing table is persistently stored so that the routing table can be reloaded like the iptables (under /etc/sysconfig/iptables on Fedora/RHEL/CentOS Linuxes).

asked May 8, 2013 by Adam (1,780 points)

1 Answer

 
Best answer

If the system uses the /etc/rc.d/init.d/network script to manage the network, the static routing rules are stored in /etc/sysconfig/static-routes. This is the related script about applying the rules from static-routes in the network script file:

    # 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    

The network script reads from /etc/sysconfig/static-routes the lines starting with "any" and passes the following arguments to the /sbin/route command.

For example: A line like this in static-routes:

any host 10.1.1.8 gw 8.9.10.11

runs command:

route add -host 10.1.1.8 gw 8.9.10.11

If the system uses NetworkManager to manage the network, the NetworkManager GUI tools provides a dialog to set the routing rules. In the "Editing config_name" dialog's "IPv4 Settings" tab (for IPv4), there is a button "Routes" which will opens the form that you can configure the routing rules.

answered May 8, 2013 by Peter M. (1,270 points)
selected Jul 30, 2013

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...