>_ IzzyLab

Hands-on task

This task is step 10 of the course “Networking and HTTP from the terminal”

curl --resolve: bypass DNS

medium~5 min

A local server on port 8080 serves a page only when it is addressed by the name shop.local. Reach it as http://shop.local:8080/, without touching /etc/hosts: force shop.local to resolve to 127.0.0.1 using curl's own means. Save the response body to /root/body.txt.

What you'll practise:
  • curl
  • --resolve
  • dns
  • virtual host
  • host header

Topic breakdown

curl's --resolve flag overrides name resolution for a specific request without touching /etc/hosts or real DNS: you give a name-port-address triple, and curl goes to the specified IP but sends the original name in the Host header. This lets you reach a virtual host by a domain that isn't in DNS yet. The response body needs to be saved here, so instead of discarding it, it's redirected to a file.

What's checked

  1. body received via --resolve
  2. /etc/hosts is unchanged

What it looks like