Section H-6. nslookup and dig


H-6. nslookup and dig

nslookup, found on Unix and Windows systems, is used to get IP address information on a host, and vice versa:

 C:\>nslookup www.yahoo.com Server:  ns1.mindspring.com Address:  207.69.188.185   Non-authoritative answer: Name:    www.yahoo.akadns.net Addresses:  216.109.118.75, 216.109.118.77, 216.109.118.78, 216.109.118.79           216.109.118.65, 216.109.118.66, 216.109.118.69, 216.109.118.73 Aliases:  www.yahoo.com   C:\>nslookup 216.109.118.75 Server:  ns1.mindspring.com Address:  207.69.188.185   Name:    p12.www.dcn.yahoo.com Address:  216.109.118.75 

While nslookup has been widely used on Unix systems for many, many years, nslookup is being deprecated on Linux systems. Instead of nslookup, Linux systems now make use of a command called dig (dig stands for Domain Internet Groper).

Let's look at some example usage of dig:

 $ dig @69.15.40.52 www.yahoo.com   ; <<>> DiG 9.2.4 <<>> @69.15.40.52 www.yahoo.com ;; global options:  printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7406 ;; flags: qr rd ra; QUERY: 1, ANSWER: 9, AUTHORITY: 0, ADDITIONAL: 0   ;; QUESTION SECTION: ;www.yahoo.com.                 IN      A   ;; ANSWER SECTION: www.yahoo.com.          300     IN      CNAME   www.yahoo.akadns.net. www.yahoo.akadns.net.   60      IN      A       68.142.226.34 www.yahoo.akadns.net.   60      IN      A       68.142.226.56 www.yahoo.akadns.net.   60      IN      A       68.142.226.44 www.yahoo.akadns.net.   60      IN      A       68.142.226.45 www.yahoo.akadns.net.   60      IN      A       68.142.226.38 www.yahoo.akadns.net.   60      IN      A       68.142.226.47 www.yahoo.akadns.net.   60      IN      A       68.142.226.39 www.yahoo.akadns.net.   60      IN      A       68.142.226.43   ;; Query time: 239 msec ;; SERVER: 69.15.40.52#53(69.15.40.52) ;; WHEN: Mon May 16 08:13:18 2005 ;; MSG SIZE  rcvd: 193   $   

The @ value is optional. You could use a domain name or, as we did, an IP address. It specifies the name server to be queried. The second option is the host we want to look up.

Using the -x option with dig, you can get reverse name lookup:

 $ dig -x 68.142.226.34   ; <<>> DiG 9.2.4 <<>> -x 68.142.226.34 ;; global options:  printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51297 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0   ;; QUESTION SECTION: ;34.226.142.68.in-addr.arpa.    IN      PTR   ;; ANSWER SECTION: 34.226.142.68.in-addr.arpa. 1200 IN     PTR     p3.www.re2.yahoo.com.   ;; Query time: 79 msec ;; SERVER: 69.15.40.52#53(69.15.40.52) ;; WHEN: Mon May 16 08:13:47 2005 ;; MSG SIZE  rcvd: 78 

With the mx option, dig can be used to obtain the mail exchanger information for a domain:

 $ dig mx yahoo.com   ; <<>> DiG 9.2.4 <<>> mx yahoo.com ;; global options:  printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25 ;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0   ;; QUESTION SECTION: ;yahoo.com.                     IN      MX   ;; ANSWER SECTION: yahoo.com.              6557    IN      MX      1 mx3.mail.yahoo.com. yahoo.com.              6557    IN      MX      5 mx4.mail.yahoo.com. yahoo.com.              6557    IN      MX      1 mx1.mail.yahoo.com. yahoo.com.              6557    IN      MX      1 mx2.mail.yahoo.com.   ;; Query time: 1 msec ;; SERVER: 69.15.40.52#53(69.15.40.52) ;; WHEN: Mon May 16 08:14:26 2005 ;; MSG SIZE  rcvd: 112 

The soa option can be used to obtain zone authority information:

 $ dig soa yahoo.com   ; <<>> DiG 9.2.4 <<>> soa yahoo.com ;; global options:  printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41407 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0   ;; QUESTION SECTION: ;yahoo.com.                     IN      SOA   ;; ANSWER SECTION: yahoo.com.              1800    IN      SOA     ns1.yahoo.com. hostmaster.yahoo-inc.com. 2005051609 3600 300 604800 600   ;; Query time: 21 msec ;; SERVER: 69.15.40.52#53(69.15.40.52) ;; WHEN: Mon May 16 08:14:45 2005 ;; MSG SIZE  rcvd: 88 

See the manual page for more details on this powerful tool.




Essential SNMP
Essential SNMP, Second Edition
ISBN: 0596008406
EAN: 2147483647
Year: 2003
Pages: 165

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net