Technical: DNS – Query for Name Server (NS) – On Linux\CentOS Using Dig

Technical: DNS – Query for Name Server (NS) – On Linux\CentOS Using Dig

 

Install

Install – whois

Install whois:

sudo yum -y install jwhois

 

Install – dig

As Dig is part of the bind-utils, install bind-utils

sudo yum -y install bind-utils

 

 

 

Using Dig

On Linux, we can use dig to query for Name Servers.

Using Dig – Query System’s default Name Server

Syntax:

dig  NS <domain-name> +noall +answer

 

Sample:

dig  NS youtube.com +noall +answer

 

Output:

DigQueryForNameServer

Explanation:

In the example above, we are querying the system’s default Name Server.  And, asking it for the authoritative nameservers for the youtube.com domain.

 

Using Dig – Target specific name server

In case something is wrong with our default named server or our default Named Server has been configured not to forward DNS Queries, we can target another DNS Server.

 

Syntax:

dig  @NS <domain-name> NS +noall +answer

 

Sample:

dig  @68.94.156.1 bbc.co.uk  NS +noall +answer +stats

 

Output:

DigQueryForNameServer- target specific server

 

Explanation:

In the example above, we are specifically targeting an AT&T named server (68.94.156.1) and querying for bbc.co.uk domain NameServers.

We do not really need the stats answer block (Query time, Server, when), but included it so that we can confirm that our result came from the specific server that we requested that it comes from.

To exclude stats data, remove +stats or add nostats.

 

 

Using Dig – Query DNS Server (and got back SERVFAIL)

Using dig, query DNS Server and we are getting back SERVFAIL.

Syntax:

dig  <domain-name> NS

 

Sample:

dig notfullysetup.org NS

 

Output:

Image:

dig -- SERVFAIL

Textual:



[dadeniji@adelia tmp]$ dig NS notfullysetup.org

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> NS 
notfullysetup.org

;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 6679
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;notfullysetup.org. IN NS

;; Query time: 42 msec
;; SERVER: 68.87.66.196#53(68.87.66.196)
;; WHEN: Mon Apr 28 10:23:04 2014
;; MSG SIZE rcvd: 33

[dadeniji@adelia tmp]$ 

 

Explanation:

In the example above, we are querying a DNS Server and getting back an error status, specifically SERVFAIL.

SERVFAIL means that an authoritative server is registered, but it is unreachable or faulty.

 

Using Dig – Query DNS Server tracing delegation path

Using dig, query DNS Server and note the delegation path.

Syntax:

dig  <domain-name> +trace

 

Sample:

dig notfullysetup.com +trace

 

Output:

[dadeniji@adelia tmp]$ dig NS notfullysetup.com +trace

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6_4.6 <<>> NS notfullysetup.org +trace

;; global options: +cmd
. 319385 IN NS h.root-servers.net.
. 319385 IN NS m.root-servers.net.
. 319385 IN NS e.root-servers.net.
. 319385 IN NS i.root-servers.net.
. 319385 IN NS g.root-servers.net.
. 319385 IN NS j.root-servers.net.
. 319385 IN NS a.root-servers.net.
. 319385 IN NS l.root-servers.net.
. 319385 IN NS d.root-servers.net.
. 319385 IN NS b.root-servers.net.
. 319385 IN NS k.root-servers.net.
. 319385 IN NS c.root-servers.net.
. 319385 IN NS f.root-servers.net.
;; Received 496 bytes from 68.87.66.196#53(68.87.66.196) in 727 ms

com. 172800 IN NS k.gtld-servers.net.
com. 172800 IN NS l.gtld-servers.net.
com. 172800 IN NS h.gtld-servers.net.
com. 172800 IN NS g.gtld-servers.net.
com. 172800 IN NS m.gtld-servers.net.
com. 172800 IN NS d.gtld-servers.net.
com. 172800 IN NS j.gtld-servers.net.
com. 172800 IN NS f.gtld-servers.net.
com. 172800 IN NS b.gtld-servers.net.
com. 172800 IN NS i.gtld-servers.net.
com. 172800 IN NS c.gtld-servers.net.
com. 172800 IN NS e.gtld-servers.net.
com. 172800 IN NS a.gtld-servers.net.
;; Received 505 bytes from 2001:7fe::53#53(2001:7fe::53) in 1038 
ms

notfullysetup.com. 172800 IN NS ns1.notfullysetup.com.
notfullysetup.com. 172800 IN NS ns2.notfullysetup.com.

dig: couldn't get address for 'ns1.notfullysetup.com': no more

[dadeniji@adelia tmp]$ 


 

Explanation:

In the case listed above we asked for a trace on what dig did, and it says that the root servers were queried and returned our ns1 and ns2 name servers.

But, we were unable to get the address for ns1.

Upon taking a second look, you might also notice that the first query went to the root servers and we were referred to the gtld-servers.net servers.

Keep in mind that *.gltd-servers.net servers are authoritaive for .com top level domain.

 

Who Is

As one plays more with dig, you might find it important to make sure that your NameServers are properly recorded, as well.

The whois utility provides a nice complement to dig.
Syntax:

whois <domain-name>

 

Sample:

whois wordpress.com | egrep 'Name Server'

 

Output:

whoIs

 

 

Helpful Hints

Helpful Hints – When specifying Name Server

When specifying Name Server using @NS, see if you can use IP Address , as the initial DNS resolution for NS might itself fail.

Helpful Hints – When querying for specific Name, place a period at end of full name

When querying for a specific name, please place a period at end of the name to indicate that the default name (resolv.conf in linux) not be appended to the hostname.

 

References

References – Installation

 

References – DNS Examples

References – DNS TroubleShooting

 

References – DNS TroubleShooting – Trace

 

References – DNS – Q&A

 

 

2 thoughts on “Technical: DNS – Query for Name Server (NS) – On Linux\CentOS Using Dig

  1. Hello very nice web site!! Guy .. Excellent .. Superb ..
    I’ll bookmark your web site and take the feeds also? I’m glad to
    search out a lot of helpful information here within the submit, we’d like
    develop more techniques in this regard, thanks for sharing.
    . . . . .

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s