Commit f9983b21 authored by Jamie Tanna's avatar Jamie Tanna

Document `curl --resolve`

Closes #923.
parent 56dd41fe
Pipeline #122651443 passed with stages
in 8 minutes and 23 seconds
title: "How to Use `curl` to Send Requests to Domains Without Editing Your `/etc/hosts` File"
description: "Using `curl`'s `--resolve` flag to perform custom lookup for hosts."
- blogumentation
- command-line
license_code: Apache-2.0
license_prose: CC-BY-NC-SA-4.0
date: 2020-03-02T21:49:40+0000
slug: "curl-without-hosts"
Sometimes you need to make requests to sites, but don't want to allow regular DNS lookups for the host. For instance, you may have a passive/side stack you need to test against, but can't get it working without the official DNS working.
Usually, the solution would be to update `/etc/hosts`, and hardcode the IP address. But that requires `root` privileges, and there's always the risk that you forget you made the change, resulting in pain in the future!
What we can do from curl v7.21.3 is use the `--resolve` flag, which allows forcing curl to not perform lookups, and instead use the IP address provided.
$ curl -i --resolve
Note that you need the port number in there!
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment