Results 1 to 3 of 3
I just want to say hi to all. I am new here and need your help. I am programming to detect NICs in my system, and choose which one I ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-17-2009 #1Just Joined!
- Join Date
- Jan 2009
- Posts
- 4
Hi everyone and please help
I just want to say hi to all. I am new here and need your help. I am programming to detect NICs in my system, and choose which one I want to use to send packets (Raw-Ethernet socket API). With Raw-Ethernet socket API can I bind a socket to a certain NIC? let's say I want to use Eth1 how can I open a socket bound to Eth1?
Thanks for your help!
- 02-18-2009 #2
I'm no expert in what you're trying to do but maybe this how to will help you.
Linux Tutorial - Linux Network AdministrationLinux Registered User # 475019
Lead,Follow, or get the heck out of the way
I'd rather be a dangerous, wild Penguin than a docile, domesticated sheep.
Free Linux Books
Free R Books
- 02-18-2009 #3Just Joined!
- Join Date
- Jan 2009
- Posts
- 4
Thanks! I looked through the site and seems like there is no help specific to my problem. Is there any forums out there do you think can help? maybe my question is so ambiguous. If this is the case then I would like to reinstate it. Basically I want to open a raw socket like this (in C code):
sockfd = socket(AF_PACKET, SOCK_RAW, htonl(ETH_P_ALL)
Since I have more than one NICs in the box, I want to bind this raw socket to let's say eth2 and send packets out of this NIC only.
I found bind() could help but it didn't work. According to the man page bind() can only bind a socket intended for receiving (only) to a NIC, but it cannot assign a NIC to a socket for transmiting. Right now I am trying setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,"eth2"). Hopefully it will works.
Any hints I would appreciate.


Reply With Quote

