Detailed explanation of the route add command

Source: Internet
Author: User
  1. Functions
    This command is used to display and modify entries in the local IP address routing table. Use a route without parameters to display help.
    2. Syntax explanation
    Route [-F] [-p] [Command [destination] [mask netmask] [gateway] [metric] [If inte *** ce]

This is similar to thinking about how Huawei devices add routing commands. We can think that Cisco and Huawei network devices are actually Linux.

Examples


Example 1: To display the complete content of the IP route table, run the following command:
Route print


Example 2: to display a route entry starting with 10 in the IP route table, run the following command:
Route print 10 .*


Example 3: to add a default route entry whose default gateway address is 192.168.12.1, run the following command:
Route add 0.0.0.0 mask 0.0.0.0 192.168.12.1


Example 4: to add a route entry whose destination is 10.41.0.0, whose subnet mask is 255.255.0.0, and whose next hop address is 10.27.0.1, run the following command:
Route add 10.41.0.0 mask 255.255.0.0 10.27.0.1


Example 5: to add a permanent route whose destination is 10.41.0.0, The subnet mask is 255.255.0.0, And the next hop address is 10.27.0.1, run the following command:
Route-P add 10.41.0.0 mask route 255.0.0 10.27.0.1


Example 6: to add a route entry with the target 10.41.0.0, subnet mask 255.0.0, Next Hop address 10.27.0.1, and number of hops 7, run the following command:

Route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 metric 7


Example 7: to add a route entry whose destination is 10.41.0.0, whose subnet mask is 255.255.0.0, whose next hop address is 10.27.0.1, and whose interface index is 0x3, run the following command:
Route add 10.41.0.0 mask route 0.0 10.27.0.1 if 0x3


Example 8: to delete a route whose destination is 10.41.0.0 and the subnet mask is 255.255.0.0, run the following command:
Route Delete 10.41.0.0 mask 255.255.0.0


Example 9: to delete all routes starting with 10 in the IP route table, run the following command:
Route Delete 10 .*


Example 10: to change the next hop address of the route whose destination is 10.41.0.0 and whose subnet mask is 255.255.0.0 from 10.27.0.1 to 10.27.0.25, run the following command:
Route change 10.41.0.0 mask 255.255.0.0 10.27.0.25


Example 11: Add a static route so that all the CIDR blocks destined for 172.0.0.0 are forwarded to the route whose network is 172.25.25.1.
Route add 172.0.0.0 mask 255.0.0.0 172.25.25.1 metric 2-P

Detailed explanation of the route add command

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.