Overriding DNS in curl

Often I’ll run into a situation where I need to make an HTTP request for a host name against a server that is at a different IP address than the one the host name resolves to. A common reason for this is to test out changes against a sandbox before deploying the change to production.

One way to deal with this in curl is with the --resolve option. Here is a simple example:

curl – resolve

Internally curl will make sure that resolves to for the purposes of that request. No need to mess around with hosts files or anything else.

For more suggestions in this area check out curl another host.