Requirements: The local computer has multiple networks, and the specified network is set to use the A network card, and the other network uses the B network card. For example, if a server network has a whitelist and only allows access from the exit IP of the A NIC card, when we use the B NIC to access, the access will be denied or timed out.
View the current route table as shown in the following figure:
route [-f] [-p] [command [destination] [mask netmask] [gateway] [metric metric] [if interface]
-f Clear the routing table for all gateway ingresses. -p makes the route permanent when used with the add command. Command specifies the command you want to run (Add/Change/Delete/Print). Destination specifies the network destination for that route. mask Netmask specifies the network mask associated with the network target (also known as the subnet mask). The gateway specifies the forward or next hop IP address that the network destination defines as a set of addresses and subnet masks can reach. metric Metric specifies an integer cost scale (from 1 to 9999) for the route, which can be used when selecting from multiple routes in the routing table that best match the destination address of the forwarded packet. if Interface specifies an interface index for interfaces that can access the target. To get a list of interfaces and their corresponding interface indexes, use the display function of the route print command. Interface indexing can be done using decimal or hexadecimal values
>0.0.0.0 represents the default route and helps the router send packets that cannot be queried in the routing table. If you set up an all-zero network route, all packets that cannot be queried in the routing table will be sent to the all-zero network route
>255.255.255.255 Netmask for the network address of a specific host
The >print command displays a list of interfaces and their corresponding interface indexes. For interface indexes, decimal or hexadecimal values can be used. For hexadecimal values, add 0x before the hexadecimal number. When the if parameter is ignored, the interface is determined by the gateway address.
ipconfig /all // to view the network configuration
Physical Address. . . . . . . . . : 00-16-D3-27-49-AA Dhcp Enabled. . . . . . . . . . . : No IP Address. . . . . . . . . . . . : 192.168.1.89 Subnet Mask . . . . . . . . . . . : 255.255.255.0 IP Address. . . . . . . . . . . . : 124.207.235.42 Subnet Mask . . . . . . . . . . . : 255.255.255.240 Default Gateway . . . . . . . . . : 124.207.235.34 192.168.1.1 DNS Servers . . . . . . . . . . . : 202.106.0.20 8.8.8.8
//查看本机路由表 1.route print
//删除默认路由 2.route delete 0.0.0.0
//添加192.168.1.0/24 网段的静态路由 3.route -p add 192.168.1.0 mask 255.255.255.0 192.168.1.1
//添加对特定主机123.126.72.34的静态路由 4.route -p add 123.126.72.34 mask 255.255.255.255 124.207.235.34
//添加默认路由 5.route -p add 0.0.0.0 mask 0.0.0.0 192.168.1.1
//添加218.206.73.0/24 网段的静态路由 6.route -p add 218.207.73.0 mask 255.255.255.0 124.207.235.34
Other operating examples
To display the full contents of the IP routing table, type: route print To display the IP route table with 10. To start the route, type: route print 10.*
To add a default route with a default gateway address of 192.168.12.1, type: route add 0.0.0.0 mask 0.0.0.0 192.168.12.1
To add a route with a destination of 10.41.0.0, a subnet mask of 255.255.0.0, and a next hop address of 10.27.0.1, type: route add 10.41.0.0 mask 255.255.0.0 10.27.0.1
To add a persistent route with a destination of 10.41.0.0, a subnet mask of 255.255.0.0, and a next hop address of 10.27.0.1, type: route -p add 10.41.0.0 mask 255.255.0.0 10.27.0.1
To add a route with a destination of 10.41.0.0, a subnet mask of 255.255.0.0, a next hop address of 10.27.0.1, and a hop count of 7, type: route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 metric 7
To add a route with a destination of 10.41.0.0, a subnet mask of 255.255.0.0, a next hop address of 10.27.0.1, and an interface index of 0x3, type: route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 if 0x3
To delete a route with a destination of 10.41.0.0 and a subnet mask of 255.255.0.0, type: route delete 10.41.0.0 mask 255.255.0.0
To remove the IP route table with a 10. For all routes to start, type: route delete 10.*
To change the next hop address of a route destined for 10.41.0.0 with a subnet mask of 255.255.0.0 from 10.27.0.1 to 10.27.0.25, type: route change 10.41.0.0 mask 255.255.0.0 10.27.0.25
Finally, attach a batch file to use the default network when accessing the domestic IP, otherwise use the VPN network:
VPN-skip-China-route-Window-DM-master.zip
(132.49 KB, Number of downloads: 0, 售价: 3 粒MB)
|