Testing a new connection destination without changing DNS using curl –resolve

ネットワーク・RFCカテゴリを表すパンダのイラスト Networking / RFC

About this article
This article was created using an automated generation workflow powered by generative AI. Based on the official curl documentation, we organized --resolve as a safe verification procedure to temporarily override only the destination IP for a specific hostname without changing DNS settings.

Verification status: 📘 Confirmed with official curl specifications – actual communication not verified

When verifying before switching a web server, you can use curl --resolve to specify the connection destination for only that single curl execution, without needing to change the hosts file or DNS for the entire PC.

First, let's look at how it works

curl -I --resolve example.com:443:93.184.216.34 https://example.com/

--resolve passes the mapping for host:port:address to curl. What we check here are the HTTP response and the presence of any TLS errors.

*The IP address above is for illustrative purposes only. In actual testing, use the verification IP provided officially by the target service or one that you manage. Avoid experiments that point unrelated hostnames to third-party servers.

Try changing one location

Keeping the same URL, change only the address to the IP of the server under test. This allows you to verify whether the new server responds as expected before making the DNS public.

Why it is easier to isolate issues than modifying the hosts file

Modifying the OS hosts file affects other browsers and applications as well.--resolve applies only to that specific curl execution, keeping the test scope narrow. There is also no risk of forgetting to revert the hosts file afterward.

When TLS fails

With HTTPS, certificate hostname verification is also performed.-k / --insecure If you carelessly bypass this with , you might overlook the certificate verification required in production. First, check the certificate, SNI, and virtual host configuration.

When using it for work

It is useful for pre-checks during web migrations, load balancer switches, CDN changes, and new Nginx backend rollouts. It is ideal for troubleshooting scenarios such as wanting to access a new IP via HTTPS with a Host header while DNS still points to the old system.

Official and Primary Sources

Document information

Article title
Testing a new connection destination without changing DNS using curl –resolve
Published
Updated
Source
https://papanda925.com/?p=15999&lang=en

License: Text and original figures for which this site holds the relevant rights are available under CC BY 4.0 , unless otherwise noted. This article may include content created or edited with generative AI. If code has a separate license notice or a linked GitHub repository license, that license takes precedence for the code. Quotations, third-party materials, images, and trademarks are excluded from this license. Usage policy

Copied title and URL