Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
cURL: Selecting a custom DNS server to resolve domain names
#!/usr/bin/env bash
# this can be useful when developing against a custom DNS server, or
# for example, if you made a change to the DNS settings of a domain, and you
# know the authoritative nameserver IP address for a domain, you could use this
# to bypass the intermediate DNS cache, and apply an HTTP request using the new
# DNS settings supplied by your specified (authoritative) nameserver
curl --dns-servers <dns.ip,dns.ip> url.com
# acquire the nameserver using
dig url.com NS
# then ping the NS to get its IP address
@LouWii

This comment has been minimized.

Copy link

LouWii commented Mar 23, 2017

Ugh, it might not work depending on your libcurl curl: (4) A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision.

@icasimpan

This comment has been minimized.

Copy link

icasimpan commented Dec 21, 2017

I am also hitting this limitation which is quite common and I found an alternative which is to use --resolve:
curl --resolve domain:port:ip url.com

Example, for https://www.google.com:

curl --resolve www.google.com:443:172.217.10.132 www.google.com

@matthayter

This comment has been minimized.

Copy link

matthayter commented Jan 31, 2018

For Mac and homebrew users: you can have brew compile curl for you with the --dns-servers option enabled via:

brew install curl --with-c-ares

@patrick-webs

This comment has been minimized.

Copy link

patrick-webs commented Aug 31, 2018

For MacPorts users,

sudo port install curl +ares

to get this feature.

@SalimF

This comment has been minimized.

Copy link

SalimF commented Dec 17, 2018

I got this error
A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.