Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The BSD route command has a feature that will show what route will be selected for a given host. For example:

/Users/mhaase $ route get google.com
   route to: iad23s07-in-f8.1e100.net
destination: iad23s07-in-f8.1e100.net
  interface: en0
 recvpipe  sendpipe  ssthresh  rtt,msec    rttvar  hopcount      mtu     expire
       0         0         0         0         0         0      1500         0 

I occasionally find this useful if I am manually messing with routing tables to make sure that the routing rules are working as expected.

The GNU version of route does not have this same "get" subcommand. Is there some equivalent or alternative for GNU/Linux?

share|improve this question
I was looking for the /BSD/ equivalent of ip ro but this page still suffices :) – Benjamin Goodacre Feb 17 at 15:07
up vote 16 down vote accepted

There is

ip route get

but it doesn't do hostname resolution (which I think is a good thing). The command is usually available from iproute or iproute2 packages.

share|improve this answer
ip route get "$(dig google.com +short)" for hostname resolution. – jordanm Oct 31 '12 at 17:28
@jordanm, More like: dig google.com +short | xargs -tn1 ip route get – Stéphane Chazelas Oct 31 '12 at 20:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.