With the existence of the IP package in a linux/unix system the routing table can be viewed using the below command

$ ip route

ex:


root@00b74395b97a:/# ip route
default via 172.17.0.1 dev eth0
172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.2

 

That was a simple system with a single interface, But in case of having a system with too many interfaces and a longer routing table, the IP of the next hob as well as the exit interface for a specific route can e determined as following

 

$ ip route get 8.8.8.8

root@00b74395b97a:/# ip route get 8.8.8.8
8.8.8.8 via 172.17.0.1 dev eth0 src 172.17.0.2

The IP address mentioned after the keyword “via” 172.17.0.1 is the IP of the next hob

While the NIC mentioned after “dev” is the exit NIC in this case it’s “eth0”

While the IP following the “src” keyword will be the IP represented in the packet as the Source IP of the request. in this case it’s “172.17.0.2”