The network routing table is a crucial component that determines the paths for data packets to reach specific network destinations. In Linux, this information is stored in the Routing Information Base (RIB).
On older Linux systems, the routing table can be displayed using the route and netstat commands in the terminal. These commands are part of the net-tools suite, which is now considered deprecated and is gradually being replaced by the iproute2 suite.
Most modern Linux systems come with iproute2 pre-installed. If it's not installed on your system, it can usually be found in the default package manager's repository and can be easily installed.
$ sudo apt update && sudo apt install --assume-yes iproute2 # Ubuntu and Debian
$ ip route list 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
$ ip route list 192.168.111.0/24 192.168.111.0/24 dev ens33 proto kernel scope link src 192.168.111.128
$ ip route list | grep ^default default via 192.168.111.2 dev ens33 proto dhcp src 192.168.111.128 metric 100
This is useful for people who are used to grep rather than having to memorize all the switches for the ip route command.
Comment anonymously. Login not required.