Showing the default route is one of the fastest ways to confirm where a Linux host sends traffic when no more specific route matches. It is usually the first check when local-subnet communication works but internet or upstream connectivity does not.
The ip route show default filter asks the kernel for routes whose destination is the catch-all default prefix for the selected address family. In the output, the via field identifies the next-hop gateway, while dev shows the interface used to reach that gateway.
By default, ip route show reads the main routing table only. If the command returns no default route, or if live traffic follows a different path than the main table suggests, the host may be using policy-routing rules, a custom table, or a separate IPv6 default route checked with ip -6 route show default.
Steps to show default route and gateway with ip route:
- Show the default route from the main routing table.
$ ip route show default default via 172.17.0.1 dev eth0
- Read the gateway and interface fields from the result.
In the example above, 172.17.0.1 is the next-hop gateway and eth0 is the egress interface used for destinations that do not match a more specific route.
- Show the full main routing table when a more specific route may be taking precedence over the default route.
$ ip route show default via 172.17.0.1 dev eth0 172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.4
Connected or more specific prefixes are matched before the default route, so the default gateway is not always the path used for every destination.
- Check the route the kernel would actually choose for a real destination.
$ ip route get 1.1.1.1 1.1.1.1 via 172.17.0.1 dev eth0 src 172.17.0.4 uid 0 cacheThe via field confirms the selected gateway for that destination, while src shows the preferred source address for outbound packets.
- Inspect custom tables or routing-policy rules if the main default route is missing or does not explain the traffic path.
Use ip -6 route show default when the issue involves IPv6, because IPv4 and IPv6 default routes are tracked separately.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
