I have multiple interfaces on the box and want to force the traffic through a particular interface using python.
This thread answers how to do that for HTTP traffic. But when I look at tcpdump, the DNS queries do not honor the interface setting. libcurl provides options to force DNS traffic through a particular interface using option CURLOPT_DNS_INTERFACE and CURLOPT_DNS_LOCAL_IP4
I tried using the same through C and it seems to honor the interface when libcurl is built with c-ares support.
But when the same options are used from the pycurl version result in the following errors:
AttributeError: DNS_INTERFACE
AttributeError: DNS_LOCAL_IP4
I am trying monkey patching suggested on this thread. But based on the comments, other people already reported that it's not working. Thanks.
[edit] Tested the above-mentioned monkey-patching with bind, tcpdump still shows traffic through a different interface. Fixed formatting.