Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to look up in Linux IP routing table?

Tags:

routing

I've been manipulating the Linux routing table by "route add" and "route del". Now given an IP, how can I know (by typing some command) which gateway/device will it go through?

For example, if I have run:

route add -net 192.57.66.0 netmask 255.255.255.0 dev eth0

Is there a command that can tell me if I visit 192.57.66.42, it will go through eth0?

like image 230
Chen Xing Avatar asked Jan 21 '12 10:01

Chen Xing


1 Answers

You should stop using net-tools, because you won't find the answer there. But for iproute:

ip route add 192.57.66.0/24 dev eth0
ip route get 192.57.66.42
like image 113
jørgensen Avatar answered Nov 12 '22 18:11

jørgensen