So here we wil learn about NSLOOKUP (Name Server Lookup) and we will see some of it’s examples.
So we will start with, What is nslookup
nslookup is the tool which lets you the enter the host-name or domain name and see it’s corresponding IP address. It also lets you to pass IP address and get corresponding hostname. (reverse DNS)
Installation, if your CentOS machine says nslookup command not found.
[root@server /]# nslookup google.com -bash: nslookup: command not found
so here you will have to Install bind-utils to get nslookup command. Simply run yum install bind-utils to take advantage of nslookup command.
[root@server /]# yum install bind-utils
nslookup command examples.
nslookup command followed by domain/hostname will display IP address of the domain.
[root@server /]# nslookup unix.com Server: 22.214.171.124 Address: 126.96.36.199#53 Non-authoritative answer: Name: unix.com Address: 188.8.131.52
You can use -type option to get various dns details. For example to get MX records.
[root@server /]# nslookup -type=mx redhat.com Server: 184.108.40.206 Address: 220.127.116.11#53 Non-authoritative answer: redhat.com mail exchanger = 10 us-smtp-inbound-2.mimecast.com. redhat.com mail exchanger = 10 us-smtp-inbound-1.mimecast.com.
To get nameserver of the domain.
[root@server /]# nslookup -type=ns google.com Server: 18.104.22.168 Address: 22.214.171.124#53 Non-authoritative answer: google.com nameserver = ns3.google.com. google.com nameserver = ns2.google.com. google.com nameserver = ns1.google.com. google.com nameserver = ns4.google.com.
[root@server /]# nslookup 126.96.36.199 188.8.131.52.in-addr.arpa name = origin-www2.redhat.com. Authoritative answers can be found from:
To get Information using specific DNS server.
[root@server /]# nslookup redhat.com ns1.redhat.com Server: ns1.redhat.com Address: 184.108.40.206#53 Name: redhat.com Address: 220.127.116.11
we have used the ns1.redhat.com as the DNS server. Here you may notice that, we don’t get any “Non-authoritative answer:” header, since ns1.redhat.com has all the zone information of redhat.com