Detailed instructions for using the Route command in the Linux operating system

  

Using the routing method, use the route command.

-- The correct usage of the Route command

Use the Route command line tool to view and edit the computer's IP routing table. The Route command and syntax are as follows:

route [-f] [-p] [Command [Destination] [mask Netmask] [Gateway] [metric Metric]] [if Interface]]

-f Clears the routing table for all gateway entries.

-p Makes the route permanent when used with the add command.

Command Specify the command you want to run (Add/Change/Delete/Print).

Destination Specifies the network destination for this route.

mask Netmask Specifies the network mask (also known as the subnet mask) associated with the network target.

Gateway Specifies the forward or next hop IP address that the address set and subnet mask defined by the network target can reach.

metric Metric Specifies an integer cost value for the route (from 1 to 9999) that can be used when selecting among multiple routes in the routing table that best matches the forwarded packet destination address.

if Interface Specifies the 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.

/? Displays help at the command prompt.

Example

To display the entire contents of the IP routing table, type:

route print

To display the IP starting with 10. For routing in the routing table, 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 to the 10.41.0.0 target with a 255.255.0.0 subnet mask and a 10.27.0.1 next hop address, please Type:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1

To 10.41 with a subnet mask of 255.255.0.0 and a next hop address of 10.27.0.1. To add a permanent route to the target, type:

route -p add 10.41.0.0 mask 255.255.0.0 10.27.0.1

To subnet mask with 255.255.0.0, 10.27.0.1 To add a route to the 10.41.0.0 target with a next-hop address and a cost value of 7, type:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 metric 7

To subnet mask with 255.255.0.0, 10. 27.0.1 To add a route to the 10.41.0.0 target with the next hop address and index 0x3, type:

route add 10.41.0.0 mask 255.255.0.0 10.27.0.1 if 0x3

To delete a route to the 10.41.0.0 target with a subnet mask of 255.255.0.0, type:

route delete 10.41.0.0 mask 255.255.0.0

To delete To all routes in the starting IP routing table, type:

route delete 10.*

To mask the subnet with 10.41.0.0 and 255.255.0.0 The next hop address of the code is changed 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

Copyright © Windows knowledge All Rights Reserved