You can overrride the Name Resolution with specific IP address without adding the hostname to /etc/hosts file by using --resolve
option.
Syntax :
--resolve <host:port:address>
It will resolve IP address when connect to host on port
Example :
This will connect 127.0.0.1
$ curl --resolve google.com:80:127.0.0.1 "http://google.com/"
But this won't connect 127.0.0.1, because we use 443 port for https
$ curl --resolve google.com:80:127.0.0.1 "https://google.com/"
For cover all ports, use *
wildcard
$ curl --resolve google.com:*:127.0.0.1 "https://google.com/"