SO_BINDTODEVICE socket option on an aliased interface

Discussion in 'Linux Networking' started by Christophe Lohr, Jan 16, 2009.

  1. Hi,
    I do something like :

    char * device = "eth0:1";
    int s;
    s = socket(PF_INET, SOCK_STREAM, 0);
    if (setsockopt(s, SOL_SOCKET, SO_BINDTODEVICE, device, strlen(device)))
    perror("setsockopt");

    the result is:
    setsockopt: No such device

    Why?
    SO_BINDTODEVICE is not supposed to work on an aliased interface?

    Regards,
    Christophe.
     
    Christophe Lohr, Jan 16, 2009
    #1
    1. Advertisements

  2. Just bind to the main interface. The aliased interface is an alias for
    the main interface, that is, it's another name for the same interface.

    DS
     
    David Schwartz, Jan 16, 2009
    #2
    1. Advertisements

  3. David Schwartz a écrit :
    Ok.

    I have another question: according to man socket(7), it is not
    supported for packet sockets. So, why? (It's not yet implmented, or is
    it impossible?)

    Regards
    Christophe.
     
    Christophe Lohr, Jan 19, 2009
    #3
  4. Christophe Lohr a écrit :
    I have a new question (again): what is the behavior of outgoing packets?
    Are they routed through the given interface?

    Regards.
     
    Christophe Lohr, Jan 23, 2009
    #4
  5. If they can be routed, they will be routed through the best interface.
    If they cannot be routed, the given interface will be used. (For
    example, an arbitrary Ethernet packet that is not in a protocol known
    to the OS cannot be routed by the OS.)

    DS
     
    David Schwartz, Jan 23, 2009
    #5
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.