Configure routes in Windows

Source: Internet
Author: User

In Windows, manually set the route mainly in the dossystem command line (in the run input column, TYPE command or cmd.
Enter the command route and press enter to display dozens of lines in English. It mainly describes how to add, delete, and modify routes in windows. The following is a brief introduction:

The route command format is as follows:
Route [-F] [-p] [command] [destination] [mask netmask] [gateway] [metric] [If interface]
Here, the-F parameter is used to clear the route table, and the-p parameter is used to permanently retain a route (that is, the route will not be lost when the system is restarted, but it is invalid in Windows 95 ).
Commands include print, add, delete, and change.
Destination indicates the target IP address to be reached.
The mask is the keyword of the subnet mask. Netmask indicates the specific subnet mask. If not specified, the default subnet mask is 255.255.255.255 (single-Host IP address). Therefore, be careful when entering the mask. Check whether an IP address or IP address segment is added. 0.0.0.0 is available for all egress subnet masks.
Gateway indicates the egress gateway.
Other interfaces and metric represent the number of special routing interfaces and the cost of reaching the target address.

We describe how to set a route in Windows based on the single Nic and multi-nic (taking dual Nic as an example.
1. Single NIC:
In Windows, there are four basic routes. For details, refer to (type the route print command:
 

 

 

 

The preceding route is a Windows route that never disappears. If the preceding route is incomplete, it indicates that the installation and running of TCP/IP has some basic problems, or the local network configuration or installation has problems.
 

In the preceding table, 127.0.0.1 is used to test the loopback address, which cannot be a valid network address. The IP address of pC1 is 192.168.97.1, the IP address of the local port of router 1 (used for Internet access) is 192.168.97.10, And the IP address of the local port of router 2 (used for office network access) is 192.168.97.11.
If pC1 wants to access the Internet and the office network at the same time, it is usually because the default gateway is modified repeatedly in the Windows Network attribute, and only one network segment can be accessed at a time, which is inconvenient and troublesome. To solve this problem, enter the following command in the doscommand:
Route add 0.0.0.0 maks 0.0.0.0 192.168.97.10 (used on the Internet ),
Route add 10.42.29.0 mask 255.255.255.0 192.168.97.11 (used on the office network ).
In this way, the Internet is used as the default route, and the office network is used as a special route to add. Of course, if there are other systems, you can add the same route.
To ensure that the route is correct and avoid route confusion, it is best to delete the route first and then add the route. For example, the preceding command can be changed:
Route delelte 0.0.0.0
Route add 0.0.0.0 maks 0.0.0.0 192.168.97.10
Route add 10.42.29.0 mask 255.255.255.0 192.168.97.11
To ensure that the route settings take effect for a long time, you can add the preceding command to the autoexec. BAT file, that is, the route is automatically set as soon as the operating system starts. You can also add the-p parameter when adding a route for the first time.

The details are as follows:
Route-P add 0.0.0.0 maks 0.0.0.0 192.168.97.10
Route-P add 10.42.29.0 mask 255.255.255.0 192.168.97.11.
In this case, use Route print to view the route. Two permanent routes are added to the route table.

2. Multiple NICs (take dual NICs as an example)
If two NICs exist on the same PC and are connected to two systems with different network segments, see the following network connection:

Generally, the dual-nic and dual-gateway are added to the PC, and the two subsystems can be easily connected. However, due to Windows systems, it is often prone to Gateway fluctuations or instability. For example, if you cannot Ping An office automation address, the system returns information from 192.168.97.10 (vro1 1, now you can view the network route. The route table is normal and you need to refresh the route.
In fact, you can take a similar approach to a single Nic, remove the gateway in the network attribute, and manually set the route. Manual routing is more accurate and free. For example, you can manually control whether to access a website, a certain CIDR block, or all CIDR blocks.

For more information, enter the following command at the DOS prompt:
Route Delete 0.0.0.0
Route add 0.0.0.0 mask 0.0.0.0 192.168.97.10 (network adapter 1 addressing route, Internet, default route)
Route add 10.42.0.0 mask route 255.0.0 10.42.29.10 (network adapter 2 addressing routing, on the office network ).
Of course, you can add the-p parameter or add the route adding information to the automatic batch processing file to make the route information take effect permanently.

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.