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
Table of contents Build Vuex environment Summariz...
Table of contents Preface 1. Basic knowledge of d...
For containers, the simplest health check is the ...
First, let's introduce several common operati...
Preface Recently, due to work reasons, I was work...
Table of contents Overview (Loop Mode - Common) D...
In order to facilitate the storage and access of ...
Table of contents background 1. The query conditi...
1. Download the ElasticSearch 6.4.1 installation ...
On Linux, bash is adopted as the standard, which ...
Table of contents Preface 1. Configure gzip compr...
Specific method: 1. Press [ win+r ] to open the r...
1. As mentioned above I saw this macro when I was...
dig - DNS lookup utility When a domain name acces...
The default ssh port number of Linux servers is g...