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 220.127.116.11 (CloudFlare) curl --resolve google.com:443:18.104.22.168 -k https://google.com # perform a curl to any DNS and redirect to 22.214.171.124 (CloudFlare) curl --resolve *:443:126.96.36.199 -k https://google.com