On some Linux distributions, the nslookup command will not be installed. On a Debian distribution (Debian, Mint, Ubuntu), the apt-get command can be used to install the bind-utils package, which includes nslookup. On a Red Hat distrubtion (CentOS, Fedora, Red Hat), the dnf or yum command can be used.
On a Red Hat distrubution (CentOS, Fedora, Red Hat), the yum install or dnf install command can be used to install the bind-utils package. On a Debian distribution (Mint, Ubuntu), the apt-get install command can be used.
dnf 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
Did you find this article helpful?
If so, consider buying me a coffee over at