1. Routing table
ip route prints the kernel routing table — the rules that pick a next hop per destination.
ip routeTyporithm · medium
Step 1 of 8 · intro card
L3 — Network Layer
A routing table maps destinations to a next hop, choosing the longest-prefix match. The default route (0.0.0.0/0) sends everything else to the gateway. Routers decrement the IP TTL at each hop and forward between interfaces when ip_forward is on. traceroute uses rising TTLs to map the hop path.
Every host has a routing table. For each outgoing packet the kernel finds the entry whose prefix matches the destination most specifically — the longest-prefix match — and sends the packet to that route's next hop or out its interface.
When no specific route matches, the default route 0.0.0.0/0 takes over and hands the packet to the gateway. The gateway is a router that knows how to reach the wider network or the internet.
Routers forward packets between their interfaces, decrementing the IP TTL by one at each hop; a packet hitting TTL 0 is dropped. A Linux host only forwards when net.ipv4.ip_forward is 1. traceroute exploits TTL expiry — sending packets with TTL 1, 2, 3… — to make each router announce itself.
Routing table picks the next hop by longest-prefix match.
Default route 0.0.0.0/0 sends the rest to the gateway.
Routers decrement TTL each hop; forwarding needs ip_forward=1.
ip route
ip route show default
ip route add 10.0.0.0/8 via 192.168.1.1
traceroute 8.8.8.8
sysctl net.ipv4.ip_forwardConnect each part of the code to the concept before you type.
ip route prints the kernel routing table — the rules that pick a next hop per destination.
ip routeThe default route (0.0.0.0/0) catches every destination not matched by a more specific route.
ip route show defaultThis sends all 10.0.0.0/8 traffic to the next hop 192.168.1.1.
ip route add 10.0.0.0/8 via 192.168.1.1traceroute sends packets with increasing TTLs to reveal each router on the path.
traceroute 8.8.8.8net.ipv4.ip_forward must be 1 for the host to forward packets between interfaces like a router.
sysctl net.ipv4.ip_forwardRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.