This is the most basic knowledge of the network, but some days ago encountered this problem, found that quickly forget, just write it down here.
Basic principle
First, two pictures.
Network packet flow to the correct routing settings
Network packet flow with two default route settings
Your computer is connected to the network at the same time, will send a lot of network packets to different addresses, the first machine will cache a routing table, your network card according to this routing table, determine the next station of your packet address is.
Normally, access to special segment addresses is routed, such as packets that access the 10.11.12.0/24 segment because the routing conditions are met
10.11.12.0 255.255.255.0 10.11.12.1
Therefore, it will be directed to 10.11.12.1 this gateway address, and then go to find their own purpose.
And those that do not meet the routing conditions, will be a brain run to the default route address up, that is
0.0.0.0 0.0.0.0 192.168.1.1 (default gateway)
However, if you have two default network management in your machine cache, as shown in the figure below
Then there are two ways to go if you can't find a bag to go to.
A 0.0.0.0 0.0.0.0 192.168.1.1-----Can normally find the road of Baidu Google
A 0.0.0.0 0.0.0.0 10.11.12.1-----Can't find the way Baidu Google
So, when you visit Baidu Google, some request package Walk 192.168.1.1 Road, some will go another.
Walk 192.168 The package of this road can not return the result because the packet is lost, go the other way of the package is directly into the dead end, directly lost.
So, your Internet will appear, the network is unstable situation. Because sometimes a batch of bags to go 192.168 that road, you visit the outside network Normal, a group of packets go the wrong way, you will not go to the outside network.
Therefore, on a single computer, only one default route can be set, and this default route is to be able to go through the extranet gateway.
And for the access to the internal network address, you only need to set the appropriate route for the intranet segment you want to access, then these put back will not be unable to find the road and run to the default network management.
This is basically the truth.
Next, basic setup (in Windows environment)
To view the local cache routing table
CMD inside execution
Route print
There will be two types of routing, temporary routing and permanent routing, and temporary routing will disappear when you reboot, and the permanent route restart machine still exists.
Add a route
Route add 10.11.12.0 (network address) Mask 255.255.255.0 (subnet mask) 10.11.12.1 (gateway address)
Delete a route
Route Delete 10.11.12.0 (network address)
Change a route
Route Change <span style= "font-family:arial, Helvetica, Sans-serif;" >10.11.12.0 (network address) Mask 255.255.255.0 (subnet mask) 10.11.12.2 (gateway address)
Problems with permanent routing
The route added above is a temporary route, and if you want to make it a permanent route, you can
The last use parameter of the route add command is-P.
However, I do not recommend adding permanent routes here because permanent route removal is cumbersome. And you can write the route you want to add into a batch file, each time you double-click to execute it.
However, if you already have a permanent route in your machine, you need to delete it in the registry
[Hkey_local_machine\system\currentcontrolset\services\tcpip\parameters\persistentroutes]
[Hkey_local_machine\system\controlset001\services\tcpip\parameters\persistentroutes]
[Hkey_local_machine\system\controlset002\services\tcpip\parameters\persistentroutes]
below to find the corresponding entry to delete.
This method, I used to experiment on the XP system, every time the direct success, but in the Window 7 system experiment encountered some problems, can not be removed smoothly.
Therefore, it is still not recommended to use a permanent route.
Configure routing under Windows to solve the problem of both internal and external network falling offline