ش | ی | د | س | چ | پ | ج |
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
To keep the Static Route persistent on Linux or you want to add the route entries to the network
script files (not using the route command) then all you need to do is to edit the file
/etc/network/interfaces
and the static routes in the following format:
up route add [-net|-host] <host/net>/<mask> gw <host/IP> dev <Interface>
Example
up route add -net 172.20.11.0/16 gw 172.20.10.254 dev eth1
And the file will like the following
sudo cat /etc/network/interfaces
The output should show something like this
sudo cat /etc/network/interfaces
The output should show something like this
The above has 2 Ethernet interfaces and the static route is added to the interface eth1.
For the change to /etc/network/interface to take effect. please restart the "networking" service as follows:
sudo /etc/init.d/networking restart
NOTE: If you added the route already using the "route" then there is no need to restart the networking service because, the next time server is restarted this takes effect.