Tuesday, 12 February 2019

PycURL send DNS traffic through particular interface

I have multiple interfaces on the box and want to force the traffic through particular interface using python.

Following thread answers how to do that for HTTP traffic. Send http request through specific network interface

But when I look at tcpdump, the DNS queries do not honor the interface setting. libcurl provides following options to do the same.

https://curl.haxx.se/libcurl/c/CURLOPT_DNS_INTERFACE.html

https://curl.haxx.se/libcurl/c/CURLOPT_DNS_LOCAL_IP4.html

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 pycurl version result in following err:

AttributeError: DNS_INTERFACE AttributeError: DNS_LOCAL_IP4

I am trying monkey patching suggested here. But based on the comments, other people already reported that it's not working.

Requests, bind to an ip

Thanks.



from PycURL send DNS traffic through particular interface

No comments:

Post a Comment