SO_BINDTODEVICE
https://stackoverflow.com/questions/14478167/bind-socket-to-network-interface
You can bind to a specific interface by setting SO_BINDTODEVICE socket option. Warning: You have to be root and have the CAP_NET_RAW capability in order to use this option.
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));