If I have multiple network interfaces (here: 2) on a Linux machine (here: Debian Lenny). How do I see, over what network interface (NIC) a route to a specific destination host is going and what source IP address is used by default?
I have though of using
ping -I nic1 desthost.example.com
ping -I nic2 desthost.example.com
too see if both ways are possible. (Here: Both ways are possible)
I looked up the routing table
ip route show
But it's quite complex, so I thought, there must by a small simple tool, to just tell me:
"To destination host desthost.example.com it takes interface nicX and source IP address 10.0.0.1"
What is the simplest way of getting this information?
(And I'd rather not use tcpdump and set the interfaces in promiscous mode.)
Thanks.
Use
ip route get <ip>
.what about
route -C
I use
netstat -Wcatnp
. You should try this command.Even easier, I'd say
nm-tool
and if you only want the relevant linenm-tool | grep Device
. That should output: