Close

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:

$ dig google.com +short
{list of ip address}

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

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

$ dig google.com 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 https://example.com @8.8.8.8 

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

$ dig https://example.com @{internal-dns}