Skip to contentSkip to conversation

getting the NIC that my socket connection will go on

DISCUSSION Lee Chin 3 participants 3 messages Sep 17, 2003

lore
Share & tools
lore

Lee Chin

author
#0 lore raw

Hi,
I have an IP address I want to connect to. How can I tell what NIC Linux will use to make that connection on?

Thanks
Lee

Signature · 12 lines
__________________________________________________________
Sign-up for your own personalized E-mail at Mail.com
http://www.mail.com/?sr=signup

CareerBuilder.com has over 400,000 jobs. Be smarter about your job search
http://corp.mail.com/careers

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
#1 lore raw

See SO_BINDTODEVICE

Quoted 7 lines · Lee Chin

Hi,
I have an IP address I want to connect to. How can I tell what NIC Linux will use to make that connection on?

Thanks
Lee

#2 lore raw
In reply to Lee Chin
Quoted 2 lines · Lee Chin

Hi,
I have an IP address I want to connect to. How can I tell what NIC Linux will use to make that connection on?

You look at your routing table to see which interface the kernel has been told to use to reach that IP address, then you see what NIC that interface is associated with in your setup.

One common way to display the routing table is the command "netstat -nr"; another is "route -n". The man pages for route and netstat will tell you more about options and switches.

The typical way to find out what actual device (in your case, what NIC) is associated with an interface is with the command "ifconfig -a". Some systems may not have that command (full-size distros usually do, but specialized distros like router/firewall systems may not), and you'll need to use some variant of "ip" instead, maybe "ip -s addr".

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs