How to add a static route to Linux

  
Today, I have brought the steps of adding static routes for Linux, I hope to help my friends!

1. Add a default route
route add default Gw 10.0.0.1 (default only works in memory)
Boot from boot can be added to /etc/rc.local file
echo “route add default gw 10.0.0.1” 》》/etc/rc .local
2. Add a static route
route add -net 192.168.2.0/24 gw 192.168.2.254
To do this permanently:
echo “any net 192.168.2.0/24 gw 192.168.2.254” 》》/etc/sysconfig/static-routes
Adding a static route to a host
route add -host 192.168.2.2 gw 192.168.2.254
To be permanent Do this:
echo “any host 192.168.2.2 gw 192.168.2.254 ” 》》/etc/sysconfig/static-routes
Note: Linux does not have this file by default, you have to create a manual
Linux adds a static route method, this article describes adding a default route, static route, permanent static road Way, add choose according to demand.

Copyright © Windows knowledge All Rights Reserved