Steps to Add Static Routes to Linux

  
                

In the computer system, static routing and dynamic routing are different. Static routing is the routing information manually configured by the user to protect the network security. How to add a static route to the Linux system? How to add a permanent route? The following small series will introduce you to the method of adding a static router to Linux.

1, add a default route

route add default gw 10.0.0.1 (default takes effect only memory)

boot from the start can be appended 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 To 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 manually Create a

The above is the introduction of Linux to add static routes, this article describes the addition of a default route, static routing, Yong The method of long static routing is selected according to the requirements.

Copyright © Windows knowledge All Rights Reserved