Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Linux view the routing table

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to view the routing table in Linux". In the daily operation, I believe many people have doubts about how to view the routing table in Linux. The editor has consulted all kinds of information and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to view routing tables in Linux". Next, please follow the editor to study!

A routing table is a spreadsheet (file) or class database stored in a router or networked computer. The main goal is to implement routing protocols and static routing.

Method 1: through the netstat command

The netstat command has always been a widely used method of printing routing table information in Linux. However, it was officially replaced by the ip route command. In any case, we need it because it is still a way to retrieve the information we need.

Here is how to use this command:

$netstat-rn

-r this flag is used to display the kernel routing table

-n this flag is used to display numeric addresses

This is the result of the output:

Destination this column indicates the destination network. Gateway this column indicates the defined gateway of the network. If you see * in this column, the specified network does not require a forwarding gateway. Genmask this column indicates the network mask of the network. Flags the U output in this column indicates that the route has been started. The G output indicates that the specified gateway should be used for this route. D stands for dynamic installation, M for modification, and R for recovery. MSS this column indicates the default maximum segment size (MSS) for TCP connections for this route. Window this column indicates the default window size for TCP connections on this route. Irtt this column indicates the initial round trip time for this route. The Iface Iface column shows the network interface. If you have multiple interfaces, you will see lo (for loopback), eth0 (the first Ethernet device) and eth2 (for the second Ethernet device), and so on the number of interfaces you have installed.

Method 2: through the route command

The route command is also a widely used but now obsolete command to view the routing table. The man page of this command also mentions that the command has now been replaced by the ip route command.

With this command, you can view exactly the same information through the netstat command. Here's how to use it:

$route-n

Kernel IP routing table destination gateway subnet mask flag hop reference using interface 0.0.0.0 192.168.182.2 0.0.0.0 UG 20100 00 ens33 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 00 ens33 172.17.0.0 0.0.0.0 255.255.0.0 U 000 docker0 192.168.182.0 0.0 . 0.0 255.255.255.0 U 100 00 ens33

-n this flag is only used to display numeric addresses

Method 3: through the ip route command

Last but not least, this is the best way to print routing table information in Linux. Here is how to use this command:

$ip route

Although this information is not as reader-friendly as the previously mentioned commands, it is still sufficient for you to configure the router.

At this point, the study on "how to view the routing table by Linux" 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report