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 to View the routing Table in Linux system

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

Share

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

This article will explain in detail how to view the routing table in the Linux system. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

Routing table introduction: in a computer network, the routing table (routing table) or routing domain information base (RIB, Routing Information Base) is a spreadsheet (file) or class database stored in a router or networked computer. The routing table stores a path to a specific network address (and in some cases, a routing metric for the path). The routing table contains topology information around the network. The main goal of establishing routing table is to realize routing protocol and static route selection.

Linux system View routing Table method: 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.

These are several commands to view routing table information in Ubuntu. Although the ip route command is not very neat in appearance, it is still the recommended way to find relevant routing table information. Although other commands are considered obsolete, they do sometimes help to export what needs to be extracted.

This is the end of the article on "how to view the routing table in the Linux system". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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