How do I figure out which route I use for a prefix?


Userlevel 4
For example I know I can reach google.com
  cumulus@leaf1$ ping www.google.com  PING www.google.com (216.58.192.4) 56(84) bytes of data.  64 bytes from nuq04s29-in-f4.1e100.net (216.58.192.4): icmp_req=1 ttl=53 time=3.01 ms  64 bytes from nuq04s29-in-f4.1e100.net (216.58.192.4): icmp_req=2 ttl=53 time=2.82 ms  ^C  --- www.google.com ping statistics ---  2 packets transmitted, 2 received, 0% packet loss, time 1000ms  rtt min/avg/max/mdev = 2.820/2.919/3.019/0.113 ms  
But when I do an ip route show on the IP address I can't get there... nothing shows up in my route table
  cumulus@leaf1$ nslookup www.google.com  Server:  192.168.0.1  Address: 192.168.0.1#53    Non-authoritative answer:  Name: www.google.com  Address: 216.58.192.4    cumulus@leaf1$ ip route show 216.58.192.4  
Looking at my full route table
  cumulus@leaf1$ ip route show  default via 192.168.0.1 dev eth0  10.1.10.0/30 dev swp32s0  proto kernel  scope link  src 10.1.10.1  10.2.1.3  proto zebra  metric 20   nexthop via 10.2.1.3  dev swp1s0 weight 1 onlink   nexthop via 10.2.1.3  dev swp1s1 weight 1 onlink  10.2.1.4  proto zebra  metric 20   nexthop via 10.2.1.4  dev swp1s2 weight 1 onlink   nexthop via 10.2.1.4  dev swp1s3 weight 1 onlink  192.168.0.0/24 dev eth0  proto kernel  scope link  src 192.168.0.11  
it should take the default! Why does the default not appear when I do a ip route show 216.58.192.4?

2 replies

Userlevel 5
ip route show is a command geared towards displaying the routing table and providing information on that. The command you should use is ip route get
.

$ ip route get 216.58.192.4
216.58.192.4 via 192.168.0.1 dev wlan0 src 192.168.0.11

Userlevel 4
Scott Suehle wrote:

ip route show is a command geared towards displaying the routing table and providing information ...

Thanks Scott this is perfect!!
 cumulus@leaf1$ ip route get 216.58.192.4 216.58.192.4 via 192.168.0.1 dev eth0  src 192.168.0.11     cache 

                
        
            

Reply