curl without modifying the hosts file⚓︎
You can provide curl 7.21.3+ custom addresses for any host and port pair, forcing curl requests use a specified address and prevent the otherwise normally resolved address to be used. For each host:port pair you want to override you specify
--resolve <host:port:address>, where the ‘*’ wildcard can be used as a host to resolve all DNS to the specified IP.
# perform a curl to google.com:443 and resolve to 22.214.171.124 (CloudFlare) curl --resolve google.com:443:126.96.36.199 -k https://google.com # perform a curl to any DNS and redirect to 188.8.131.52 (CloudFlare) curl --resolve *:443:184.108.40.206 -k https://google.com