There is a --resolve
option in the curl utility that allows you to add a DNS entry and force a certain IP address when calling a host.
Since version 7.21.3 cURL allows specifying an IP address, thus forging the hostname for the request.
$ curl --resolve www.example.com:80:127.0.0.1 http://www.example.com/
The --resolve switch allows you to tell curl which address to request when it would resolve a given hostname. In the above snippet cURL uses 127.0.0.1 (localhost) instead of resolving www.example.com via DNS.
This option works correctly when used without an http proxy, the DNS entry is found in cache.
The problem is I would like to use this option simultaneously with the curl --proxy
parameter. When this last parameter is set, the DNS entry is not found when calling the same host.
$ curl --proxy 1.2.3.4:80 --resolve www.example.com:80:127.0.0.1 http://www.example.com/
Any idea how to get around this problem?
I have an idea that the proxy is using its own DNS cache and we can't change it but maybe I'm wrong ?
In case you have access to it you could also modify /etc/hosts in the proxy server.