Configuration and routing

Read the routing table

Read destination prefixes, next hops, and interfaces, then identify the most specific matching route.

8 minute lesson

~~~

A host uses its routing table to choose where an IP packet goes next. A route includes a destination prefix and an outgoing interface, and may include a next-hop router.

The most specific matching prefix wins. A route for 192.0.2.0/24 is preferred over a default route for 0.0.0.0/0 when both match the destination.

Inspect routes on Linux or macOS with:

ip route
netstat -rn

An on-link route sends directly to the destination after neighbor discovery. A gateway route sends the frame to a router. The default route is only the fallback when no more specific route matches.

Inspect the routes your machine will really use:

ip route
ip route get 1.1.1.1
ip route get 192.168.1.1

The first command shows the table. The next commands ask the kernel to choose a path for one destination. Record the selected interface, gateway, and source address. If your system uses route -n or netstat -rn instead, find the same four facts rather than memorizing one operating-system command.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →