What is Routing of Network Packages?

The process of network package routing is the transmission of an IP packet from one point to another over the network, e.g the internet. When you send an email to someone, you are actually transferring a series of IP packets or datagrams from your computer to the other network node or PC. The packets sent from your computer pass through several gateways or routers to reach the target computer system. The same approach applies to all Internet protocols such as HTTP, IRC, FTP, etc.

In all Linux and UNIX systems, the information about the forwarding of IP packets is stored in a kernel structure. These structures are called routing tables. If you want your system to communicate with other computers, you should configure these routing tables. But first, it is important how you can display these routing tables on your Linux system.

Commands covered in this article

In this article, we will explain how the routing table can be displayed in Debian using the following three popular commands

  • The ip command
  • The route command
  • The netstat route command

We have tested the commands from this article on a Debian 10 Buster system.

We use the Debian command line, the terminal, to execute the above commands. You can open the terminal using the application startup search as follows:

Debian Terminal

The Application Launcher can be launched through the Super/Windows key on your keyboard.

How to use the ip command to view network routes

Last but not least, here is the most recommended way of printing routing table information in Linux. Hets is how to use this command:

$ ip route

The ip route command

Though this information is not much reader-friendly as that of the previously mentioned commands, it is still enough for you to configure the route.

These were a few commands to view the routing table information on Debian. Though the ip route command in not neat looking, it is still the most recommended way of looking up for relevant routing table information. The other commands are considered obsolete but they may still be helpful in deriving what you need to extract.

View routing table using the route command

The route command also falls under the category of once widely used but now obsolete command to view routing tables. The manual page of this command also mentions that the command is now replaced by the ip route command.

Through this command, you can view exactly the same information that you could, through the netstat command. Here is how you can use it:

$ sudo route -n

-n This flag is used to display the numerical addresses only

route command

The output format is somewhat similar to that of the netstat command.

Use netstat command to view the routing table

The netstat command has always been a widely used method of printing routing table information in Linux. However, it is officially replaced by the ip route command. We are including it anyway as it is still an approach to retrieve the required information

Here is how you can use this command:

$ netstat -rn

-r This flag is used to display the Kernel routing tables

-n This flag is used to display the numerical addresses

Netstat command

This is what the output indicates:

Destination This column indicates the destination network
Gateway This column indicates the defined gateway for the network. If you see an * in this column, it means that no forwarding gateway is needed for the specified network.
Genmask This column indicates the netmask of the network.
Flags The U output in this columns means that the route is up. The G output indicates that specified gateway should be used for this route. D stands for dynamically installed, M stands for modified, and R means reinstated.
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 over this route.
irtt This column indicates the Initial Round Trip Time for this route.
Iface The Iface column shows the network interface. If you had more than one interface, you would see lo (for loopback), eth0 (first Ethernet device), and eth1 (for the second Ethernet device), and so on for the number of interfaces you have installed.


How to View the Network Routing Table in Debian 10

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn