Find the answer to your Linux question:
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.
  1. #1
    Just 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!

  2. #2
    Linux Guru rokytnji's Avatar
    Join Date
    Jul 2008
    Location
    Desert
    Posts
    4,037
    I'm no expert in what you're trying to do but maybe this how to will help you.

    Linux Tutorial - Linux Network Administration
    Linux Registered User # 475019
    Lead,Follow, or get the heck out of the way. I Have a Masters in Raising Hell
    Tech Books
    Free Linux Books
    Newbie Guide
    Courses at Home

  3. #3
    Just Joined!
    Join Date
    Jan 2009
    Posts
    4
    Quote Originally Posted by rokytnji View Post
    I'm no expert in what you're trying to do but maybe this how to will help you.

    Linux Tutorial - Linux Network Administration
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •