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
This website is made possible by minimal ads and your gracious donation via PayPal or credit card
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.