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)))

    the result is:
    setsockopt: No such device

    SO_BINDTODEVICE is not supposed to work on an aliased interface?

    Christophe Lohr, Jan 16, 2009
    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.

    David Schwartz, Jan 16, 2009
    1. Advertisements

  3. David Schwartz a écrit :

    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?)

    Christophe Lohr, Jan 19, 2009
  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?

    Christophe Lohr, Jan 23, 2009
  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.)

    David Schwartz, Jan 23, 2009
    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.