Skip to main content
DARKPC.NET

Explain Linux Route Selection With ip route get

Ask the Linux kernel which interface and source address it would use for one destination, without transmitting a packet.

Difficulty Beginner

Prerequisites

Use Kali or another Linux workstation with iproute2. Use the terminal on your own machine. The queries read local routing information. They do not contact the example address.

Compare a network route with loopback

ip -brief address
ip route show default
ip route get 192.0.2.20
ip route get 127.0.0.1

The first two commands show addresses and default paths. The route query resolves one destination through the current kernel routing configuration. Listen for values labelled dev, src and via in the printed result. The 192.0.2.0/24 subnet is reserved for documentation. It can still match a local default route, though you should not use it to test Internet reachability. The loopback result should name lo.

Compare two legitimate states

On a lab VM, record an output with both the normal lab network and a second explicitly allowed network active. Change only the VM's normal network selection if it is safe to do so. Run the query again and note whether the interface, source or next hop changed. Route selection can depend on policy rules as well as the main table.

Troubleshooting and practice

An unreachable result can reflect the absence of a usable route or local policy. Check ip rule show before assuming the main routing table tells the full story. A route result does not establish remote connectivity or DNS health. Explain the difference between a kernel-selected route and an observed response. Redact private addresses and interface identifiers before sharing diagnostic output.

References and related reading