Configure a routing policy for the ROUTE command to enable the dual-nic to access both the Intranet and Internet

Source: Internet
Author: User

A friend's computer is connected to both a wired network card and a Wi-Fi network card, respectively, to connect the LAN and the Internet. The problem is that one of the network cards must be disabled each time to access the LAN or the Internet. This is very inconvenient. Ask me if I have any solutions. The answer is yes. Set a routing policy.

First, analyze the cause of the problem. We all know that the NIC settings page allows you to enter the IP address, subnet mask, and default gateway. The root cause of the problem lies in the default gateway. The default gateway refers to the IP address that the default gateway directs to, no matter where the traffic goes. Now we have two NICs with the default gateway (either set by yourself or allocated by DHCP), and their points are different, as a result, the traffic does not know which default gateway to go to. As a result, all websites cannot be accessed normally.

The solution is simple. You can set only one default gateway, and then manually specify the gateway of the other Nic for traffic differentiation. The problem is, which network card's default gateway is suitable? Wired or wireless network interfaces?

The answer is to specify the default gateway for accessing the Internet NIC (here it is a wireless Nic). The reason is that the range of Internet network segments is too large, so we cannot specify all network segments one by one; however, the specified Intranet CIDR block is different, because the Intranet CIDR block is only the three private CIDR blocks. We can easily solve this problem by using a single command.

OK. The above is the theoretical part. The procedure is as follows:

1. If the IP address of the NIC you access to the LAN (this is a wired Nic) is fixed, that is, you can set the IP address on your own, open the nic ip Address Settings page, and delete the Default Gateway (nothing left ), see step 3.

2. If the IP address of your lan nic (wired Nic) is allocated by DHCP, that is, you cannot delete the default gateway, open the IP Address Settings page of the Internet NIC (Wireless Nic, select "advanced", remove "automatic hops", manually enter "1", save and exit.

In this case, all traffic goes first to the Internet NIC (Wireless Nic). Next we need to guide the Intranet traffic to the Intranet NIC (wired Nic ).

3. Open CMD and enter the Static Routing command. Here, you need to figure out your intranet CIDR Block and Intranet gateway. Usually ipconfig/all can help you.

Route-p add 192.168.0.0 mask 255.255.255.0 192.168.0.1

Route-p add 172.16.0.0 mask route 255.0.0 172.16.0.254

Route-p add 10.0.0.0 mask route 0.0.0 10.0.0.254

Here I have written three situations at will.-p refers to permanent addition to the route table. The first IP segment is your intranet segment, and the second is the subnet mask, the three types of private CIDR blocks are different. You can use your own check box. The third IP address is the default gateway of your intranet.

At this point, the Internet traffic will go through the wireless network card, and the matching Intranet traffic will go through the gateway you specified. The traffic will not conflict, and the network card can also be used at the same time.

Related Article

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.