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