Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
    gateway: 10.36.13.1
  interface: en0
      flags: <UP,GATEWAY,HOST,DONE,WASCLONED,IFSCOPE,IFREF>
 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
add comment

1 Answer

up vote 7 down vote accepted

There is

ip route get 74.125.137.100

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
1  
ip route get "$(dig google.com +short)" for hostname resolution. –  jordanm Oct 31 '12 at 17:28
1  
@jordanm, More like: dig google.com +short | xargs -tn1 ip route get –  Stephane Chazelas Oct 31 '12 at 20:16
add comment

Your Answer

 
discard

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.