FreeKB - Linux Commands nslookup (name server looking DNS)
Linux Commands - nslookup (name server looking DNS)

Use apt-get or yum to install bind-utils, which contains the nslookup utility.

~]# yum install bind-utils

 

The nslookup command without any options will start an interactive prompt.

[root@server1 ~]# nslookup
>

 

The prompt expects a hostname to lookup. In this example, www.example.com is looked up.

[root@server1 ~]# nslookup
> www.example.com
Server:		192.168.0.6
Address:	192.168.0.6#53

Non-authoritative answer:
Name:	www.example.com
Address: 93.184.216.34
>

 

This can also be accomplished by typing nslookup followed by www.example.com.

[root@server1 ~]# nslookup www.example.com
Server:		192.168.0.6
Address:	192.168.0.6#53

Non-authoritative answer:
Name:	www.example.com
Address: 93.184.216.34

 

The first and second lines of the output list the IP address of the nameserver that is being used to resolve the hostname to an IP address. The IP address of the nameserver is retrieved from the /etc/resolv.conf file.

You may also want to enable querylog to append the DNS queries to /var/log/messages.

 


Specify a DNS name server

In this example, DNS name server ns1.example.com will be used to lookup up www.example.com. 

nslookup www.example.com ns1.example.com

 


server can't find NXDOMAIN

If server can't find NXDOMAIN is displayed, this means the nameserver cannot resolve the hostname to an IP address.

[root@server1 ~]# nslookup www.bogus.com
Server:		192.168.0.6
Address:	192.168.0.6#53

** server can't find www.bogus.com: NXDOMAIN

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter e076a in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |