Where are the Linux routing table entries stored on disk?

Posted on In QA

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).

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 by Peter M..

Leave a Reply

Your email address will not be published. Required fields are marked *