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.

Steps to display network routing table in Linux:

  1. Open a terminal application.
  2. Install the iproute2 suite (optional, only if your system doesn't have it installed already).
    $ sudo apt update && sudo apt install --assume-yes iproute2 # Ubuntu and Debian
  3. Display the complete network routing table using the ip command.
    $ ip route list
    default via dev ens33 proto dhcp src metric 100 dev ens33 proto kernel scope link src dev ens33 proto dhcp scope link src metric 100
  4. View route information for a specific network segment.
    $ ip route list dev ens33 proto kernel scope link src
  5. Filter and display a particular route using the grep command.
    $ ip route list | grep ^default
    default via dev ens33 proto dhcp src 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.

Discuss the article:

Comment anonymously. Login not required.