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 network routing table in Ubuntu

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

Share

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

Today, the editor will share with you the relevant knowledge about how to view the network routing table in Ubuntu. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

The main function of the routing table is for the router to find the target network, then determine the forwarding interface and the next-hop route, and complete the packet forwarding function.

The way to view the routing table: 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.

These are all the contents of the article "how to View the Network routing Table in Ubuntu". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

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