The syntax for the route command is:
Route [-cfvnee]
Route [-v] [-A family] add [-net|-host] target [netmask Nm] [GW GW] [metric N] [mod] [reinstate] [[Dev] If]
Route [-v] [-A family] del [-net|-host] target [GW GW] [netmask Nm] [METRICN] [[Dev] If]
Route [-v] [--version] [-h] [--help]
The common parameters of route are as follows:
-V uses redundant output modes.
-A family specifies a particular address family (for example, "inet" Inet6″).
-N uses numbers to display addresses such as 202.38.75.75 instead of interpreting domain names.
-e uses the same output format as netstat.
The-ee parameter produces a very long output, including almost all information about the kernel routing table.
-net Target is a network segment.
-host Destination (target) is a separate host.
-F Display kernel FIB routing table results may be changed by the-E and-ee parameters.
-C Displays the kernel's middle-cached information.
Del Deletes a routing table entry.
Add adds a routing table entry.
Destination network segment or host for target configuration. Can be an IP, or a network or host name.
Netmask Nm is used to indicate the netmask of the routing table entry to be added.
GW GW Any IP packet to destination (target) is passed through this gateway.
Metric m sets the scale field (metric field) of the item in the routing table to M.
Example:
1 To add a routing table entry, 192.168.0.x should be from the interface "Eth0″ go
Route add-net 192.168.0.0 netmask 255.255.255.0 Dev eth0
2) Add a default route
Route add 0.0.0.0 GW gateway address
This routing rule is used if there are no more matching routing items.
3) Delete default route
Route del 0.0.0.0 GW Gateway address
4 The output of the route command shows an example
The output is formatted with the following columns:
Destination target network segment or host
Gateway address, if not set, is "*" means
Genmask Network Mask
Flags some possible markings are as follows:
U (routing is active)
H (target is a host)
G (use Gateway)
R (reinstate route the table entry produced by dynamic routing)
D (dynamically installed by daemon or redirect)
M (modified from routing daemon or redirect)
! (Reject route)
Metric routing distance.
Ref route item reference number. (not used in Linux kernel)
The number of times the use is found for a route item.
Iface the output interface corresponding to the routing table entry.