Article Title: Use the route command to solve the problem of dual-network access on one machine. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
We often encounter the need for a computer to access two networks at the same time (one is the Internet and the other is the enterprise intranet ).
Take this unit as an example: the address is fictitious ^_^
The machine has two NICs connected to the two switches.
Internet address: 218.22.123.123, subnet mask: 255.255.255.0, Gateway: 218.22.123.254
Intranet address: 10.128.123.123, subnet mask: 255.255.255.0, Gateway: 10.128.123.254
If you set the IP address and gateway of each network card according to the normal setting method, you will see it when you use route print in cmd.
Network Destination Netmask Gateway Inte *** ce Metric
0.0.0.0 0.0.0.0 218.22.123.254 218.22.123.123 20
0.0.0.0 0.0.0.0 10.128.123.254 10.128.123.123 1
That is, there are two gateways pointing to 0.0.0.0, so there will be a route conflict and both networks will not be accessible. To access two networks at the same time, you must use the route command.
Step 1: route delete 0.0.0.0 "delete all 0.0.0.0 routes"
Step 2: route add 0.0.0.0 mask 0.0.0.0 218.22.123.254 "add 0.0.0.0 network route"
Step 3: route add 10.0.0.0 mask route 0.0.0 10.128.123.254 "add 10.0.0.0 network route"
In this case, you can access the two networks at the same time. However, if you encounter a problem, the route added using the above command will be automatically lost after the system restarts. How can you save the existing route table? Www.bitsCN.net China Network Management blog
In win2000, you can use route add-p to add a static route. After restart, the route will not be lost. Note: remove the gateway that is connected to the NIC of the enterprise intranet in the TCP/IP settings before use.