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 check the routing table under Ubuntu

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

Share

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

Most people don't quite understand the knowledge of this article "how to View routing Table under Ubuntu", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can gain something after reading this article. Let's take a look at this "how to View routing Table under Ubuntu" article.

What are routes and routing tables in Linux?

The process of routing means that IP packets are transmitted from one point to another on the network. When you send an email to someone, you are actually transmitting a series of IP packets or datagrams from your system to another person's computer. Packets sent from the computer reach the target computer system through several gateways or routers. The same method applies to all internet protocols, such as HTTP, IRC, and FTP.

In all Linux and UNIX systems, information about how to forward IP packets is stored in the kernel structure. These structures are called routing tables. You may need to configure these routing tables when you want the system to communicate with other computers. First, it is important to understand how to view these routing tables on Linux systems.

In this article, we will explain how to view the routing table in Ubuntu through the following three common commands:

Netstat command

Route command

Ip route command

We ran the commands and procedures mentioned in this article on the Ubuntu 18.04 LTS system. We use the Ubuntu command line terminal to run the above command. You can open the terminal through the system Dash or Ctrl + Alt + T shortcut.

How do I 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 method to view the network routing table in Ubuntu how to view the network routing table in Ubuntu

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

The method of viewing the Network routing Table in Ubuntu the method of viewing the Network routing Table in Ubuntu

-n this flag is used to display numeric addresses

The method of viewing Network routing Table in Ubuntu the method of viewing Network routing Table in Ubuntu

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 how to view the network routing table in Ubuntu the method of viewing the network routing table in Ubuntu

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 the method of viewing the network routing table in Ubuntu the method of viewing the network routing table in Ubuntu

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.

The above is the content of this article on "how to check the routing table under Ubuntu". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to learn more about the relevant knowledge, please follow 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