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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With