Linux Commands-route: Show or manipulate routing tables

Source: Internet
Author: User

The route command looks at the routing table or manually adds, deletes, and modifies entries in the routing table.

Command format

Route [-cfvnnee] [-A family]

Route [-v] [-A family] add [-net|-host] target [netmask Nm] [GW GW] [metric N] [MSS M] [window W] [Irtt I] [reject] [mod] [Dyn] [Reinstate] [[Dev] If]

Route [-v] [-A family] del [-net|-host] target [GW GW] [netmask Nm] [metric N] [[Dev] If]

Route [-v] [--version] [-h] [--help]

Command parameters

-A family
Use the specified address family, such as inet.

-F
The FIB (Forwarding information Base) routing table that operates the kernel, which is the default option.

-C
The route cache of the operating kernel.

-V
Show more detailed information about the operation

-N
Replaces the host name with a numeric address when displaying information.

-E
Displays routing table information using the Netstat (8) format. The-ee option displays all parameter information for the routing table.

Del
Delete a route entry

Add
Add a new route entry

Target
Specifies the destination network or host. You can use either a decimal IP address or a host/network name.

-net
The routing target is a network

-host
The routing target is a host

Netmask NM
When you add a network route entry, you need to specify a network mask.

GW GW
Specifies the gateway for any groupings destined for the destination network/host. Note: The specified gateway must first be accessible. This means that a static route must be pre-specified for the gateway. If you specify this gateway address for one of the local interfaces, then this gateway address will be used to determine how the groupings on this interface will be routed. This is the BSD style compatible.

Metric M
Set the Metric field value in the routing table to M.

MSS M
Set the MTU of the route (Maximum transmission Unit) to M bytes.

Window W
Sets the TCP window length of the connection on top of this route to W bytes.

Irtt I
Set the initial round-trip time for TCP connections on top of this route to I milliseconds (1-12000).

MoD, Dyn, reinstate
Installs a dynamic or changed routing entry. These tokens are usually set only by the routing daemon for diagnostic purposes.

Dev If
Forces the route to be associated with the specified device, or the kernel attempts to detect the appropriate device.

Instance

A) Display routing table information

Route Kernel IP Routing tabledestination     Gateway         genmask         Flags Metric Ref use    Iface10.6.0.0        *               255.255.255.0   u     0      0        0 eth1192.168.1.0     *               255.255.255.0   u     0      0        0 eth0169.254.0.0     *               255.255.0.0     U     0      0        0 eth1default         10.6.0.2        0.0.0.0         UG    0      0        0 eth1

b) Add a new route entry

Route add-net 192.56.76.0 netmask 255.255.255.0 Dev eth0

c) Delete a route entry

Route del 192.56.76.0

The meaning of the Routing table field information

The field meaning of the routing table is shown in the following table:

Field Describe
Destination Target network or destination host.
Gateway The gateway address, if not, displays *.
Genmask The mask for the destination address. ' 255.255.255.255 ' is used for the target host, ' 0.0.0.0 ' is used for the default route.
Flags Identity.
Metric The number of hops from the target.
Ref Number of routing entry references (not used in the Linux kernel).
Use The number of times the route entry was looked up.
Iface The network interface name.
Mss The default maximum message length based on the TCP connection above this route.
Window The default window size for TCP connections on top of this route.
Irtt The initial round-trip time based on the TCP connection above this route.

Where the value of Flag is indicated in the following table:

Flag Description
U Route is up
H Target is a host
G Use Gateway
R Reinstate route for dynamic routing
D Dynamically installed by daemon or redirect
M Modified from routing daemon or redirect
A Installed by addrconf
C Cache entry
! Reject Route
 

Linux Commands-route: Show or manipulate routing tables

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.