route: Usage, Options & Common CI Errors
route prints and edits the kernel routing table (the legacy tool).
route is the net-tools predecessor to ip route. It still appears in older scripts to add a default gateway, but on modern images it is absent and ip route is the replacement - important when debugging "Network is unreachable".
What it does
route displays and manipulates the IPv4 routing table - listing routes and adding or deleting them, including the default gateway. It is part of the deprecated net-tools package; ip route is the iproute2 equivalent and is what modern images ship.
Common usage
route -n # routing table, numeric
route # with name resolution (slower)
route add default gw 10.0.0.1 eth0
route del default
# Modern equivalent:
ip route showOptions
| Usage | What it does |
|---|---|
| -n | Numeric output (no DNS) |
| add default gw <ip> <if> | Set the default gateway |
| add -net <net> gw <ip> | Add a network route |
| del <target> | Remove a route |
| -ee | Extended output |
Common errors in CI
"route: command not found" - net-tools is gone on most modern/slim images; use ip route show (list) and ip route add default via <gw> dev <if> (set). "SIOCADDRT: Operation not permitted" adding a route needs NET_ADMIN. "SIOCADDRT: File exists" means the route is already present. An empty default-route line under route -n (no "0.0.0.0" destination) is the smoking gun for "Network is unreachable" - the same diagnosis you get faster from ip route show default.