Detailed explanation of the route command

Source: Internet
Author: User

1. Specific functions
This command is used to display and modify entries in the local IP address routing table. Use a route without parameters to display help.

2. Syntax explanation
Route [-F] [-p] [Command [destination] [mask netmask] [gateway] [metric] [If inte *** ce]
3. parameter description
-F
Clear all routes that are not the primary route (the subnet mask is 255.255.255.255), the back-to-network route (the destination is 127.0.0.0, And the subnet mask is 255.255.255.0), or multiple

Route table of the route entry whose destination is 224.0.0.0 and whose subnet mask is 240.0.0.0. If it is used with one of the commands (such as ADD, change, or delete ),

Clear before running the command.

-P
When used together with the Add command, specify that the route is added to the Registry and initialize the IP route table when starting the TCP/IP protocol. By default, it is not guaranteed when the TCP/IP protocol is enabled.

Save the added route. When used with the print command, the permanent route list is displayed. All other commands ignore this parameter. The location where the permanent route is stored in the registry is

Hkey_local_machsystemcurrentcontrolsetservicestcpipparameterspersistentroutes.

Command specifies the command to run. The following table lists valid commands.
Destination
_ Specify the network destination address of the route. The destination address can be an IP address (the host address bit of the network address is set to 0), and the host route is an IP address

The route is 0.0.0.0. Mask
Subnetmask
Specifies the netmask (also known as the subnet mask) associated with the target network address ). The subnet mask can be an appropriate subnet mask for the IP address and for the host route

255.255.255.255, Which is 0.0.0.0 for the default route. If this parameter is ignored, the subnet mask 255.255.255.255 is used. When defining a route, the relationship between the destination address and subnet mask

, The target address cannot be more detailed than its corresponding subnet mask. In other words, if one of the subnet masks is 0, the corresponding bit in the target address cannot be set to 1.

Gateway
Specify the previous or next hop IP address that exceeds the reachable address set defined by the Network target and subnet mask. The gateway address is allocated to the connected subnet.

The IP address of the subnet interface. A gateway address is a directly accessible IP address allocated to an adjacent router.

Metric
Specify the integer (range: 1 ~ 9999). It is used to select the route that best matches the destination address in the forwarding packet among multiple routes in the routing table. Selected

Has the least number of hops. The number of hops reflects the quantity, speed, reliability, throughput, and management attributes of the hops.

If inte *** ce specifies the interface index of the interface that the target can reach. Use the route print command to display the index list of the interface and its corresponding interface. For interface indexes

Use a decimal or hexadecimal value. For hexadecimal values, add 0x before the hexadecimal number. When the if parameter is ignored, the interface is determined by the gateway address.

Note: the value of the number of hops column in the route table is large because TCP/IP is allowed to automatically determine the route table based on the IP address, subnet mask, and default gateway configuration of each LAN interface.

The number of hops. By default, the auto-determine interface hops are enabled to determine the speed of each interface and adjust the route hops of each interface. Therefore, the routes created by the fastest interface have the lowest

The number of hops. To delete the number of hops, disable automatic interface hops in the Advanced properties of the TCP/IP protocol for each LAN connection.

If an appropriate entry exists in the local network file of the systemrootsystem32driversetc folder, the name can be used for destination. As long as the name can pass the "Domain Name

The system "(DNS) queries such standard host name resolution technology into IP addresses, you can use it for gateway, DNS queries are stored in systemrootsystem32driversetc
The local host file and NetBIOS name in the folder.
For the print or delete command, you can ignore the gateway parameter and use wildcards to indicate the target and gateway. The value of destination can be a wildcard specified by the asterisk.

If the specified target contains an asterisk (*) or question mark (?), It is regarded as a wildcard and only prints or deletes matched target routes. An asterisk represents a sequence of any character, and a question mark represents any character.

. For example, 10. *. 1, 192. 168. *, 127. *, and * 224 * are all effective use of the asterisk wildcard.

If an invalid combination of the target and subnet mask (netmask) values is used, "route bad gateway address" is displayed.
Netmask "error message. This error occurs when one or more bits in the target are set to 1 and their corresponding bits in the subnet mask are set to 0. The object can be expressed in binary notation.

Label and subnet mask to check this situation. The subnet mask in binary format includes a series of 1 representing the destination network address and a series of 0 representing the destination host address.

Points. View the target to determine the target host address (defined by the subnet mask)

Set some bits to 1.
The route command of Windows 98 does not support the-p parameter.
This command is only available when TCP/IP is installed as a component of the network adapter attribute in a network connection.
4. Examples
Example 1: To display the complete content of the IP route table, run the following command:
Route print
Example 2: to display a route entry starting with 10 in the IP route table, run the following command:
Route print 10 .*
Example 3: to add a default route entry whose default gateway address is 192.168.12.1, run the following command:
Route add 0.0.0.0 mask 0.0.0.0 192.168.12.1
Example 4: to add a route entry whose destination is 10.41.0.0, whose subnet mask is 255.255.0.0, and whose next hop address is 10.27.0.1, run 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 whose destination is 10.41.0.0, The subnet mask is 255.255.0.0, And the next hop address is 10.27.0.1, run the following command:
Route-P add 10.41.0.0 mask route 255.0.0 10.27.0.1
Example 6: to add a route entry with the target 10.41.0.0, subnet mask 255.0.0, Next Hop address 10.27.0.1, and number of hops 7, run 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 entry whose destination is 10.41.0.0, whose subnet mask is 255.255.0.0, whose next hop address is 10.27.0.1, and whose interface index is 0x3, run the following command:
Route add 10.41.0.0 mask route 0.0 10.27.0.1 if 0x3
Example 8: to delete a route whose destination is 10.41.0.0 and the subnet mask is 255.255.0.0, run the following command:
Route Delete 10.41.0.0 mask 255.255.0.0
Example 9: to delete all routes starting with 10 in the IP route table, run the following command:
Route Delete 10 .*
Example 10: to change the next hop address of the route whose destination is 10.41.0.0 and whose subnet mask is 255.255.0.0 from 10.27.0.1 to 10.27.0.25, run the following command:
Route change 10.41.0.0 mask 255.255.0.0 10.27.0.25
Example 11: Add a static route so that all the CIDR blocks destined for 172.0.0.0 are forwarded to the route whose network is 172.25.25.1.
Route add 172.0.0.0 mask 255.0.0.0 172.25.25.1 metric 2-P

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.