Drill: Read and Manipulate the Routing Table¶
Goal¶
Use ip route to inspect, query, and manipulate the Linux routing table for network debugging.
Setup¶
- Linux system with iproute2 installed
- Root access for modifying routes
Commands¶
Show the main routing table:
Show the routing table with all details:
Find which route a specific destination uses:
Show routes for a specific subnet:
Add a static route:
Add a route with a specific metric:
Delete a route:
Show the default gateway:
Check routing cache/nexthop:
What to Look For¶
ip route getshows the exact route and source IP used for a destination- Routes with lower metrics are preferred when multiple paths exist
scope linkroutes are for directly connected networks- The
defaultroute is the gateway of last resort
Common Mistakes¶
- Using
routecommand instead ofip route(route is deprecated) - Forgetting that routes added with
ip route addare not persistent across reboots - Not checking
ip route getto verify which route is actually selected - Adding routes with wrong source interface, causing asymmetric routing