Nslookup是一个命令行管理工具,用于对DNS服务器(域名服务器)进行测试和故障排除,它也用于查询特定的DNS资源记录 ( RR )。目前大多数操作系统都带有内置的Nslookup功能。
本文将简单介绍广泛使用的Nslookup命令。据悉,Nslookup可以在两种模式下运行:交互式和非交互式。交互模式用于向DNS-Server查询各种域名和主机,而非交互模式用于查询域或主机的信息。
1、找出域名的“A”记录(IP地址)
# nslookup yahoo.com Server: 4.2.2.2 Address: 4.2.2.2#53 Non-authoritative answer: Name: yahoo.com Address: 72.30.38.140 Name: yahoo.com Address: 98.139.183.24 Name: yahoo.com Address: 209.191.122.70
上面的命令查询域www.yahoo.com与4.2.2.2公共DNS服务器和下面的部分显示Non-authoritative answer:显示www.yahoo.com的A记录
2、找出反向域名Lookup
# nslookup 209.191.122.70 Server: 4.2.2.2 Address: 4.2.2.2#53 Non-authoritative answer: 70.122.191.209.in-addr.arpa name = ir1.fp.vip.mud.yahoo.com. Authoritative answers can be found from:
3、找出特定的域名Lookup
# nslookup ir1.fp.vip.mud.yahoo.com. Server: 4.2.2.2 Address: 4.2.2.2#53 Non-authoritative answer: Name: ir1.fp.vip.mud.yahoo.com Address: 209.191.122.70
4、查询MX(邮件交换)记录
# nslookup -query=mx www.yahoo.com Server: 4.2.2.2 Address: 4.2.2.2#53 Non-authoritative answer: www.yahoo.com canonical name = fd-fp3.wg1.b.yahoo.com. fd-fp3.wg1.b.yahoo.com canonical name = ds-fp3.wg1.b.yahoo.com. ds-fp3.wg1.b.yahoo.com canonical name = ds-any-fp3-lfb.wa1.b.yahoo.com. ds-any-fp3-lfb.wa1.b.yahoo.com canonical name = ds-any-fp3-real.wa1.b.yahoo.com. Authoritative answers can be found from: wa1.b.yahoo.com origin = yf1.yahoo.com mail addr = hostmaster.yahoo-inc.com serial = 1344827307 refresh = 30 retry = 30 expire = 86400 minimum = 1800
MX记录用于将域名映射到该域的邮件交换服务器列表,这样它就可以告诉任何接收/发送到@yahoo.com的邮件都将被路由到邮件服务器。
5、查询NS(Name Server)记录
# nslookup -query=ns www.yahoo.com Server: 4.2.2.2 Address: 4.2.2.2#53 Non-authoritative answer: www.yahoo.com canonical name = fd-fp3.wg1.b.yahoo.com. fd-fp3.wg1.b.yahoo.com canonical name = ds-fp3.wg1.b.yahoo.com. ds-fp3.wg1.b.yahoo.com canonical name = ds-any-fp3-lfb.wa1.b.yahoo.com. ds-any-fp3-lfb.wa1.b.yahoo.com canonical name = ds-any-fp3-real.wa1.b.yahoo.com. Authoritative answers can be found from: wa1.b.yahoo.com origin = yf1.yahoo.com mail addr = hostmaster.yahoo-inc.com serial = 1344827782 refresh = 30 retry = 30 expire = 86400 minimum = 1800
6、查询SOA(Start of Authority)记录
# nslookup -type=soa www.yahoo.com Server: 4.2.2.2 Address: 4.2.2.2#53 Non-authoritative answer: www.yahoo.com canonical name = fd-fp3.wg1.b.yahoo.com. fd-fp3.wg1.b.yahoo.com canonical name = ds-fp3.wg1.b.yahoo.com. ds-fp3.wg1.b.yahoo.com canonical name = ds-any-fp3-lfb.wa1.b.yahoo.com. ds-any-fp3-lfb.wa1.b.yahoo.com canonical name = ds-any-fp3-real.wa1.b.yahoo.com. Authoritative answers can be found from: wa1.b.yahoo.com origin = yf1.yahoo.com mail addr = hostmaster.yahoo-inc.com serial = 1344827965 refresh = 30 retry = 30 expire = 86400 minimum = 1800
7、查询所有可用的DNS记录
# nslookup -query=any yahoo.com Server: 4.2.2.2 Address: 4.2.2.2#53 Non-authoritative answer: yahoo.com origin = ns1.yahoo.com mail addr = hostmaster.yahoo-inc.com serial = 2012081016 refresh = 3600 retry = 300 expire = 1814400 minimum = 600 Name: yahoo.com Address: 98.139.183.24 Name: yahoo.com Address: 209.191.122.70 Name: yahoo.com Address: 72.30.38.140 yahoo.com mail exchanger = 1 mta7.am0.yahoodns.net. yahoo.com mail exchanger = 1 mta5.am0.yahoodns.net. yahoo.com mail exchanger = 1 mta6.am0.yahoodns.net. yahoo.com nameserver = ns3.yahoo.com. yahoo.com nameserver = ns4.yahoo.com. yahoo.com nameserver = ns2.yahoo.com. yahoo.com nameserver = ns8.yahoo.com. yahoo.com nameserver = ns1.yahoo.com. yahoo.com nameserver = ns6.yahoo.com. yahoo.com nameserver = ns5.yahoo.com. Authoritative answers can be found from:
8、启用调试模式
要启用调试模式,’set debug’ 将返回详细信息,如TTL,以下是输出结果:
# nslookup -debug yahoo.com > set debug > yahoo.com Server: 4.2.2.2 Address: 4.2.2.2#53 ------------ QUESTIONS: yahoo.com, type = A, class = IN ANSWERS: -> yahoo.com internet address = 72.30.38.140 ttl = 1523 -> yahoo.com internet address = 98.139.183.24 ttl = 1523 -> yahoo.com internet address = 209.191.122.70 ttl = 1523 AUTHORITY RECORDS: ADDITIONAL RECORDS: ------------ Non-authoritative answer: Name: yahoo.com Address: 72.30.38.140 Name: yahoo.com Address: 98.139.183.24 Name: yahoo.com Address: 209.191.122.70
总结
在以上内容中,小编简单介绍了Nslookup基本命令的使用方法,这些命令可以帮助你搜索 ( DNS ) 域名服务相关信息。
当然,上述以雅虎域名为例进行演示,大家可以自行换成想要查询的域名或IP地址。上述Nslookup基本命令演示仅供参考,有任何问题欢迎交流讨论。