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

The usage of route add command

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces the usage of route add command, which has certain reference value and can be used for reference by friends who need it. I hope you will learn a lot after reading this article. Next, let the editor take you to learn about it.

The route add command is used to display and modify entries in the local IP routing table, using ROUTE with no parameters to display help with the code [route [- f] [- p] [command [destination] [mask netmask]..].

Route add command usage:

I. specific functions

This command is used to display and modify entries in the local IP routing table. Use ROUTE with no parameters to display help.

Second, detailed explanation of grammar

Route [- f] [- p] [command [destination] [mask netmask] [gateway] [metric metric] [if inte***ce]

Third, parameter description

-f

Clear all entries that are not primary routes (routes with a subnet mask of 255.255.255.255), loopback network routes (with a destination of 127.0.0.0 with a subnet mask of 255.255.255.0), or multicast routes (with a destination of 224.0.0.0, routes with a subnet mask of 240.0.0.0). If it is used in conjunction with one of the commands, such as Add, Change, or Delete, the table is cleared before running the command.

-p

When used with the Add command, the specified route is added to the registry and the IP routing table is initialized when the TCP/IP protocol is started. By default, added routes are not saved when the TCP/IP protocol is started, and when used with the Print command, a list of permanent routes is displayed. All other commands ignore this parameter. The location where permanent routes are stored in the registry is HKEY_LOCAL_MACHSYSTEMCurrentControlSetServicesTcpipParametersPersistentRoutes.

Command specifies the command to run. The following table lists valid commands.

Destination

Specifies the network destination address of the route. The destination address can be an IP network address (where the host address bit of the network address is set to 0), the IP address for the host route, and 0.0.0.0 for the default route.

Mask

Subnetmask

Specifies the netmask (also known as the subnet mask) associated with the network destination address. The subnet mask can be an appropriate subnet mask for IP network addresses, 255.255.255.255 for host routes and 0.0.0.0 for default routes. If omitted, the subnet mask 255.255.255.255 is used. When defining a route, the destination address cannot be more detailed than its corresponding subnet mask because of the relationship between the destination address and the subnet mask. In other words, if one bit of the subnet mask is 0, the corresponding bit in the destination address cannot be set to 1.

Gateway

Specifies a previous or next hop IP address that exceeds the set of reachable addresses defined by the network destination and subnet mask. For locally connected subnet routes, the gateway address is the IP address assigned to the subnet interface. For remote routes that can only be used through one or more routers, the gateway address is a directly reachable IP address assigned to neighboring routers.

Metric

Specifies the integer value of the required number of hops for the route (range is 1-9999), which is used to select the route that best matches the destination address in the forwarding packet among the multiple routes in the routing table. The selected route has the least number of hops. The number of hops can reflect the number of hops, path speed, path reliability, path throughput and management attributes.

If inte***ce specifies the interface index of the interface that the destination can reach. Use the Route print command to display a list of interfaces and their corresponding interface indexes. You can use decimal or hexadecimal values for interface indexes. For hexadecimal values, add 0x before the hexadecimal number. When the if parameter is ignored, the interface is determined by the gateway address.

The Route command of Windows 98 does not support the-p parameter.

This command is available only if the TCP/IP protocol is installed as a component of the network adapter property in a network connection.

Fourth, give examples to illustrate

Example 1: to display the complete contents of the IP routing table, execute the following command:

Route print

Example 2: to display 10. 0 in the IP routing table. To start the route, execute the following command:

Route print 10.*

Example 3: to add a default route with a default gateway address of 192.168.12.1, execute the following command:

Route add 0.0.0.0 mask 0.0.0.0 192.168.12.1

Example 4: to add a route with a destination of 10.41.0.0, a subnet mask of 255.255.0.0, and the next hop address of 10.27.0.1, execute the following command:

Route add 10.41.0.0 mask 255.255.0.0 10.27.0.1

Example 5: to add a permanent route with a destination of 10.41.0.0, a subnet mask of 255.255.0.0, and the next hop address of 10.27.0.1, execute the following command:

Route-p add 10.41.0.0 mask 255.255.0.0 10.27.0.1

Example 6: to add a route with a destination of 10.41.0.0, a subnet mask of 255.255.0.0, a next hop address of 10.27.0.1, and a hop count of 7, execute the following command:

Route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 metric 7

Example 7: to add a route with destination 10.41.0.0, subnet mask 255.255.0.0, next hop address 10.27.0.1, and interface index 0x3, execute the following command:

Route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 if 0x3

Example 8: to delete a route with a destination of 10.41.0.0 and a subnet mask of 255.255.0.0, execute the following command:

Route delete 10.41.0.0 mask 255.255.0.0

Example 9: to delete 10. 0 from the IP routing table. For all routes that start, execute the following command:

Route delete 10.*

Example 10: to change the next hop address of a route with destination 10.41.0.0 and subnet mask 255.255.0.0 from 10.27.0.1 to 10.27.0.25, execute the following command:

Route change 10.41.0.0 mask 255.255.0.0 10.27.0.25

Example 11: to add a static route so that those with a destination of 172.0.0.0 are forwarded to a route with a network of 172.25.25.1

Route add 172.0.0.0 mask 255.0.0.0 172.25.25.1 metric 2-p Thank you for reading this article carefully. I hope it is helpful for the editor to share the usage of the route add command. At the same time, I also hope that you will support us, pay attention to the industry information channel, and find out if you encounter problems. Detailed solutions are waiting for you to learn!

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