Command by command
| Legacy Linux (net-tools) | Linux | What it gives you |
|---|---|---|
route -n | ip route show | Main routing table |
route add -net 10.0.2.0/24 gw 10.0.1.2 | ip route add 10.0.2.0/24 via 10.0.1.2 | Add a static route |
route del -net 10.0.2.0/24 | ip route del 10.0.2.0/24 | Remove a route |
route add default gw 192.168.1.1 | ip route add default via 192.168.1.1 | Default route |
| ip route show table all | Every table — route cannot do this at all |
What the output looks like
$ ip route show
default via 10.0.1.1 dev eth0
10.0.1.0/24 dev eth0 proto kernel scope link src 10.0.1.10
Why the two differ
Linux has supported multiple routing tables and policy routing since the 2.2 kernel. A packet is matched against rules (ip rule show) which select a table, and only then against routes in that table. route -n knows nothing about this and always prints table main. On a host that uses policy routing — some multi-homed servers, VPN clients such as WireGuard's wg-quick sending all traffic through the tunnel, some container network plugins — that means it can confidently show you a table the kernel is not consulting for the traffic you care about.
The trap
route takes a netmask (-net 10.0.2.0 netmask 255.255.255.0) while ip route takes CIDR (10.0.2.0/24). Mixing the two syntaxes is the most common migration error, and ip route will reject the old form rather than guess.
Common questions
Do routes added with ip route add survive a reboot?
No. Anything added with ip route add lives in the kernel's memory and is gone on reboot. Persistence is handled by whatever manages your network configuration — netplan, NetworkManager, systemd-networkd or ifupdown — not by the command itself. This is also true of the old route add.
Why does ip route add say "RTNETLINK answers: Network is unreachable"?
Almost always because the next hop you gave is not on a directly connected subnet. Linux insists it can reach the gateway before it will accept a route through it, so add or fix the interface address first, then re-add the route. Current kernels word the same refusal as "Error: Nexthop has invalid gateway."
Stop reading, start running
Open the lab, go live, and run ip route show against real Linux networking in your browser. No install, no signup.