Learn a Linux command every day (69): NSLOOKUP

Time:2021-6-13

Recommended reading:Learn a Linux command every day (68): lsof

Command introduction

NSLOOKUP (name server lookup) is a tool for querying DNS information of domain names. NSLOOKUP has two working modes: interactive mode and non interactive mode.

[[email protected] ~]# nslookup
-bash: nslookup: command not found
[[email protected] ~]# yum install -y bind-utils

Grammatical format

nslookup [-option] [name | -] [server]

Option description

-query=TYPE       # Set query type
-timeout=NUMBER   # Set the timeout for waiting for a response, in seconds
-sil              # No warning message is displayed.

There are also some interactive commands. Interested readers can view the help information to read.

Application examples

example

Non interactive mode
[[email protected] ~]# nslookup www.baidu.com
Server:  223.5.5.5
Address: 223.5.5.5#53
Non-authoritative answer:
www.baidu.com canonical name = www.a.shifen.com.
Name: www.a.shifen.com
Address: 36.152.44.96
Name: www.a.shifen.com
Address: 36.152.44.95
#Interactive mode
[[email protected] ~]# nslookup
> baidu.com
Server:  223.5.5.5
Address: 223.5.5.5#53
Non-authoritative answer:
Name: baidu.com
Address: 39.156.69.79
Name: baidu.com
Address: 220.181.38.148
> 163.com
Server:  223.5.5.5
Address: 223.5.5.5#53
Non-authoritative answer:
Name: 163.com
Address: 123.58.180.7
Name: 163.com
Address: 123.58.180.8

Google.com related information

#Search your DNS for all available information related to the domain name google.com.
[[email protected] ~]# nslookup -type=any google.com
Server:  223.5.5.5
Address: 223.5.5.5#53
Non-authoritative answer:
Name: google.com
Address: 93.46.8.90
google.com nameserver = ns1.google.com.
google.com nameserver = ns2.google.com.
google.com nameserver = ns4.google.com.
google.com nameserver = ns3.google.com.
Authoritative answers can be found from:
#In your   DNS   Query and domain name in Internet   google.com   Information about the relevant mail exchange server
[[email protected] ~]# nslookup -type=mx google.com
Server:  223.5.5.5
Address: 223.5.5.5#53
Non-authoritative answer:
google.com mail exchanger = 10 aspmx.l.google.com.
google.com mail exchanger = 50 alt4.aspmx.l.google.com.
google.com mail exchanger = 20 alt1.aspmx.l.google.com.
google.com mail exchanger = 30 alt2.aspmx.l.google.com.
google.com mail exchanger = 40 alt3.aspmx.l.google.com.
Authoritative answers can be found from:

Looking up an address in reverse

[[email protected] ~]# nslookup 200.208.150.3
 
Server:         103.240.22.111
Address:        103.240.22.111#53
 
Non-authoritative answer:
3.150.208.200.in-addr.arpa      name = 200.208.150.3.xmission.com.
 
Authoritative answers can be found from:
150.208.200.in-addr.arpa        nameserver = ns1.xmission.com.
150.208.200.in-addr.arpa        nameserver = ns2.xmission.com.
150.208.200.in-addr.arpa        nameserver = ns.xmission.com.

Learn a Linux command every day (66): SS

Learn a Linux command every day (67): nmap