When having multiple gateway it is very useful know which route is used by particular address. So we can know if the routing is work as expected. For this task we can use ip route get command.
Show Selected Route for particular IP
ip route get 8.8.8.8
8.8.8.8 via 192.168.42.129 dev usb0 src 192.168.42.243
cache
Show Selected Route for particular Domain
The ip route does not do name resolution so we can use other tools such asdig to display routing for a domain.
ip route get "$( dig google.com +short | head -1 )"
74.125.135.100 via 192.168.42.129 dev usb0 src 192.168.42.243
cache ipid 0x766e rtt 449ms rttvar 256ms cwnd 10
We need to pipe the result to "head" since the dig result might contains more than one address at a time.
0 comments:
Post a Comment