Last updated on November 21, 2020 by Dan Nanni
A static route is defined by statically configuring a next-hop router IP address for a specific destination network. You can add a static route by using
route add or
ip route add command. However, any static route so added is not persistent across reboots.
If you would like to configure a permanent static route on Linux, do the following.
In this example, it is assumed that you want to configure a static route for network 10.10.0.0/16 that is reachable via next hop 10.10.5.5 on eth0.
$ sudo echo "10.10.0.0/16 via 10.10.5.5" >> /etc/sysconfig/network-scripts/route-eth0
$ sudo echo "up route add -net 10.10.0.0/16 gw 10.10.5.5 dev eth0" >> /etc/network/interfaces