April 2, 2016

Linux – The dig command

You can use the nslookup command to find what ip address a url resolves to. But another way to do this is by using the dig command:


You can find all my latest posts on medium.
$ dig +short
{list of ip address}

This gives a list of ip addresses, since website is load-balanced across several servers.

To find which dns servers gave this resolution info, do:

$ dig ns +short
{list of urls}

These are the urls of dns servers.

If you want to find out what a server’s fqdn is, then do:

$ dig -x {ip-addr}

This will give the same info that you would get if you had ssh’d into the server and ran the ‘hostname’ command.

Also you can specify what dns server to use when using dig:

$ dig @ 

This is using google’s dns. If you want to use your company’s internal dns, then do:

$ dig @{internal-dns}