What are Routing and Routing Table in Linux? The process of routing means the transmission of IP packets from one point to another on the network. When you send someone an email, you are actually transmitting a series of IP packets, or datagrams, from your system to the other person's computer. Data packets sent from a computer pass through several gateways or routers to reach the destination computer system. The same approach applies to all internet protocols such as HTTP, IRC, FTP, etc. In all Linux and UNIX systems, information about how to forward IP packets is stored in kernel structures. These structures are called routing tables. You may need to configure these routing tables when you want your system to communicate with other computers. First, it is 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 by going through the following three commonly used commands:
We have run the commands and procedures mentioned in this article on an Ubuntu 18.04 LTS system. We use the Ubuntu command line, the Terminal, in order to run the above commands. You can open the Terminal through the system Dash or the Ctrl+Alt+T shortcut. How to view the routing table? Method 1: Using the netstat command The netstat command has been a widely used method to print routing table information in Linux. However, it was officially replaced by the ip route command. We need it regardless, as it is still a way to retrieve the information we need. Here’s 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 output:
Method 2: Using the route command The route command is also among the once widely used but now obsolete commands to view routing tables. The man page for this command also mentions that this command has now been replaced by the ip route command. This command lets you view the exact same information as you can with the netstat command. Here’s how to use it: $ route -n Kernel IP routing table Destination Gateway Subnet Mask Flags Metric 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 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 -n This flag is used to display numeric addresses only Method 3: Using the ip route command Last but not least, here is the best way to print routing table information in Linux. Here’s how to use this command: $ ip route While this information is not as reader-friendly as the previously mentioned commands, it is still enough for you to configure your router. Here are a few commands to view routing table information in Ubuntu. While the ip route command is not very neat in appearance, it is still the recommended way to find relevant routing table information. While the other commands are considered obsolete, they do sometimes help to export what needs to be extracted. Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM. You may also be interested in:
|
<<: Install and configure MySQL under Linux
>>: Problems with index and FROM_UNIXTIME in mysql
1. Download the mysql repo source $ wget http://r...
How to create a virtual machine on VMware and ins...
Problem explanation: When using the CSS animation...
Table of contents 1. Recipe Collection 1.1 Projec...
Preface This article will explain how Vue compone...
This article uses a specific example to introduce...
This article shares the specific code of js to ac...
1. When the width of the adjacent floating layer o...
Table of contents Preface Several common bit oper...
Several parts of Compose deal with environment va...
Preface: I used the official nginx proxy_cache as...
The layout problem of irregular picture walls enc...
In order to download this database, it takes a lo...
The DATE_ADD() function adds a specified time int...
Table of contents 8. CSS3 click button circular p...