Linux DNS server query tools

Linux command line programLinux has a few Domain Name System (DNS) server query tools that you can access via the command line. You can use these tools to test whether your domain name’s authoritative nameservers are responding correctly or not. Using them you can diagnose problems with DNS records.

Dig

Using dig is easy. A simple example to start with:

dig @ns1.example.com example.com A

In the above example we are querying the nameserver ns1.example.com for the A record for the domain name example.com. You can use dig to query nameservers for different record types. For example querying a nameserver for the Start of Authority record:

dig @ns1.example.com example.com soa

Or the NS record:

dig @ns1.example.com example.com NS

Dig has a lot of options. Type man dig to see the dig help file.

Nslookup

Before dig there was nslookup. It is still available on most Linux distributions as well as on Microsoft Windows. Using nslookup is easy:

nslookup example.com ns1.example.com

The above command will lookup the A record for the domain name example.com at the nameserver ns1.example.com.

You can also lookup specific record types using the -querytype switch:

nslookup -querytype=mx example.com ns1.example.com

Using dig and nslookup you can quickly query DNS servers via the shell.

Leave a Reply

Your email address will not be published. Required fields are marked *