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 8.8.8.8
(One of Google’s public DNS server IP addresses). We run the route
utility and pass it the necessary arguments – get 8.8.8.8
. Below is the output of the utility run on a Solaris machine.
ibrahim@solaris> route get 8.8.8.8 route to: 8.8.8.8 destination: default mask: default gateway: 192.168.10.1 interface: oce0 flags: <UP,GATEWAY,DONE,STATIC> 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 192.168.10.1
.
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 8.8.8.8 8.8.8.8 via 192.168.10.1 dev eth0 src 192.168.10.100 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 192.168.10.1
.
Do note that on Linux, you have to specify an IP address and not a host name.