cURL / Mailing Lists / curl-library / Single Mail


Re: Make DNS requests follow the CURLOPT_INTERFACE if c-ares is in use

From: Kim Vandry <vandry_at_TZoNE.ORG>
Date: Sat, 07 Sep 2013 13:51:50 -0400

On 2013-07-22 12:26 , Kim Vandry wrote:
> On 2013-07-18 15:14 , Daniel Stenberg wrote:
>> On Thu, 18 Jul 2013, Daniel Stenberg wrote:
>>>>> * b9f0e44 curl: Add support for various DNS binding options.
> [...]
>> It does a nasty include of "../lib/inet_pton.h" which is incorrect in
>> several ways. curl cannot include libcurl internal headers with a direct
>> path like that and it shouldn't include libcurl private headers at all
>> (if it isn't a curlx* function). I see this code uses Curl_inet_pton()
>> which is an internal libcurl function that shouldn't be used like this
>> from curl even though I see you've added the source file to the curl
>> build. It should be made into a curlx_ version if that should remain so.
> Thanks for the explanation. If the change below if made, I think this
> use of inet_pton in the curl tool may no longer be necessary.
>> I do however think that you should make CURLOPT_DNS_LOCAL_IP* accept a
>> string of the IP address and do the conversion to binary within libcurl
>> and not in the application. Seems more in line with similar other
>> libcurl options too.
> I actually agree with this, and mentioned already that I wasn't fully
> comfortable with the current interface. Once again, the reason is that
> it is a thin layer over the existing c-ares interface.
> I will change it as you suggest.

Hi Daniel,

I have addressed both of these issues by making the new options take
strings instead of binary IP addresses.

Please find two patches at , one for
libcurl and one for the command line tool.

commit a57d4506a7adcb0750411e7be46953376927a0cd
Author: Ben Greear <>
Date: Sat Feb 9 13:18:02 2013 -0800

     curl: Add support for various DNS binding options.

     (Passed on to c-ares.)

     Allows something like this:

     curl --dns-interface sta8 --dns-ipv4-addr --interface
sta8 --localaddr --dns-servers

     Signed-off-by: Ben Greear <>

commit 5cd18e2cff4976392fcbfebd69cb4ccdda762330
Author: Kim Vandry <vandry_at_TZoNE.ORG>
Date: Sat Sep 7 12:45:50 2013 -0400

     libcurl: New options to bind DNS to local interfaces or IP addresses

List admin:
Received on 2013-09-07