Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add static routes to route

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to add static routes in route, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

The method is as follows: 1, the route added to the host, "# route add-host 192.168.1.11 dev eth0"; 2, the route added to the network, "# route add-net 192.168.1.0 eth2".

The specific operation methods are as follows:

Use the route command to add

The route added using the route command becomes invalid after the machine is rebooted or the network card is restarted. Method:

/ / routes added to the host

# route add-host 192.168.1.11 dev eth0 # route add-host 192.168.1.12 gw 192.168.1.1

/ / routes added to the network

# route add-net 192.168.1.11 netmask 255.255.255.0 eth0 # route add-net 192.168.1.11 netmask 255.255.255.0 gw 192.168.1.1 # route add-net 192.168.1.0 net 24 eth2

/ / add a default gateway

# route add default gw 192.168.2.1

/ / Delete a route

# route del-host 192.168.1.11 dev eth0

Second: the method of setting permanent route under linux:

. / etc/sysconfig/static-routes: any net 192.168.3.0/24 gw 192.168.3.254 any net 10.250.228.128 netmask 255.255.255.192 gw 10.250.228.129

The method of using static-routes is the best. Both the restart of the system and service network restart will take effect.

What is the static-routes file? this is a file that is called when the network script is executed. The file is placed in the / etc/sysconfig directory, and the location in the network script is:

# Add non interface-specific static-routes.if [- f / etc/sysconfig/static-routes]; thengrep "^ any" / etc/sysconfig/static-routes | while read ignore args; do/sbin/route add-$argsdonefi

As you can see from this script, this is the way to add static routes. Static-routes is written as

Any net 192.168.0.0 any net 16 gw Gateway ip. The above is how to add static routes to route. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report