At The Engaging News Project, we recently upgraded our DNS hosting by moving over to Cloudflare. I wanted to test our site as soon as the nameservers updated to Cloudflare’s to make sure no weird issues popped up.

Fortunately, there’s a handy terminal command for that!

$ nslookup -type=ns

nslookup is a command to query nameservers and get all kinds of info back related to the server it’s on and any DNS settings you want to… look-up. Pretty well named command, I guess.

In our case, the nslookup -type=ns command will return all the nameservers of my site,

As of this writing, here’s the response for my domain.

$ nslookup -type=ns


Non-authoritative answer:	nameserver =	nameserver =	nameserver =

To get different information about your DNS, like CNAME, MX, A Records, etc, just change out the ns part of -type=ns with the record type you’re looking for:

$ nslookup -type=cname 
$ nslookup -type=a 
$ nslookup -type=mx 

There’s plenty more nslookup can do that I imagine I’ll never, ever use as a front-end developer, but I’m glad it’s there if I need it.

Clearing out DNS

If you just made a DNS change and want to flush your cache to try to grab the updated nameservers and you’re on OS X 10.10.4 or above, use:

sudo killall -HUP mDNSResponder

Switching servers of any kind is stressful. Hopefully these commands will help your heart beat a little easier when making the switch.