How to display Routing Table

In networking, a routing table is a data table stored in a router or a network host that lists the routes to particular network destinations, and in some cases, metrics associated with those routes.

To display the Linux kernel routing table, we can use either the route, netstat, or ip commands. Below are examples using each of these commands.

route

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.10.0.1       0.0.0.0         UG    0      0        0 eth0
10.10.0.0       0.0.0.0         255.255.255.0   U     0      0        0 eth0

The -n show numerical addresses instead of trying to determine hostnames. This is useful if you are trying to determine why the route to your nameserver has vanished.

netstat

$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         10.10.0.1       0.0.0.0         UG        0 0          0 eth0
10.10.0.0       0.0.0.0         255.255.255.0   U         0 0          0 eth0

The -r option specifies that you want the routing table. The -n option is similar to that of the route command.

ip

$ ip route list
10.10.0.0/24 dev eth0 proto kernel scope link src 10.10.0.58
default via 10.10.0.1 dev eth0