Q: Raw packets directed to a specific interface

I need to be able to send raw packets to one of several interfaces - what is
the mechanism to select an interface to send the raw packet on?

When I create a raw socket, the sendto() function complains if there is no
default route in the routing table, which implies that the packet will be
sent out on whichever interface is associated with the default route. Note
that I don’t necessarily want to send out an IP packet.

Any help would be appreciated.

btw, I’ve looked at bpf and libpcap, but these appear to simply capture
data.

Issam

Issam Haddad <ihaddad@asurent.com> wrote:
: I need to be able to send raw packets to one of several interfaces - what is
: the mechanism to select an interface to send the raw packet on?

: When I create a raw socket, the sendto() function complains if there is no
: default route in the routing table, which implies that the packet will be
: sent out on whichever interface is associated with the default route. Note
: that I don’t necessarily want to send out an IP packet.

: Any help would be appreciated.

: btw, I’ve looked at bpf and libpcap, but these appear to simply capture
: data.

: Issam


If that’s the case, there isn’t currently an easy way to do this.
If you want to send udp packets, you can look at the SO_BINDTODEVICE
option; otherwise, you’ll have to write a module for io-net.

-seanb