Detailed explanation of the route command and instance usage, and simultaneous access to the Intranet and Internet; detailed explanation of the route command

Source: Internet
Author: User

Detailed explanation of the route command and instance usage, and simultaneous access to the Intranet and Internet; detailed explanation of the route command
Route command details and use instance 12:19:41 | category: Others | label: route | font size subscription 1. to use the background, you need to access two networks. One is the Intranet environment where the deployment environment is located. This environment cannot be connected to the Internet, and the other is probably a wireless network. If the two are connected, it is likely that one party cannot work, that is, the Internet or Intranet cannot, you often need to use tedious "disable network connection" and "enable network connection" operations to switch between Intranet and Internet, which is very troublesome. To solve this problem, you can use the route command to make both internal and external networks available. 2. The route command is to display and modify the entry network command in the local IP address routing table. The route command syntax is as follows: route [-f] [-p] [Command [Destination] [mask Netmask] [Gateway] [metric Metric] [if Interface] route commands commonly used commands are as follows: 1) route delete: delete a route; 2) route print: print the route's Destination; 3) route add: add a route; 4) route change: change an existing route. Generally, the three commands route delete, route add, and route print can solve all routing functions. 2.1 print route information use the command: route print. ========================================================== ======================================== Interface List0x1 ms tcp Loopback interface0x2 00 26 18 31 4f d1 Realtek RTL8168C (P) /8111C (P) PCI-E Gigabit Ethernet NIC-packet scheduler micro port 0x50004 00 53 45 00 00 00 WAN (PPP/SLIP) interface ===================================================== ========================================================== ========================================================== ====================================== ========= Active Routes: network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 255.255.1 0.0.0.0 0.0.0 192.168.2.226 192.168.2.79 20 255.255.255.255.255.1 255.255.127.0.0.1 127.0.0.1 50 255.255.255.255.255.0.0.0 127.0.0.1 0.0.1 255.1 192.168. 2.0 255.255.255.0 192.168.2.79 192.168.2.79 20 192.168.2.79 255.255.255.255.20 192.168.2.255 255.192.168.2.79 192.168.2.79 20 255.240.0.0.0 192.168.2.79 192.168.2.79 20 255.240.0.0.0 255.255.255.255.255.1 255.255.192.168.2.79 192.168.2.79 1 Default Gateway: 116.69.106.119 ======================================== ========================================== Persistent Routes: the first column of None is the destination network address. Lists all the CIDR blocks connected to the vro. The network mask column in the second row provides the subnet mask of the network segment, instead of the subnet mask of the network adapter connected to the network segment. This basically allows the router to determine the destination network address class. The third column is the gateway. Once the vro determines the destination network to which the packet will be forwarded, The vro will view the gateway list. The gateway table tells the router which IP address the packet should be forwarded to achieve the destination network. The fourth interface column tells the router which Nic is connected to the appropriate destination network. Technically, the interface column only tells the IP address assigned to the NIC by the router. The network adapter connects the router to the destination network. However, the router is very smart and knows which physical Nic the address is bound. The Fifth Column is measurement. Measurement itself is a science. The smaller the value, the higher the credibility. The following describes the content of each line: network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 255.116.69.106.119 1 This indicates that data sent to any Network segment is sent to a default Gateway through the Local Interface 116.69.106.119: 116.69.106.119. The management distance is 1, management Distance refers to the information credibility in the path selection process. The smaller the management distance, the higher the credibility. Line 2: Network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 192.168.2.226 192.168.2.79 20. This indicates that data sent to any Network segment is sent to the Gateway 192.168.2.226 through the Local Interface 192.168.2.79, however, because the Management Distance of the row (Metric) is greater than that of the first row, it indicates that the credibility of the second row is not as high as that of the first row, therefore, by default, the gateway of the first line is preferentially selected. Line 3: Network Destination Netmask Gateway Interface Metric 115.168.64.94 255.255.255.255.255 116.69.106.119 116.69.106.119 1 content of line 4: network Destination Netmask Gateway Interface Metric 116.69.106.119 255.255.255.255.255 127.0.0.1 127.0.0.1 50 indicates the packets sent from your host to your host. If you are using the IP address of your host, the effect is the same as using the loopback address, you can use the same route, that is, if you have your own site, you need to browse your site and enter localhost In the IE geological column, which is the same as 116.69.106.119, although localhost is resolved to 127.0.0.1. Contents of the fifth line: Network Destination Netmask Gateway Interface Metric 116.255.255.255 255.255.255.255 116.69.106.119 116.69.106.119 50 the Destination address here is a local broadcast address. The system processes such data packets by setting the local machine 116 .. 69.106.119 acts as the gateway and sends a local broadcast frame, which will be filtered by the router. Line 6: Network Destination Netmask Gateway Interface Metric 127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1 2.2 command used to delete route information: route delete network Destination Address [mask] [subnet mask] For example, to delete a route whose destination address is 192.168.2.0 and subnet mask is 255.255.255.0, available: you can use fuzzy match when deleting a route entry in route delete 192.168.2.0 mask route 255.0.0. For example, to delete all routes in the IP route table starting with 115, the following options are available: route delete 115*2.3 add route information use the following command: route add network Destination Address mask subnet mask gateway [metric] [measurement value]. For example, to add a subnet mask with 255.255.0.0, 10.27.0.1 gateway. To add a route entry to the destination address of 10.41.0.0 measured in 7, run the following command: route add 10.41.0.0 mask route 255.0.0 10.27.0.1 metric 73. the application instance uses the debugging environment as an example. You need to connect to the Intranet for debugging. The intranet address is 5.0.217.47. In addition, there is a wireless connection. You can automatically allocate 192.168.2.110 to the Internet. After you have successfully connected to the Internet, the Intranet is accessible, but the Internet cannot be connected. In the command window, run the ipconfig and route print commands to print the current information: route print ==================================================== ============================================================== Interface List0x1 MS TCP Loopback interface0x2 00 26 18 31 4f d1 Realtek RTL8168C (P) /8111C (P) PCI-E Gigabit Ethernet NIC-packet scheduler micro port 0x3 00 24 2c e7 57 11 Atheros AR5006X Wireless Network Adapter-package scheduler micro port ========== ========================================================== ================== ========================================================== ========================================================== ======= Active Routes: network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 255.255.10 0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.110 25 5.0.2255.255.255.255.192 255.255.10 255.255.255.255 127.0.0.1 127.0.0.1 10 255.255.255.255.255 255.255.10 127.0. 0.0 255.0.0.0 255.255.1 192.168.1.0 255.255.0 192.168.1.110 192.168.1.110 25 192.168.1.110 255.127.0.0.1 127.0.0.1 25 192.168.1.255 255.192.168.1.110 192.168.1.110 25 255.255.255.255.255.10 255.192.168.1.110 192.168.1.110 25 255.255.255.255.255.1 255.255.255.255.192.168. 1.110 192.168.1.110 1 Default Gateway: 192.168.1.1 ============================================== ========================================== Persistent Routes: none ipconfig Windows IP ConfigurationEthernet adapter local Connection: Connection-specific DNS Suffix.: IP Address ............: 5.0.217.47 Subnet Mask ...........: zookeeper lifecycle 192 Default Gateway .........: Ethernet adapter wireless network connection: Co Nnection-specific DNS Suffix.: IP Address ............: 192.168.1.110 Subnet Mask ...........: 255.255.255.0 Default Gateway .........: 192.168.1.1 can be seen in the first line of the result of the route print command, so the Internet is not accessible because the Intranet gateway of 5.0.217.1 is used by default. To meet the need to access the Intranet and Internet at the same time, you only need to delete the 0.0.0.0 route and add two routes to route the addresses starting with 5 through the gateway 5.0.217.1, all other addresses go out through the wireless gateway 192.168.1.110. See the following for details: route delete 0.0.0.0route add 0.0.0.0 mask 0.0.0.0 192.168.1.1route add 5.0.0.0 mask route 0.0.0 5.0.217.1 run the route print command. The running result is as follows: route print ==================================================== ============================================================== Interface List0x1 MS TCP Loopback interface0x2 00 26 18 31 4f d1 Realtek RTL8168C (P) /8111C (P) PCI-E Gigabit Ethernet NIC-packet scheduler micro port 0x3 00 24 2c e7 57 11 Atheros AR5006X Wireless Network Adapter-package scheduler micro port ========== ========================================================== ========================================================== ========================================================== ============================== Active Routes: network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.110 1 5.0.0.0 255.0.0.0 255.255.1 255.255.255.255.255.10 255.255.255.10 255.255.0.0.0 255.127.0.0.1 1 192.168.1.0 255.255.255.0 192.168.1.110 192.168.1.110 25 192.168.1.110 255.255.255.255 127.0.0.1 127.0.0.1 25 192.168.1.255 255.192.168.1.110 192.168.1.110 25 255.240.0.0.0 255.255.10 255.240.0.0 192.168.1.110 192.168.1.110 25 255.255.255.255.255.255.1 255.192.168.1.110 192.168.1.110 1 Default Gateway: 192.168.1.1 ============================================== ========================================== Persistent Routes: none. The default value is 192.168.1.110.

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.