Tuesday, January 5, 2010

how to use nslookup

I have just wrote a post about how to install nslookup, but what is nslooup?

well, according to wikipedia it is

"nslookup is a computer program used in Windows and Unix to query Domain Name System (DNS) servers to find DNS details, including IP addresses of a particular computer, MX records for a domain and the NS servers of a domain. The name nslookup means "name server lookup". The most common version of the program is included as part of the BIND package. More modern alternatives to nslookup are the "host" and "dig" programs which also ship with BIND. Both nslookup and dig look up nameserver information from /etc/resolv.conf."

This is a very useful tool for system and network administrators, and helps a lot when you are having DNS problems and while troubleshooting them.

There are two ways to use nslookup, directly on the command line, and using its interactive mode.

Command line mode

Enter it in this form

nslooup [server][ip]

[user@myhost ~]$ nslookup www.go2linux.org Server:         4.2.2.2 Address:        4.2.2.2#53  Non-authoritative answer: Name:   www.go2linux.org Address: 97.107.133.237 

First it tells you which DNS server it is using, next, it gives you the information it got from that server, giving you the IP address of the server www.go2linux.org

In the interactive mode you have more options, for example.

[ggarron@myhost ~]$ nslookup > set type=mx > gmail.com  Server:         200.87.61.83 Address:        200.87.61.83#53  Non-authoritative answer: gmail.com       mail exchanger = 40 alt4.gmail-smtp-in.l.google.com. gmail.com       mail exchanger = 5 gmail-smtp-in.l.google.com. gmail.com       mail exchanger = 10 alt1.gmail-smtp-in.l.google.com. gmail.com       mail exchanger = 20 alt2.gmail-smtp-in.l.google.com. gmail.com       mail exchanger = 30 alt3.gmail-smtp-in.l.google.com.  Authoritative answers can be found from: gmail.com       nameserver = ns1.google.com. gmail.com       nameserver = ns2.google.com. gmail.com       nameserver = ns3.google.com. gmail.com       nameserver = ns4.google.com. ns1.google.com  internet address = 216.239.32.10 ns2.google.com  internet address = 216.239.34.10 ns3.google.com  internet address = 216.239.36.10 ns4.google.com  internet address = 216.239.38.10 

As you can see, I have typed set type=MX which tells nslookup to inform about Mail eXchange servers, instead of the A records.

You can use set type=NS or with any other of the valid records in DNS, such as CNAME, A, NS, MX, etc.

read the man page of nslookup, and you will get more info about it.

No comments: