packet notes

Back to index / routes.html

Reading a routing table

A routing table tells the operating system where to send a packet next. It is useful to inspect the decision for one destination rather than guessing from the default route alone.

Show addresses and routes

ip -brief address
ip -4 route show
ip -6 route show

Interface addresses and routing entries describe different things. An interface can have an address without a usable route to the destination you need.

Ask for the selected route

ip -4 route get 192.0.2.10

This example uses a documentation address. The output normally identifies the selected interface, source address and, when needed, a gateway. It describes the kernel's routing decision; it does not send an application request.

Look for a more specific entry

For an ordinary destination lookup, the longest matching prefix is preferred. A route for a narrow subnet can take precedence over a default route. Policy routing can also select a different table based on rules.

ip rule show
ip route show table all

Keep read-only inspection separate from commands such as ip route add or ip route replace. Changing the route used by a remote session can interrupt your access.

Further reading: ip-route(8).