What a Routing Table Is and Why It Matters
Every packet your computer sends must be directed somewhere — either to a device on your local network or out through a gateway to the wider internet. The kernel makes this decision by consulting the routing table: an ordered list of rules that map destination IP ranges to specific gateways and network interfaces. The route command lets you read and modify this table directly.
Understanding your routing table is essential for diagnosing connectivity failures, configuring VPN split tunneling, directing traffic over a specific interface on a multi-homed server, and verifying that static routes are in place after a network change.
Viewing the Routing Table
On Windows, use route print:
route print
Windows displays three sections: the Interface List (numbered adapters with their MAC addresses), the IPv4 Route Table, and the IPv6 Route Table. A typical IPv4 table looks like this:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.1.1 192.168.1.50 25
127.0.0.0 255.0.0.0 On-link 127.0.0.1 331
192.168.1.0 255.255.255.0 On-link 192.168.1.50 281
192.168.1.255 255.255.255.255 On-link 192.168.1.50 281
On Linux and macOS, use route -n. The -n flag suppresses hostname resolution, which makes the output appear faster and avoids misleading results when DNS is not working:
route -n
Output on Linux:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
Reading the Routing Table
Each row in the routing table describes one rule. The kernel evaluates rules from most specific (longest matching prefix) to least specific, and applies the first match. Key columns:
- Destination / Network Destination: The target network or host this route applies to.
- Gateway / Genmask: The next-hop IP to forward packets to. "On-link" (Windows) or 0.0.0.0 (Linux) means the destination is directly reachable on the attached network.
- Flags: U = route is Up; G = route uses a Gateway (traffic leaves the local subnet); H = Host route (single IP, not a network).
- Metric: The cost of the route. When two routes match the same destination, the one with the lower metric wins.
- Interface / Iface: The network interface used to send packets matching this route.
The Default Route
The most important entry in any routing table is the default route — destination 0.0.0.0/0 on Windows or "default" on Linux. It matches every destination that no other, more specific route covers. The gateway in the default route is your router. Without a default route, your machine can reach devices on directly connected subnets but cannot communicate with the internet or any other remote network.
Adding and Deleting Static Routes
To add a route on Windows:
route add 10.10.0.0 mask 255.255.0.0 192.168.1.254
Add -p to make it persistent across reboots:
route add -p 10.10.0.0 mask 255.255.0.0 192.168.1.254
To delete a route on Windows:
route delete 10.10.0.0
On Linux (using the legacy route command):
route add -net 10.10.0.0/16 gw 192.168.1.254
route del -net 10.10.0.0/16
On modern Linux, prefer the ip route equivalents:
ip route add 10.10.0.0/16 via 192.168.1.254
ip route del 10.10.0.0/16
route vs ip route
| Feature | route (legacy) | ip route (modern Linux) |
|---|---|---|
| Available on Windows | Yes | No |
| Available on macOS | Yes | No |
| Available on Linux | Yes (deprecated) | Yes (preferred) |
| Show routing table | route -n |
ip route show |
| Add a route | route add -net ... |
ip route add ... |
| Delete a route | route del -net ... |
ip route del ... |
| Persistent routes (Linux) | No built-in support | No built-in support (use config files) |
| Policy routing support | No | Yes (via ip rule) |
Common Scenarios
Force traffic over a VPN interface: When a VPN connects, it typically adds a default route with a lower metric than your existing one, pulling all traffic through the tunnel. You can verify this by running route print or route -n and checking whether the VPN interface appears in the default route entry.
Add a route to a specific subnet via a second gateway: In environments with multiple network segments — a corporate LAN and a management network, for example — you may need to reach one subnet via a different gateway than the default. A static route handles this cleanly: route add 172.16.0.0 mask 255.240.0.0 10.0.0.1.
Diagnose "No route to host": When a connection attempt returns "No route to host," check the routing table first. Confirm there is a default route and that the gateway IP is reachable with a ping. If the default route is missing or the gateway is unreachable, connectivity will fail.
Frequently Asked Questions
How do I view the routing table on Windows?
Open Command Prompt and run route print. This displays both the IPv4 and IPv6 routing tables, including the interface list, active routes, and persistent routes. Each route shows the network destination, netmask, gateway, interface, and metric.
What does the default route (0.0.0.0) mean?
The default route, shown as destination 0.0.0.0 with netmask 0.0.0.0 on Windows or as "default" on Linux, is the catch-all route. When the kernel looks up a destination and finds no more specific matching route, it sends the packet to the gateway specified in the default route — typically your router. Without a default route, your machine can only communicate with directly connected subnets.
How do I add a static route?
On Windows: route add 10.10.0.0 mask 255.255.0.0 192.168.1.254. On Linux: route add -net 10.10.0.0/16 gw 192.168.1.254. On modern Linux, prefer: ip route add 10.10.0.0/16 via 192.168.1.254. To make the route persistent on Windows, add the -p flag. On Linux, configure it in your network settings files.
What is the difference between route and ip route?
route is from the older net-tools package and is deprecated on Linux, though still available on macOS and Windows. ip route is from the modern iproute2 package on Linux. Both display and modify the routing table, but ip route supports more advanced features, has a more consistent syntax, and is actively maintained. On Linux, prefer ip route for new scripts and workflows.
How do I make a route persistent across reboots on Linux?
Routes added with the route or ip route command are lost on reboot. To persist them on Debian/Ubuntu, add the route to /etc/network/interfaces using a "post-up" directive. On systems using NetworkManager, use nmcli or the connection editor. On RHEL/CentOS, add the route to a file in /etc/sysconfig/network-scripts/.
What does "No route to host" mean?
"No route to host" means the kernel looked up the destination IP in its routing table and either found no matching route, or found a route but the next hop (gateway) reported the destination is unreachable. Common causes include a missing default gateway, a misconfigured static route, a firewall blocking ICMP unreachable messages, or the remote host being down.