In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "the usage of Linux basic command route". In daily operation, I believe many people have doubts about the usage of Linux basic command route. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "the usage of Linux basic command route"! Next, please follow the editor to study!
Route
The route directive is used to display or modify the IP routing table. Its main purpose is to set a static route to a specific host or network through the interface after configuring the interface using the ifconfig (8) program. When the add or del option is used, the route modifies the routing table. Without these options, the route displays the current contents of the routing table.
The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.
1. Grammar
Route [- CFvnee]
Route [- v] [- A family] add [- net |-host] target [netmask Nm] [gw Gw] [metric N] [mssM] [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]
2. List of options
Option
Description
-- help
Show help documentation
-- version
Show command version
-A family
Specify the type of address to use
-F
Manipulate kernel FIB
-C
Manage kernel routing cache
-v
Show detailed procedures
-n
Display the hosts in the routing table digitally
-e
Display the routing table using the output format of netstat
-net
Specify a network route
-host
Specify a host route
Add
Add a route
Del
Delete a route
Target
Specify the destination network or host
Netmask mask
Use this subnet mask when adding a route
Gw ip
Specify the IP address of the gateway through which the packet passes
Metric
Specify the metric field of the routing table
Window
Specify the TCP connection serial port of the routing table
Irtt I
Set the initial round-trip time (Irtt) for TCP connections on this route to I milliseconds (1-12000). This is usually only used on AX.25 networks. If omitted, the default ms of rfc 1122 is used.
Reject
Install blocked routes, which will force route lookups to fail. For example, this is used to mask the network before using the default route. It's not for fire prevention.
Mod, dyn, reinstate
Install dynamic or modified routes. These flags are used for diagnostics and are usually set only by the routing daemon.
Dev eth
Specify the network interface of the route
3. Output
The output of the kernel routing table is organized in the following columns
Output column
Description
Destination
Target network or target host.
Gateway
Gateway address or "*" (if not set)
Genmask
The network mask of the destination network; the host destination is' 255.255.255.255' and the default route is' 0.0.0.0'.
Flags
It is possible that flag has
U, the route is up.
H, the target is a host
G, use the gateway
R, restore routing for dynamic routin
D, dynamically installed or redirected by the daemon
M, modified from the routing daemon or redirection
A, installed by addrconf
C, cache item
! deny the route
Metric
The distance from the target (usually in terms of hops). It is not used by the recent kernel, but is required by routing daemons.
Ref
The number of times this route is referenced. (not used in the Linux kernel.)
Use
Find the number of routes. Depending on the usage of-F and-C, this will be a route cache loss (- F) or hit (- C).
Iface
Packets used for this route will be sent to the interface.
MSS
Default maximum segment size for TCP connections on this route
Window
Default window size for TCP connections on this route
Irtt
Initial RTT (round trip time). The kernel uses it to guess the best TCP protocol parameters without waiting for (possibly slow) answers.
HH
The number of ARP entries and cache routes cached by hardware headers that reference cache routes. -1 if the interface that caches the route does not require a hardware address (for example, lo).
Arp
Whether the hardware address of the cache route is up to date.
4. Example code
Route add-net 127.0.0.0
Add a normal loopback entry, using the net mask 255.0.0.0 (level A Net, determined from the destination address) and associated with the "lo" device (assuming the device is set correctly with ifconfig (8)).
10.x.x.x. Add routes to network 192.56.76.x via "eth0". There is no need to use a Class C netmask modifier here because 192. * is a Class C IP address. The word "dev" can be omitted here.
Route add default gw mango-gw
Add a default route (if no other routes match, use that route). All packets using this path will be sent via "Mango-GW". The actual equipment used for this route depends on how we get to "mango-gw", and the static path to "mango-gw" must be set before that.
Route add ipx4 sl0
Routes are added to the "IPX 4" host through the SIP interface (assuming that "IPX 4" is the SILIP host).
Route add-net 192.57.66.0 netmask 255.255.255.0 gw ipx4
This command adds the network "192.57.66.x", which is passed to the SILIP interface through the previous route.
Route add-net 224.0.0.0 netmask 240.0.0.0 dev eth0
. This sets all Class D (multicast) IP routes to pass through "eth0". This is the correct normal configuration line with a multicast kernel.
Route add-net 10.0.0.0 netmask 255.0.0.0 reject
This is the private network "10.x.x.x." A deny route is installed.
5. Examples
1) display the local routing table
[root@localhost ~] # route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
255.255.255.255-255.255.255.255! h 0-0-
224.0.0.0-255.255.255.0! 0-0-
2) display in netstat format
[root@localhost] # route-e
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
255.255.255.255-255.255.255.255! h-
224.0.0.0-255.255.255.0!-
3) add a route
[root@localhost ~] # route add-net 111.13.0 24 dev eth0 / / the specified network segment is accessed using device eth0
[root@localhost ~] # route / / View the routing table
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
255.255.255.255-255.255.255.255! h 0-0-
111.13.0.0 * 255.255.255.0 U 000 eth0
224.0.0.0-255.255.255.0! 0-0-
172.16.0.0 * 255.255.0.0 U 000 eth0
4) Delete a route
[root@localhost ~] # route del-net 111.13.0.0 24 / / Delete the specified address id route
[root@localhost ~] # route / / View routes
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
255.255.255.255-255.255.255.255! h 0-0-
224.0.0.0-255.255.255.0! 0-0-
172.16.0.0 * 255.255.0.0 U 000 eth0
At this point, the study of "the usage of the Linux basic command route" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.