How to view detailed network routing table in Ubuntu

**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. The data packet sent from the computer reaches 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. When you want the system to communicate with other computers, you may need to configure these routing tables. First of all, it is very important to understand how to view these routing tables on a Linux system.

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

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 commands. You can open the terminal through the system Dash or Ctrl + Alt + T shortcut.

**How to view the routing table? **

Method 1: Via netstat command

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

Here is how to use this command:

$ netstat -rn

This is 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, it means that the specified network does not require a forwarding gateway.
Genmask This column indicates the netmask of the network.
The U output in this column of Flags indicates that the route has been activated. The G output indicates that the specified gateway should be used for this route. D stands for dynamic installation, M stands for modification, and R stands for recovery.
MSS This column indicates the default maximum segment size (MSS) of TCP connections for this route.
Window This column indicates the default window size of TCP connections on this route.
Irtt This column indicates the initial round-trip time of this route.
The IfaceIface column shows the network interface. If you have multiple interfaces, you will see lo (for loopback), eth0 (for the first Ethernet device) and eth1 (for the second Ethernet device), and so on the number of interfaces you have installed .

Method 2: Via route command

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

With this command, you can view the exact same information with the netstat command. Here is how to use it:

$ route -n

Core IP routing table

Target gateway subnet mask mark hop reference use interface

0.0.0.0 192.168.182.2 0.0.0.0 UG 20100 0 0 ens33

169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 ens33

172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0

192.168.182.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33

Method 3: Via 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 export what needs to be extracted.

to sum up

The above is the entire content of this article. I hope that the content of this article has a certain reference value for your study or work. If you have any questions, you can leave a message and exchange. Thank you for your support to ZaLou.Cn.

Recommended Posts

How to view detailed network routing table in Ubuntu
How to install Helm in Ubuntu
How to use hanlp in ubuntu
How to install mysql in Ubuntu 14.04
How to view errors in python
How to install mysql in Ubuntu 14.04
How to easily compile openJDK in Ubuntu
How to install cuda10.1 driver in Ubuntu
How to add users to Sudoers in Ubuntu
How to delete redundant kernels in Ubuntu
How to delete redundant kernels in Ubuntu
How to install ROS Noetic in Ubuntu20.04
How to set static IP in ubuntu14.04
How to modify software source in Ubuntu 7.10
How to view installed modules in python
How to open root account in Ubuntu20.04
How to hide applications in Ubuntu Dash?
How to modify time zone and time in ubuntu
How to configure TensorFlow use environment in Ubuntu
How to install python in ubuntu server environment
How to use dpkg command in Ubuntu system
How to open the ubuntu system in win10
How to configure /var/log/messages in Ubuntu system log
How to upgrade to Ubuntu 20.04
How to upgrade to Ubuntu 20.04
How to install Hadoop in standalone mode on Ubuntu 18.04
How to use Putty to log in to ubuntu installed in VirtualBox
How to modify time zone and time in ubuntu system
Example of how to modify ip address in Ubuntu20.04
How to create a Python virtual environment in Ubuntu 14.04
Many attempts to set up soft routing in ubuntu
How to upgrade to Ubuntu 16.04 LTS
How to control the ubuntu system in win10 through ssh
Detailed steps to automatically set the line number in ubuntu16.04
How to install memcache and start it in ubuntu environment
How to compile and install PHP and Nginx in Ubuntu environment
How to support TL-WDN7200H wireless USB network card in CentOS8?
How to map shared disk to window in linux under Ubuntu
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to upgrade CentOS7 to CentOS8 (detailed steps)
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to wrap in python code
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to compile ijkplayer-android under ubuntu
How to install Anaconda3 on Ubuntu 18.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
Detailed steps to install MySQL to change the default password in Ubuntu
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04