Terminal Command for Looking up Nameservers

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.

By Jerry Jones

JavaScript Engineer for Automattic, living simply in rural MO.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s