Get Route Details for a Destination on Linux

To verify routing entries for a destination IP on a Solaris machine, I typically use the route get command. This will give the source IP address and Ethernet interface used by the kernel to reach the specified destination. On Linux however, the route utility does not support the get sub command.

Let’s say we want to determine how the Solaris kernel routes to IP address (One of Google’s public DNS server IP addresses). We run the route utility and pass it the necessary arguments – get Below is the output of the utility run on a Solaris machine.

ibrahim@solaris> route get
   route to:
destination: default
       mask: default
  interface: oce0
 recvpipe  sendpipe  ssthresh    rtt,ms rttvar,ms  hopcount      mtu     expire
       0         0         0         0         0         0      1500         0 

Based on the above output, we can determine that the oce0 interface is being used to reach the destination and the first hop gateway or router IP address is

To get that same information on Linux, we will need to run the ip route get command instead. Let’s try to use this command to find the routing details to reach the same destination IP address again.

[ibrahim@linux ~]$ ip route get via dev eth0  src
    cache  mtu 1500 advmss 1460 hoplimit 64

There, you have it. You can see that the eth0 interface is being used to reach the destination and the router’s IP address is

Do note that on Linux, you have to specify an IP address and not a host name.

ibrahim = { interested_in(unix, linux, android, open_source, reverse_engineering); coding(c, shell, php, python, java, javascript, nodejs, react); plays_on(xbox, ps4); linux_desktop_user(true); }