How to View the Routing Table Using the route Command in Linux

When an Ubuntu Linux server attempts to send data across a network—whether it is responding to a web request or pinging an external database—it does not simply push the data out randomly. The operating system consults a highly structured map called the routing table to determine the most efficient path (or gateway) for the data packets to travel to reach their final destination.

If your server is experiencing bizarre connectivity issues—such as being able to reach the public internet but failing to communicate with a database server on the same local subnet—inspecting the routing table is an essential diagnostic step.

How to View the Routing Table

The traditional method for viewing the kernel’s IP routing table involves using the classic route command, which has been bundled with the net-tools package for decades.

  1. Open your terminal or SSH into your Linux server.
  2. Type the following command and press Enter:
route -n

Why use the ‘-n’ flag?
The -n flag stands for “numeric.” By default, the route command attempts to perform a reverse DNS lookup to translate every IP address in the table into a human-readable hostname. If your DNS server is misconfigured (which is highly likely during a networking outage), the command will freeze and hang for several minutes while it waits for the DNS request to time out. Using -n forces it to immediately print the raw numerical IP addresses.

Understanding the Output

The command will print a formatted table with several columns. Here is how to interpret the critical information:

  • Destination: This is the target network. An IP address of 0.0.0.0 represents the “default route” (meaning any internet traffic that does not have a specific local destination rule will be sent here).
  • Gateway: This is the specific IP address of the router that the traffic must pass through to reach the Destination. If the Gateway is listed as 0.0.0.0, it means the destination is on the exact same local network switch, and no routing is required.
  • Genmask: The subnet mask defining the size of the destination network (e.g., 255.255.255.0).
  • Flags: You will usually see a U (indicating the route is “Up” and active) and a G (indicating the route utilizes a “Gateway”).
  • Metric: A priority score. If the server has two different paths to reach the same destination, it will always choose the route with the lowest metric number.
  • Iface: The physical network interface card (e.g., eth0, ens33, or wlan0) that will transmit the data.

The Modern Alternative: ‘ip route’

While the route command is iconic, the net-tools package has technically been deprecated on modern Linux distributions in favor of the newer iproute2 suite.

If you type route and the terminal returns a “Command not found” error, you should use the modern equivalent instead:

ip route show

This command outputs the exact same logical routing data, but presents it in a slightly different, more condensed layout (e.g., default via 192.168.1.1 dev eth0 proto dhcp metric 100).

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.