#TIL : Curl override Name Resolution with specific IP address

You can overrride the Name Resolution with specific IP address without adding the hostname to /etc/hosts file by using --resolve option.

Syntax :

--resolve <host:port:address>

It will resolve IP address when connect to host on port

Example :

This will connect

$ curl --resolve google.com:80: "http://google.com/"

But this won’t connect, because we use 443 port for https

$ curl --resolve google.com:80: "https://google.com/"

For cover all ports, use * wildcard

$ curl --resolve google.com:*: "https://google.com/"

#TIL : View DNS history of a domain

You can check the history of a domain (A Record). It’s useful in case you forgot the old IP of domain.

Check it here : http://viewdns.info/iphistory/

Example : this is Github A record history http://viewdns.info/iphistory/?domain=github.com

#TIL : Setup wildcard domains .test for development in MacOS

Too tired of setting your local domain each time you create new virtual development domain, etc helloworld.test, unit.test point to

There is a better way to achieve that by using dnsmasq, then set up a wildcard domains for development. In this case I use .test because .dev has been owned by Google and they strictly use HTTPS in mainly browsers.

Install dnsmasq

$ brew install dnsmasq

Adding .test wildcard to config file

$ echo 'address=/.test/' > $(brew --prefix)/etc/dnsmasq.conf

Setup dnsmasq as a startup service

$ sudo brew services start dnsmasq

Then add (dnsmasq IP) as first DNS resolver

System Preferences > Network > Wi-Fi > Advanced... > DNS > add > move it to top of the list.

Checking everything is worked by listing all resolvers

$ scutil --dns

Try it out

$ nslookup -type=a something.test
$ ping helloworld.test

#TIL : Flush DNS cache on iOS device

There are 2 simple ways to clear DNS cache on iOS devices :

  1. (FASTER) Just enable the Airplane Mode, wait 10 seconds and disable it
  2. (SLOWER) Reboot the device ! ;) You know this always be classic answer for many questions :D

#TIL : Getting your external IP

We can get our external IP address by following ways :

  1. Call http request : curl http://wtfismyip.com/text or curl http://ifconfig.me/ip
  2. Lookup A record for hostname nslookup myip.opendns.com resolver1.opendns.com (this only works when you use resolver of OpenDNS)

Bonus : curl https://v6.ident.me/ for IPv6