Curl custom DNS Resolve

Jbn1233
1 min readApr 27, 2020

--

Sometime I need to validate SSL certificate from internal network with Curl.

Example:

I wanted to Curl to Google public ip “172.217.194.94” with specific DNS

www.google.co.uk => 172.217.194.94

There are many ways to do it. e.g. fixed hosts file or curl with host header ,but I prefer curl — resolve

$ curl -v --resolve www.google.co.uk:443:172.217.194.94 -sS -o /dev/null --write-out '%{http_code}' https://www.google.co.uk
* Added www.google.co.uk:443:172.217.194.94 to DNS cache
* Rebuilt URL to: https://www.google.co.uk/
* Hostname www.google.co.uk was found in DNS cache
* Trying 172.217.194.94...
* TCP_NODELAY set
* Connected to www.google.co.uk (172.217.194.94) port 443 (#0)
...
...
...

Done.

--

--

Jbn1233
Jbn1233

Written by Jbn1233

Very short and simple notes for CKA/SRE and may not works on your environment | jbn1233@gmail.com | Bangkok, Thailand |

No responses yet