linux下nslookup操作实例,查找域名的a记录、mx记录、cname记录、ns记录

说明:
以下是在linux下的操作实例,win下的nslookup操作实例请看附录1:win下的nslookup操作实例
nslookup有2种模式,交互模式、非交互模式

实例:
一、以下实例为nslookup非交互模式下操作
实例1:查找域名A记录

# nslookup coolnull.com
Server:		100.100.2.138
Address:	100.100.2.138#53

Non-authoritative answer:
Name:	coolnull.com
Address: 120.24.240.59

 
查找域名A记录
上面下面都一样,只是查询的时候多了-query=a,因为nslookup默认就是查询a记录,所以不写也一样。

# nslookup -query=a coolnull.com
Server:		100.100.2.138
Address:	100.100.2.138#53

Non-authoritative answer:
Name:	coolnull.com
Address: 120.24.240.59   ###这是解析出来coolnull.com对应的ip地址

 
实例2:查询域名A记录,指定dns服务器,通过在域名后指定dns服务器地址

# nslookup coolnull.com 8.8.8.8
Server:		8.8.8.8
Address:	8.8.8.8#53

Non-authoritative answer:
Name:	coolnull.com
Address: 120.24.240.59

 
实例3:查找MX记录

# nslookup -query=mx coolnull.com
Server:		100.100.2.138
Address:	100.100.2.138#53

Non-authoritative answer:
coolnull.com	mail exchanger = 10 mxbiz2.qq.com.     ###域名mx记录为mxbiz1.qq.com.、mxbiz2.qq.com.有用过qq免费域名邮箱的应该熟悉,当然还有mxdomain.qq.com.这个
coolnull.com	mail exchanger = 5 mxbiz1.qq.com.

Authoritative answers can be found from:
renjianrenai.net	nameserver = f1g1ns2.dnspod.net.
renjianrenai.net	nameserver = f1g1ns1.dnspod.net.
mxbiz1.qq.com	internet address = 163.177.89.176
mxbiz1.qq.com	internet address = 112.90.78.144
mxbiz2.qq.com	internet address = 112.90.78.144
mxbiz2.qq.com	internet address = 163.177.89.176
f1g1ns1.dnspod.net	internet address = 58.247.212.36
f1g1ns1.dnspod.net	internet address = 115.236.151.191
f1g1ns1.dnspod.net	internet address = 180.163.19.15
f1g1ns1.dnspod.net	internet address = 182.140.167.166
f1g1ns1.dnspod.net	internet address = 14.215.150.17
f1g1ns2.dnspod.net	internet address = 52.220.136.67
f1g1ns2.dnspod.net	internet address = 61.129.8.159
f1g1ns2.dnspod.net	internet address = 101.226.220.16
f1g1ns2.dnspod.net	internet address = 121.51.128.164
f1g1ns2.dnspod.net	internet address = 182.140.167.188

 
实例4:查找域名CNAME记录

# nslookup -query=cname www.baidu.com
Server:		100.100.2.138
Address:	100.100.2.138#53

Non-authoritative answer:
www.baidu.com	canonical name = www.a.shifen.com.    ###可以看到www.baidu.com是cname到www.a.shifen.com

Authoritative answers can be found from:
baidu.com	nameserver = ns3.baidu.com.
baidu.com	nameserver = ns7.baidu.com.
baidu.com	nameserver = ns2.baidu.com.
baidu.com	nameserver = dns.baidu.com.
baidu.com	nameserver = ns4.baidu.com.
dns.baidu.com	internet address = 202.108.22.220
ns2.baidu.com	internet address = 61.135.165.235
ns3.baidu.com	internet address = 220.181.37.10
ns4.baidu.com	internet address = 220.181.38.10
ns7.baidu.com	internet address = 180.76.76.92

 
实例5:查看域名NS(nameserver)记录

# nslookup -query=ns coolnull.com
Server:		100.100.2.138
Address:	100.100.2.138#53

Non-authoritative answer:
coolnull.com	nameserver = f1g1ns1.dnspod.net.    ###这边可以看到coolnull.com的ns地址为f1g1ns1.dnspod.net.和f1g1ns2.dnspod.net.,这是dnspod免费域名服务器的域名地址。
coolnull.com	nameserver = f1g1ns2.dnspod.net.

Authoritative answers can be found from:
f1g1ns1.dnspod.net	internet address = 180.163.19.15    ####dnspod免费域名服务器的域名对应的ip地址
f1g1ns1.dnspod.net	internet address = 182.140.167.166
f1g1ns1.dnspod.net	internet address = 14.215.150.17
f1g1ns1.dnspod.net	internet address = 58.247.212.36
f1g1ns1.dnspod.net	internet address = 115.236.151.191
f1g1ns2.dnspod.net	internet address = 61.129.8.159
f1g1ns2.dnspod.net	internet address = 101.226.220.16
f1g1ns2.dnspod.net	internet address = 121.51.128.164
f1g1ns2.dnspod.net	internet address = 182.140.167.188
f1g1ns2.dnspod.net	internet address = 52.220.136.67

 
二、以下实例为nslookup交互模式下操作
要进入nslooku交互模式只需要在命令行输入nslookup即可,更多参数可以查看这篇nslookup – man手册
实例1:查找域名A记录

# nslookup
> set query=a
> coolnull.com
Server:		100.100.2.138
Address:	100.100.2.138#53

Non-authoritative answer:
Name:	coolnull.com
Address: 120.24.240.59    ###这是解析出来coolnull.com对应的ip地址

 
实例2:查找MX记录

# nslookup
> set query=mx    ###set query=mx后,可以直接输入其它域名查找该域名的mx记录。不需要再重复set query=mx;当然如果要查找其它记录,如a记录,还是需要再set query=a
> coolnull.com
Server:		100.100.2.138
Address:	100.100.2.138#53

Non-authoritative answer:
coolnull.com	mail exchanger = 5 mxbiz1.qq.com.     ###域名mx记录为mxbiz1.qq.com.、mxbiz2.qq.com.
coolnull.com	mail exchanger = 10 mxbiz2.qq.com.

Authoritative answers can be found from:
renjianrenai.net	nameserver = f1g1ns2.dnspod.net.
renjianrenai.net	nameserver = f1g1ns1.dnspod.net.
mxbiz1.qq.com	internet address = 163.177.89.176
mxbiz1.qq.com	internet address = 112.90.78.144
mxbiz2.qq.com	internet address = 112.90.78.144
mxbiz2.qq.com	internet address = 163.177.89.176
f1g1ns1.dnspod.net	internet address = 14.215.150.17
f1g1ns1.dnspod.net	internet address = 58.247.212.36
f1g1ns1.dnspod.net	internet address = 115.236.151.191
f1g1ns1.dnspod.net	internet address = 180.163.19.15
f1g1ns1.dnspod.net	internet address = 182.140.167.166
f1g1ns2.dnspod.net	internet address = 61.129.8.159
f1g1ns2.dnspod.net	internet address = 101.226.220.16
f1g1ns2.dnspod.net	internet address = 121.51.128.164
f1g1ns2.dnspod.net	internet address = 182.140.167.188
f1g1ns2.dnspod.net	internet address = 52.220.136.67

 
实例3:查找域名CNAME记录

# nslookup
> www.baidu.com
Server:		100.100.2.138
Address:	100.100.2.138#53

Non-authoritative answer:
www.baidu.com	canonical name = www.a.shifen.com.    ###可以看到www.baidu.com是cname到www.a.shifen.com

Authoritative answers can be found from:
baidu.com	nameserver = ns4.baidu.com.
baidu.com	nameserver = ns2.baidu.com.
baidu.com	nameserver = ns3.baidu.com.
baidu.com	nameserver = dns.baidu.com.
baidu.com	nameserver = ns7.baidu.com.
dns.baidu.com	internet address = 202.108.22.220
ns2.baidu.com	internet address = 61.135.165.235
ns3.baidu.com	internet address = 220.181.37.10
ns4.baidu.com	internet address = 220.181.38.10
ns7.baidu.com	internet address = 180.76.76.92

 
实例4:查看域名NS(nameserver)记录

# nslookup
> set query=ns
> coolnull.com
Server:		100.100.2.138
Address:	100.100.2.138#53

Non-authoritative answer:
coolnull.com	nameserver = f1g1ns2.dnspod.net.    ###域名coolnull.com的ns地址
coolnull.com	nameserver = f1g1ns1.dnspod.net.

Authoritative answers can be found from:
f1g1ns1.dnspod.net	internet address = 115.236.151.191
f1g1ns1.dnspod.net	internet address = 180.163.19.15
f1g1ns1.dnspod.net	internet address = 182.140.167.166
f1g1ns1.dnspod.net	internet address = 14.215.150.17
f1g1ns1.dnspod.net	internet address = 58.247.212.36
f1g1ns2.dnspod.net	internet address = 182.140.167.188
f1g1ns2.dnspod.net	internet address = 52.220.136.67
f1g1ns2.dnspod.net	internet address = 61.129.8.159
f1g1ns2.dnspod.net	internet address = 101.226.220.16
f1g1ns2.dnspod.net	internet address = 121.51.128.164

 
附录:
附录1:附录1:win下的nslookup操作实例
win下的nslookup操作实例,查找域名的a记录、mx记录、cname记录、ns记录

附录2:以下为可用的查询类型,不区别大小写
A 地址记录(Ipv4)
AAAA 地址记录(Ipv6)
AFSDB Andrew文件系统数据库服务器记录(不懂)
ATMA ATM地址记录(不是自动提款机)
CNAME 别名记录
HINFO 硬件配置记录,包括CPU、操作系统信息
ISDN 域名对应的ISDN号码
MB 存放指定邮箱的服务器
MG 邮件组记录
MINFO 邮件组和邮箱的信息记录
MR 改名的邮箱记录
MX 邮件服务器记录,preference为优先级,该数值越小则优先级越高。
NS 名字服务器记录
PTR 反向记录(从IP地址解释域名)
RP 负责人记录
RT 路由穿透记录
SRV TCP服务器信息记录
TXT 域名对应的文本信息
X25 域名对应的X.25地址记录

发表评论

邮箱地址不会被公开。 必填项已用*标注