Use it when traffic leaves through the wrong interface, or a network is unreachable.
Routing Table
The Linux routing table decides where each packet goes: the most specific matching route wins, then metric. ip route shows the main table; policy routing (ip rule) can select other tables.
1. ip route get <dest> — which route, interface and source?
2. ip route — expected specific route present?
3. Multiple tables? ip rule and ip route show table all.
4. Add temporarily: ip route add <net> via <gw>; then persist in the tool.
5. Test the path: tracepath <dest>.
packet → ip rules choose a table → longest prefix match → lowest metric → next hop and interface
For Linux Networking → Routing Table, continue with the first unproven Topic check: Capture relevant ip rule ordering and all tables used by the flow, not only main. If that boundary is healthy, advance to the adjacent check: Run a route lookup using the exact destination and source/context of the failing traffic. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
ip route show table mainPrimary Commands
Configuration and operational commands for this Topic.
ip route show table mainVerifyShows Linux IPv4 routes in the main table.
Use when: Use after confirming the Linux Networking target and before changing state.
Quick note: Linux · distribution/version specific. A successful command or active unit proves only local state; it does not prove dependency health, data integrity or client-visible service.
Linux · mixedip route get {{destination}}ReferenceAsks the kernel which route/source/device would be used for a destination.
Use when: Use after confirming the Linux Networking target and before changing state.
Quick note: Linux · distribution/version specific. A successful command or active unit proves only local state; it does not prove dependency health, data integrity or client-visible service.
Linux · mixedip -6 route showReferenceInspect IPv6 routes and default-router selection.
Linux · mixedVerification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
packet context → RPDB rule match → FIB table → longest-prefix/metric selection → route type + nexthop → output interface → neighbor → forwarding path → return path → workload
Healthy evidence: the exact packet context matches the expected policy rule and FIB route, nexthop/interface are usable, and the return path supports the original flow.
Step 2 Verification and output interpretation Verify boundary
Existing fast checks for this Topic. - Capture relevant ip rule ordering and all tables used by the flow, not only main.
- Run a route lookup using the exact destination and source/context of the failing traffic.
- Verify nexthop/interface reachability and neighbor state after route selection.
- Validate both forward and return paths with the original protocol/service.
Verification chain. packet context → RPDB rule match → FIB table → longest-prefix/metric selection → route type + nexthop → output interface → neighbor → forwarding path → return path → workload
Step 3 Commands Verify boundary
ip route
ip route get 8.8.8.8
ip -6 route
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: a route exists only in an unused table, policy rules divert traffic, source selection changes lookup outcome, or a valid local lookup masks an unreachable nexthop/return path.
Step 5 Common mistakes Narrow the fault
- Adding routes with
ip route addand losing them on reboot.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
ip route get <dest> shows the actual decision including source address. Routes added with ip route add are temporary — persist them in NetworkManager, netplan or networkd. Check ip rule if you use multiple tables or VPNs.
ip rule— policy routing rulesip -br addr— interfaces and addressesip route— routing table and default routeip neigh— ARP/neighbour cacheip route get <dest>— route, interface and source chosen for a destinationnmcli device status / networkctl— which tool manages each interface
ReferenceWhat it is1 section · depth on demand
Core model
Do not read the main table as the whole routing decision. Reproduce lookup with the exact destination and, when relevant, source address, ingress interface, fwmark, TOS or VRF context. Distinguish route presence from rule reachability, nexthop usability and symmetric return routing.
ReferenceImportant terms & boundaries5 sections · depth on demand
What this shows and what it does not
A kernel route lookup shows the local host decision for the supplied context, but it does not show nexthop L2 resolution, downstream routing, remote policy or the return path.
In depth
The Linux routing table with ip route
Linux can hold many routing tables. Normal routes go into the main table, and ip route shows and changes them. The ip-route(8) manual page describes the tables:
main(254) holds normal routes.local(255) holds local and broadcast addresses and is maintained by the kernel.- Table numbers can go up to 2^32−1, with names defined in
/etc/iproute2/rt_tables. - 0, 253, 254 and 255 are reserved.
Route types
| Type | Effect |
|---|---|
unicast | A real path to the destination (the default type) |
local | The destination is this host |
broadcast | Sent as link broadcast |
unreachable | Dropped with ICMP host unreachable; local senders get EHOSTUNREACH |
prohibit | Dropped with ICMP administratively prohibited; local senders get EACCES |
blackhole | Dropped silently; local senders get EINVAL |
throw | Ends the lookup in this table, so policy rules continue to the next |
Route attributes
| Attribute | Meaning |
|---|---|
proto kernel / boot / static / ra | Who installed the route: the kernel (connected), at boot, the administrator, or IPv6 router discovery |
scope link / global / host | Directly attached / via a gateway / this host |
metric | Lower values are preferred among otherwise equal routes |
src | Preferred source address for traffic using the route |
nexthop ... weight | Multipath routes with relative weights |
Asking the kernel instead of reading the table
ip route get resolves a destination exactly as the kernel would, including policy rules and source selection. It's the most reliable answer to "which way will this packet go?"
host$ ip route
default via 10.110.0.1 dev eth0 proto dhcp src 10.110.0.64 metric 100
10.110.0.0/24 dev eth0 proto kernel scope link src 10.110.0.64 metric 100
10.40.0.0/16 via 10.110.0.254 dev eth0 proto static
host$ ip route get 10.40.5.9
10.40.5.9 via 10.110.0.254 dev eth0 src 10.110.0.64 uid 1000
host$ ip route show table all | grep -v '^local\|^broadcast' | head
host$ ip rule show
0: from all lookup local
32766: from all lookup main
32767: from all lookup default
host$ sudo ip route replace 10.40.0.0/16 via 10.110.0.253
Notes on the example
replaceadds the route or changes it if it already exists. That makes it safer thanaddin scripts.- Since Linux 3.6 there is no IPv4 routing cache. Outdated advice to "flush the route cache" doesn't apply to modern kernels.
Documented example, not captured output.
How it works at runtime
Routing Table is part of Linux Networking → Routing Table. Linux route selection uses the routing policy database plus one or more FIB tables; prefixes, metrics, route types, source hints, nexthops, interfaces and policy rules determine the route selected for an exact packet context.
Topic-specific state model. Linux route selection uses the routing policy database plus one or more FIB tables; prefixes, metrics, route types, source hints, nexthops, interfaces and policy rules determine the route selected for an exact packet context.
Interpretation rule. - Route listed in a table ≠ route selected by the routing policy database.
- Lowest metric ≠ universal winner across different prefix lengths, tables and rules.
- Selected nexthop ≠ neighbor resolution or downstream forwarding succeeds.
- Forward-path route success ≠ return path is valid or symmetric.
Quick reference
The Linux routing table (main table, plus policy-routing tables) decides the next hop and source address.
ip route show
ip route get 10.20.30.40 # route, device and src chosen for a destination
ip route add 10.50.0.0/16 via 10.0.10.254 dev eth1
ip route replace default via 10.0.10.1 dev eth0 metric 100
ip -6 route show
ip rule show # policy routing rules
ip route show table all | grep -v local
Selection: longest prefix, then lowest metric. Routes added with ip route are not persistent — configure them in NetworkManager, netplan or systemd-networkd.
Limits and how it fails
Primary failure point. A kernel route lookup shows the local host decision for the supplied context, but it does not show nexthop L2 resolution, downstream routing, remote policy or the return path.
ReferenceConfiguration & state1 section · depth on demand
Configuration, persistence and lifecycle
Distribution/platform context. Routing Table owns Linux kernel route/rule lookup semantics. Default Gateway is the default-route specialization; broader route failures are correlated in Network Troubleshooting.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Linux Networking → Routing Table. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.kernel.org/networking/index.html · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Routing Table operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for Routing Table.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | Linux route selection uses the routing policy database plus one or more FIB tables; prefixes, metrics, route types, source hints, nexthops, interfaces and policy rules determine the route selected for an exact packet context. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin host + namespace + exact flow → identify configuration owner/renderer → identify ifindex/interface + topology → inspect link/carrier → inspect addresses → inspect neighbor resolution → reproduce route/rule lookup → verify VLAN/bond/bridge/MTU as relevant → inspect packets/socket → verify return path → repeat original workload. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | packet context → RPDB rule match → FIB table → longest-prefix/metric selection → route type + nexthop → output interface → neighbor → forwarding path → return path → workload | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | A kernel route lookup proves the local host decision for the supplied context; it does not prove nexthop L2 resolution, downstream routing, remote policy or the return path. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux networking evidence can establish this proof path: packet context → RPDB rule match → FIB table → longest-prefix/metric selection → route type + nexthop → output interface → neighbor → forwarding path → return path → workload | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove behavior outside the captured namespace, interface, local kernel, L2/path or workload scope. A kernel route lookup proves the local host decision for the supplied context; it does not prove nexthop L2 resolution, downstream routing, remote policy or the return path. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven boundary: confirm namespace and configuration owner, inspect ifindex/link/address/neighbor/route state for the exact flow, verify L2/MTU construction and packet movement, then test the listening service and return path before making additional changes. | Continue to the next unresolved boundary while preserving the original test condition. |
Routing Table · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | Routing Table |
|---|---|
| Topic path | Linux Networking → Routing Table |
| Runtime state | Linux route selection uses the routing policy database plus one or more FIB tables; prefixes, metrics, route types, source hints, nexthops, interfaces and policy rules determine the route selected for an exact packet context. |
| Fast checks | - Capture relevant ip rule ordering and all tables used by the flow, not only main. - Run a route lookup using the exact destination and source/context of the failing traffic. - Verify nexthop/interface reachability and neighbor state after route selection. - Validate both forward and return paths with the original protocol/service. |
| Verification chain | packet context → RPDB rule match → FIB table → longest-prefix/metric selection → route type + nexthop → output interface → neighbor → forwarding path → return path → workload Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary. |
| Failure boundary | A kernel route lookup proves the local host decision for the supplied context; it does not prove nexthop L2 resolution, downstream routing, remote policy or the return path. Boundary chain: process/socket namespace → source/rule/FIB → neighbor → netfilter/eBPF/qdisc → virtual/physical device → peer → return → application. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |