curl --resolve option not working: "Hostname was NOT found in DNS cache"
After trying this with other domain names, I found that the issue was being caused by the domain names not matching in the --resolve
option and the URL (one had www
, the other didn't). User error!
Incorrect:
curl -s -S -I -H "Host: example.com" --resolve example.com:80:1.1.1.1 --verbose http://www.example.com/
Correct:
curl -s -S -I -H "Host: example.com" --resolve example.com:80:1.1.1.1 --verbose http://example.com/
Related videos on Youtube
user3018905
Email: [email protected] Twitter: @iglvzx LinkedIn: israelgalvez Free Software Foundation Member #9943 Technical Support Hero. Developer behind GWhois.org - the most advanced Whois client in the world! Live, authoritative Whois lookups for domain names and IP addresses, DNS tools, and more!
Updated on September 18, 2022Comments
-
user3018905 over 1 year
I am attempting to use curl's
--resolve
option to connect to the specified IP address when performing the HTTP request, but curl keeps reverting back to the IP address as retrieved by my local DNS cache/resolver.Command:
curl -s -S -I -H "Host: example.com" --resolve example.com:80:1.1.1.1 --verbose http://example.com/
(where
example.com
is replaced by my domain name, and1.1.1.1
replaced by the desired destination IP address)Result:
* Added example.com:80:1.1.1.1 to DNS cache * Hostname was NOT found in DNS cache * Trying 2.2.2.2... * Connected to example.com (2.2.2.2) port 80 (#0) > HEAD / HTTP/1.1 > User-Agent: curl/7.35.0 > Accept: */* > Host: example.com
(where
2.2.2.2
is replaced by the IP address cached in my local DNS resolver for my domain name)So, it looks like curl attempts to add
1.1.1.1
to the DNS cache forexample.com
, but fails somehow and reverts back to original IP address.Any ideas on how to fix this problem or troubleshoot further to find out why its not working?