ip route: Check Routing and the Default Gateway in CI
ip route prints the routing table, and ip route get <ip> shows exactly which route a packet to that address would take.
A "No route to host" error means the kernel has nowhere to send the packet. ip route shows the routing table and the default gateway; ip route get traces the decision for one destination.
What it does
ip route lists the kernel routing table: the default route (gateway of last resort) and the directly connected subnets. ip route get <ip> asks the kernel which route and source address it would use for that destination, which pinpoints a missing or wrong route.
Common usage
ip route
# which route would a packet to this host take?
ip route get 10.0.0.5
# show the default gateway specifically
ip route show defaultOptions
| Command | What it does |
|---|---|
| ip route | Show the full routing table |
| ip route show default | Show only the default route (gateway) |
| ip route get <ip> | Show the route and source IP for one destination |
| ip -6 route | Show the IPv6 routing table |
In CI
If a host is unreachable, ip route get <ip> tells you whether the kernel even has a path: it either prints the chosen route or fails with "unreachable". No default route at all (no "default via" line) means outbound traffic to anything off the local subnet has nowhere to go, a common broken-container symptom.
Common errors in CI
"RTNETLINK answers: Network is unreachable" or ip route get printing "<ip> via ... unreachable" means there is no route to that destination, often a missing default gateway. The application sees this as "connect: Network is unreachable" or "No route to host". A wrong default gateway sends traffic to a dead next-hop, which times out rather than refusing.