How to Read a Routing Table: route print and ip route Explained
Learn to read a routing table: columns, metric, and how to spot the entry sending traffic the wrong way. Covers route print and ip route.
When a machine sends a packet to an IP address, the routing table decides which interface the packet leaves from and which router (if any) receives it next. If that decision is wrong, traffic goes to the wrong network or disappears entirely. This page explains every column of route print (Windows) and ip route (Linux/macOS), what the metric actually does, and how to identify the entry that is sending traffic the wrong way.
The Routing Table at a Glance
A routing table is a list of known networks. Each entry tells the machine: “To reach this destination network, use this interface and this gateway (or none if directly connected).” When a packet needs to be sent, the machine looks for the most specific matching route — the one with the longest prefix length — and uses that entry. If multiple entries have the same prefix length, the metric breaks the tie.
Here is a sample route print output from a Windows machine:
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.10 25
127.0.0.0 255.0.0.0 On-link 127.0.0.1 331
127.0.0.1 255.255.255.255 On-link 127.0.0.1 331
192.168.1.0 255.255.255.0 On-link 192.168.1.10 281
192.168.1.10 255.255.255.255 On-link 192.168.1.10 281
192.168.1.255 255.255.255.255 On-link 192.168.1.10 281
===========================================================================
Persistent Routes:
None
And a sample ip route output from Linux:
$ ip route
default via 192.168.1.1 dev eth0 proto dhcp metric 100
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.10 metric 100
Both tables contain the same information, just formatted differently. The rest of this page maps each column.
Columns of route print
Network Destination and Netmask
Network Destination is the network address, and Netmask defines how many bits of that address must match for the route to apply. Together they form the prefix. For example, 192.168.1.0 with netmask 255.255.255.0 is the network 192.168.1.0/24. A packet destined for 192.168.1.50 matches this route because the first 24 bits of the destination match the first 24 bits of the network address.
The default route is 0.0.0.0 with netmask 0.0.0.0, which matches every destination. It is the route of last resort — used when no more specific route exists.
Gateway
Gateway is the next-hop IP address. If the destination is on a directly connected network, the gateway is On-link, meaning the machine can reach the destination without sending the packet to a router. If the gateway is an IP address, that address must be reachable through one of the machine’s interfaces — it cannot be on a network that the machine does not have a route to.
Interface
Interface is the local IP address of the network interface that the packet will leave from. For a directly connected route, this is the machine’s own IP on that network. For a route via a gateway, it is the IP of the interface that connects to the gateway’s network.
Metric
Metric is a cost associated with the route. When two routes have the same prefix length, the one with the lower metric is chosen. The metric is not a measure of speed; it is an administrative preference. Windows calculates a default metric for each interface based on link speed (faster links get lower metrics), but it can be overridden manually. Linux uses a similar concept, but the metric is often set by the routing protocol or manually.
Columns of ip route
Linux’s ip route output is more compact. Each route is shown as a prefix, followed by attributes. The key parts are:
default— shorthand for0.0.0.0/0.via— the gateway IP. If absent, the route is directly connected.dev— the interface name (e.g.,eth0).proto— the protocol that added the route (e.g.,kernelfor automatically added,dhcpfor DHCP-assigned,staticfor manually added).metric— the cost, same as Windows.scope— usuallylinkfor directly connected routes, meaning the destination is on the same link.
How the Metric Really Decides
The metric only matters when two routes have the same prefix length. For example, if a machine has two interfaces, both connected to different networks, and both have a default route (0.0.0.0/0), the metric decides which one is used for all traffic that does not match a more specific route. The route with the lower metric wins.
A common misconception is that the metric is used to choose between a specific route and a default route. It is not. The longest prefix match always wins, regardless of metric. For instance, a route to 192.168.2.0/24 will always be used for traffic to 192.168.2.10, even if the default route has a much lower metric.
Spotting the Wrong Route
When traffic goes the wrong way, the culprit is usually a route that is more specific than it should be, or a default route pointing to the wrong gateway. To diagnose, follow these steps:
- Identify the destination IP address that is failing.
- Look for the route with the longest prefix that matches that IP.
- Check if that route’s gateway and interface are correct.
- If the route is wrong, you can either delete it or add a more specific route to override it.
For example, if a machine has a route to 0.0.0.0/0 via 192.168.1.1, but also a route to 192.168.1.0/24 via 192.168.1.1, traffic to 192.168.1.100 will use the specific route (since it is directly connected) and will not go through the gateway. That is correct. But if there is a route to 192.168.1.0/24 via 192.168.2.1 (a wrong gateway), traffic to 192.168.1.100 will be sent to that gateway, which may drop it.
Comparison: When Each Route Type Applies
| Route Type | Example | When It Applies | When It Does NOT Apply |
|---|---|---|---|
| Default route | 0.0.0.0/0 | When no more specific route matches | When a more specific route exists (e.g., a directly connected network) |
| Directly connected | 192.168.1.0/24 | When the destination is on the same subnet as an interface | When the destination is on a different subnet, unless a more specific route exists |
| Static route via gateway | 10.0.0.0/8 via 192.168.1.1 | When the destination is in the specified range and the gateway is reachable | When the destination is outside the range, or when a longer prefix route exists |
| Host route | 192.168.1.10/32 | When the destination is exactly that IP | When the destination is any other IP |
What People Get Wrong About This
A natural mistake is to think that the metric is the primary factor in route selection. It is not. The longest prefix match is always evaluated first. Many people see two routes to the same network with different metrics and assume the lower metric will always be used, but if one route has a longer prefix (e.g., /24 vs /16), the longer prefix wins regardless of metric. This confusion is understandable because the metric is the only visible difference between two otherwise identical routes, and it is what is commonly adjusted to influence routing.
Another common error is misreading the Gateway column. When the gateway is On-link, the destination is directly reachable — the packet is sent out the interface without going through a router. Some people mistake On-link for a gateway IP and try to ping it, which fails because it is not an address. Understanding that On-link means “no gateway” is essential.
Finally, people often overlook the Interface column. If the interface is wrong, the packet may be sent out a network that cannot reach the gateway. For example, a route might say Gateway 192.168.1.1, Interface 192.168.2.10, which is invalid because the gateway is not on the same network as the interface. This can happen after a configuration change and will cause traffic to fail.
Viewing and Modifying Routes
To view the routing table on Windows, use route print. On Linux or macOS, use ip route (or route -n for a simpler output). To add a route on Windows, use route add with the -p flag to make it persistent. On Linux, use ip route add. To delete a route, use route delete (Windows) or ip route del (Linux).
These commands are for reference; the exact syntax is available in the built-in help (route /? or man ip-route).
Understanding the routing table is a matter of reading the columns correctly and remembering that the longest prefix match is king. Once that is clear, most routing problems become a matter of finding the offending entry and correcting it.
Common questions
What does the metric in a routing table mean?
The metric is a cost value used to choose between routes with the same prefix length. Lower metrics are preferred. It does not affect routes with different prefix lengths; the longest prefix match always wins.
Why is my traffic going to the wrong gateway?
There is likely a more specific route that points to the wrong gateway. Check the routing table for a route that matches your destination IP with a longer prefix than the default route, and verify its gateway and interface.
How do I see the routing table on Windows?
Open a command prompt and type `route print`. This shows all IPv4 and IPv6 routes. Look for the 'Active Routes' section for the current routes.
What is the difference between 'On-link' and a gateway IP?
'On-link' means the destination is directly connected to the interface, so no gateway is used. A gateway IP is the next-hop router that the packet is sent to for routes that are not directly connected.
How do I add a static route on Linux?
Use `ip route add <network>/<prefix> via <gateway> dev <interface>`. For example, `ip route add 10.0.0.0/8 via 192.168.1.1 dev eth0`. To make it persistent, add the command to a network configuration file or use a tool like `nmcli`.
Read next
- ARP and MAC Addresses: Finding the Hardware How a host finds the MAC behind an IP, why ARP never leaves the local network, and how a stale cache entry produces a confusing partial outage.
- How DHCP Works: DORA, Leases, and Failure Modes Understand DHCP: the DORA exchange, lease lifecycle, renewal timing, and failure modes like exhausted scopes and conflicting servers.
- DNS Zones Explained: Zone vs Domain, Delegation, SOA Understand DNS zones: what a zone is, how it differs from a domain, delegation, SOA records, zone transfers, and forward/reverse zones.
- chkdsk, SFC and DISM: Which One to Run and When Three repair tools with three different jobs. Why DISM comes before SFC, what chkdsk actually checks, and when chkdsk can finish off a failing drive.
- Fix 'A required CD/DVD drive device driver is missing' During USB Install When Windows setup says a CD/DVD driver is missing but you're installing from USB, the real cause is usually USB port or media. Learn how to fix it.