When you are managing a Linux server, especially one acting as a router or connected to multiple different subnets via multiple network interfaces, troubleshooting connectivity requires deep insight. You must understand exactly how the operating system decides where to send network packets. This logical decision-making process is governed entirely by the internal IP routing table. The routing table is essentially a map that tells the Linux kernel which gateway (or router) should be used to reach a specific destination IP address.
How to View the Routing Table
To inspect this internal map, you use the classic route command in the terminal. However, running the command by itself can cause frustrating delays. By default, the route command attempts to perform a reverse DNS lookup on every single IP address in the table to display human-readable hostnames. If the DNS server is slow or unreachable, the command will hang and freeze the terminal for several seconds.
To view the table instantly and reliably, you must bypass the DNS lookup by using the numeric flag.
- Open your Linux terminal.
- Type the following command:
route -n
- Press Enter.
Understanding the Output
The terminal will instantly output a formatted table containing pure numerical IP addresses. The table contains several critical columns:
- Destination: The target network (e.g.,
192.168.1.0). A destination of0.0.0.0represents the “default route” (the path to the global internet). - Gateway: The IP address of the router that will handle traffic bound for the destination. If this says
0.0.0.0, it means the destination is on the local network, and no router is required. - Genmask: The subnet mask defining the size of the destination network (e.g.,
255.255.255.0). - Iface (Interface): The physical or virtual network card (e.g.,
eth0orwlan0) that the packet will physically leave from.
By reading this table top-to-bottom, you can pinpoint exactly why traffic to a specific subnet is failing or being routed out the wrong network card.