nslookup

nslookup is a command-line tool to query IP addresses and DNS records.

With nslookup tool you can query IP addresses and carry out lookups on DNS records such as finding MX records for a domain.

Use cases

The use cases of nslookup are multiple:

  • Troubleshoot server connections and DNS related issues.
  • Query DNS records to confirm values are correct (i.e. MX records have been added correctly)

Examples

Find IP address

Use nslookup to find the A record of a domain to find the domain's IP address:

$ nslookup my_domain_name.com

If your domain is google.com, the nslookup output should be:

Server: 192.168.224.1
Address: 192.168.224.1#53

Non-authoritative answer:
Name: google.com
Address: 216.58.223.206
Name: google.com
Address: 2c0f:fb50:4003:802::200e

nslookup example of output results

Find NS records

Use nslookup to display the NS records (name server records) of a specified domain:

$ nslookup -type=ns my_domain_name.com

Example of output (in our example, we use google.com):

Server: 192.168.224.1
Address: 192.168.224.1#53

Non-authoritative answer:
google.com  nameserver = n54.google.com.
google.com  nameserver = ns1.google.com.
google.com  nameserver = ns2.google.com.
google.com  nameserver = ns3.google.com.
Name: n54.google.com
Address: 216.239.38.10
Name: n54.google.com
Address: 2001:4860:4802:38::a
Name: ns1.google.com
Address: 216.239.32.10
Name: ns1.google.com
Address: 2001:4860:4802:32::a
Name: ns2.google.com
Address: 216.239.34.10
Name: ns2.google.com
Address: 2001:4860:4802:34::a
Name: ns3.google.com
Address: 216.239.36.10
Name: ns3.google.com
Address: 2001:4860:4802:36::a

Authoritative answers can be found from:

nslookup example of ns name servers output results

Find MX records

Use nslookup to display the MX records for a specified domain:

$ nslookup -type=mx my_domain_name.com

Find SOA records

Use nslookup to display the SOA records for a specified domain:

$ nslookup -type=soa my_domain_name.com

Example of output (in our example, we use google.com):

Server: 192.168.224.1
Address: 192.168.224.1#53

Non-authoritative answer:
google.com
    origin = ns1.google.com
    mail addr = dns-admin.google.com
    serial = 483332882
    refresh = 900
    retry = 900
    expire = 1800
    minimum = 60
Name: ns3.google.com
Address: 216.239.36.10
Name: ns3.google.com
Address: 2001:4860:4802:36::a
Name: ns4.google.com
Address: 216.239.38.10
Name: n54.google.com
Address: 2001:4860:4802:38::a
Name: ns1.google.com
Address: 216.239.32.10
Name: ns1.google.com
Address: 2001:4860:4802:32::a
Name: ns2.google.com
Address: 216.239.34.10
Name: ns2.google.com
Address: 2001:4860:4802:34::a

Authoritative answers can be found from:

nslookup example of SOA authorative output results

Find TXT records

Use nslookup to display the TXT records for a specified domain:

$ nslookup -type=txt my_domain_name.com

Example of output (in our example, we use google.com):

Server: 192.168.224.1
Address: 192.168.224.1#53

Non-authoritative answer:
google.com  text = "webexdomainverification.8X6G=6e6922db-e3e6-4a36-904e-a805c28087fa"
google.com  text = "apple-domain-verification=30afIBcvSuDV2PLX"
google.com  text = "onetrust-domain-verification=de01ed21f2fa4d8781cbc3ffb89cf4ef"
google.com  text = "v-spf1 include:_spf.google.com ~all"
google.com  text = "MS=E4A68B9AB2BB9670BCE15412F62916164C0B20BB"
google.com  text = "atlassian-domain-verification-5YjTmlmjI92ewqkx20XmBaD60Td9zWon9r6eakvHX6B77zzkFQto8PQ9QsKnbfAI"
google.com  text = "facebook-domain-verification=22rm551cu4k@abebxsw536t]ds4h95"
google.com  text = "docusign-05958488-4752-4ef2-95eb-aa7ba8a3bd@e"
google.com  text = "docusign-1b036754-49b1-4db5-8540-d2c12664b289"
google.com  text = "globalsign-smime-dv=CDYX+XFHUw2wm16/Gb8+59BSH31KzUr6c112BPvaKX8="
google.com  text = "google-site-verification-wD8N711JTNTkez349swvWWw48f8_9xVeREV4OB-OHf50'
google.com  text = "google-site-verification-TV9-DBe480X4vaMAU_bd_J9cpOJMenikftejAgjmsQ"

Authoritative answers can be found from:

nslookup example of TXT records output results