Where are the Linux routing table entries stored on disk?
Storage of routing table entries
Linux routing tables exist in kernel memory during runtime. To persist routes across reboots, you need to store them on disk and have them reloaded during system startup. The mechanism varies depending on your network management setup.
systemd-networkd and netplan (modern systems)
On contemporary distributions using systemd-networkd or netplan, define routes in YAML configuration files.
With netplan, create or edit /etc/netplan/01-netcfg.yaml:
network:
version: 2
ethernets:
eth0:
dhcp4: true
routes:
- to: 10.1.1.0/24
via: 192.168.1.1
metric: 100
- to: 10.2.0.0/16
via: 192.168.1.254
Apply with:
sudo netplan apply
With systemd-networkd, place .network files in /etc/systemd/network/:
[Match]
Name=eth0
[Network]
DHCP=yes
[Route]
Destination=10.1.1.0/24
Gateway=192.168.1.1
Metric=100
[Route]
Destination=10.2.0.0/16
Gateway=192.168.1.254
Reload with:
sudo systemctl restart systemd-networkd
NetworkManager
NetworkManager stores configuration in /etc/NetworkManager/system-connections/ as .nmconnection files. Edit these directly or use the GUI:
nmtui
Or configure routes via nmcli:
nmcli connection modify "connection-name" +ipv4.routes "10.1.1.0/24 192.168.1.1"
nmcli connection up "connection-name"
Legacy: /etc/sysconfig/static-routes (RHEL/CentOS 7 and earlier)
On older RHEL/CentOS systems using traditional init scripts, static routes go in /etc/sysconfig/static-routes:
any host 10.1.1.8 gw 8.9.10.11
any net 10.2.0.0 netmask 255.255.255.0 gw 192.168.1.1
The format is any [net|host] destination [netmask mask] gw gateway. The network script parses lines starting with any and passes them to route add.
Per-interface routes (legacy)
On systems with ifcfg scripts, routes can also be defined in /etc/sysconfig/network-scripts/route-eth0:
10.1.1.0/24 via 192.168.1.1
10.2.0.0/16 via 192.168.1.254 metric 100
Verifying persistent routes
After configuration, verify routes are loaded:
ip route show
Check route configuration is correct:
ip route show table all
To view all route tables:
cat /etc/iproute2/rt_tables
Adding runtime-only routes
For temporary routes that don’t survive reboot, use ip route:
sudo ip route add 10.1.1.0/24 via 192.168.1.1
sudo ip route del 10.1.1.0/24
These disappear after reboot unless persisted through the appropriate configuration method above.
Key differences from iptables
Unlike firewall rules (iptables/nftables), routing table entries aren’t typically stored in a single dedicated dump file like /etc/sysconfig/iptables. Instead, they’re defined as part of network interface configuration, allowing routes to be associated with specific connections and applied conditionally based on network state.