Inspecting the routing table on Linux clarifies how packets leave and enter a host by showing default gateways, directly attached networks, and special routes. Clear visibility of these entries helps explain unreachable subnets, asymmetric paths, and policy decisions that affect latency and resilience.
The kernel stores routing information in the Routing Information Base (RIB) and consults it for every outgoing packet. Tools from the iproute2 suite, particularly the ip route subcommand, query and manipulate this data, exposing tables such as main and local for IPv4 and IPv6 with destinations, next-hop gateways, interface names, and metrics.
Complex topologies that involve multiple interfaces, VPNs, containers, or policy-based routing can introduce overlapping or custom tables, so interpreting entries depends on accurate knowledge of interface names and address plans. Some commands may require elevated privileges, and changes made interactively are typically ephemeral unless duplicated in configuration files such as /etc/netplan, /etc/network/interfaces, NetworkManager profiles, or distribution-specific network scripts.
Steps to check the routing table in Linux:
- Open a terminal with access to an account that can run administrative commands if required.
- Display the full IPv4 routing table using the ip route command.
$ ip route default via 192.168.111.2 dev ens33 proto dhcp src 192.168.111.128 metric 100 192.168.111.0/24 dev ens33 proto kernel scope link src 192.168.111.128 192.168.111.2 dev ens33 proto dhcp scope link src 192.168.111.128 metric 100
The base form ip route shows routes from the main table, including the default gateway and connected networks.
- Show only default routes to identify the primary gateway in use.
$ ip route show default default via 192.168.111.2 dev ens33 proto dhcp src 192.168.111.128 metric 100 $ ip route | grep ^default default via 192.168.111.2 dev ens33 proto dhcp src 192.168.111.128 metric 100
Filtering with grep gives a quick view of default routes when the table contains many entries.
- Inspect routes for a specific destination prefix or host address to see the chosen interface and next hop.
$ ip route show 192.168.111.0/24 192.168.111.0/24 dev ens33 proto kernel scope link src 192.168.111.128 $ ip route get 8.8.8.8 8.8.8.8 via 192.168.111.2 dev ens33 src 192.168.111.128 cacheReplace the sample prefix or address with the network or host under investigation to confirm which path the kernel will select.
- Display IPv6 routing information if IPv6 connectivity is configured on the system.
$ ip -6 route ::1 dev lo proto kernel metric 256 2001:db8:1234:5678::/64 dev ens33 proto ra metric 100 fe80::/64 dev ens33 proto kernel metric 256
IPv6 routes follow the same lookup logic as IPv4 but use IPv6 prefixes and can appear in separate tables managed by iproute2.
- Verify routing behaviour by sending a few echo requests through the default route to a known reachable host.
$ ping -c 3 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=114 time=12.3 ms 64 bytes from 8.8.8.8: icmp_seq=2 ttl=114 time=12.1 ms 64 bytes from 8.8.8.8: icmp_seq=3 ttl=114 time=12.4 ms --- 8.8.8.8 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2002ms rtt min/avg/max/mdev = 12.124/12.277/12.441/0.129 ms
Successful replies confirm that the active routes and default gateway provide functional connectivity to external networks.
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.
Comment anonymously. Login not required.
