The file that holds permanent routing table information varies depending on the operating system and the network configuration tools used. Here are the common locations and methods for setting up persistent static routes:

On Linux:

  1. Debian-based Systems (e.g., Ubuntu):

    • You can define static routes in the /etc/network/interfaces file or in a separate file under /etc/network/interfaces.d/.
    • Example entry in /etc/network/interfaces:
      auto eth0
      iface eth0 inet static
          address 192.168.1.100
          netmask 255.255.255.0
          gateway 192.168.1.1
          up route add -net 10.10.10.0/24 gw 192.168.1.1
          down route del -net 10.10.10.0/24 gw 192.168.1.1
  2. Red Hat-based Systems (e.g., CentOS, Fedora, RHEL):

    • You can define static routes in the /etc/sysconfig/network-scripts/route-<interface> file.
    • Example file /etc/sysconfig/network-scripts/route-eth0:
      10.10.10.0/24 via 192.168.1.1 dev eth0
  3. Systemd-networkd:

    • If you're using systemd-networkd, you can define routes in .network files located in /etc/systemd/network/.
    • Example file /etc/systemd/network/10-static.network:
      [Match]
      Name=eth0
      
      [Network]
      Address=192.168.1.100/24
      Gateway=192.168.1.1
      
      [Route]
      Destination=10.10.10.0/24
      Gateway=192.168.1.1

On macOS:

  • Static routes on macOS can be added by creating a startup script that runs at boot time.
  • Example script /etc/rc.local (make sure the script is executable):
    #!/bin/sh
    /sbin/route add -net 10.10.10.0/24 192.168.1.1

Summary:

  • Debian/Ubuntu: /etc/network/interfaces or /etc/network/interfaces.d/*
  • Red Hat/CentOS: /etc/sysconfig/network-scripts/route-<interface>
  • systemd-networkd: /etc/systemd/network/*.network
  • macOS: Custom script in /etc/rc.local
  • Windows: route -p add command (stored in the registry)

These configurations ensure that your static routes persist across system reboots.