nslookup
有些时候, user 可能会想要手动查询 DNS 上一些数据, 或者是要看看 DNS 是否有问题, 此时我们最常用的工具就是 nslookup 了, 基本上 nslookup 会根据 /etc/resolv.conf 的内容去找到所要使用的 local DNS server.
 打入 nslookup 命令后, 会看到 > 提示符号, 此时打 ? 就会出现 nslookup 说明 
 Default Server: sun4.ee.ncku.edu.tw 
 Address: 140.116.72.14 
>?
$Id: nslookup.help,v 8.4 1996/10/25 18:09:41 vixie Exp $
 Commands: (identifiers are shown in uppercase, [] means optional) 
 NAME - print info about the host/domain NAME using default server 
 NAME1 NAME2 - as above, but use NAME2 as server 
 help or ? - print info on common commands; see nslookup(1) for details 
 set OPTION - set an option 
 all - print options, current server and host 
 [no]debug - print debugging information 
 [no]d2 - print exhaustive debugging information 
 [no]defname - append domain name to each query 
 [no]recurse - ask for recursive answer to query 
 [no]vc - always use a virtual circuit 
 domain=NAME - set default domain name to NAME 
 srchlist=N1[/N2/.../N6] - set domain to N1 and search list to N1,N2, etc. 
 root=NAME - set root server to NAME 
 retry=X - set number of retries to X 
 timeout=X - set initial time-out interval to X seconds 
 querytype=X - set query type, e.g., A,ANY,CNAME,HINFO,MX,PX,NS,PTR,SOA,TXT,WKS,SRV,NAPTR 
 port=X - set port number to send query on 
 type=X - synonym for querytype 
 class=X - set query class to one of IN (Internet), CHAOS, HESIOD or ANY 
 server NAME - set default server to NAME, using current default server 
 lserver NAME - set default server to NAME, using initial server 
 finger [USER] - finger the optional USER at the current default host 
 root - set current default server to the root 
 ls [opt] DOMAIN [> FILE] - list addresses in DOMAIN (optional: output to FILE) 
 -a - list canonical names and aliases 
 -h - list HINFO (CPU type and operating system) 
 -s - list well-known services 
 -d - list all records 
 -t TYPE - list records of the given type (e.g., A,CNAME,MX, etc.) 
 view FILE - sort an 'ls' output file and view it with more 
 exit - exit the program, ^D also exits 
 >^D 
Interactive/Noninteractive (交谈式/非交谈式)
 执行 nslookup 时可以直接在后面跟着我们要查询的资料, 那么 nslookup 会直接把结果传回来 
 如果只打入 nslookup [enter], 则进入交谈模式, 出现提示符号 >, 此时 nslookup 会等待 user input command. 
 Non-authoritative answer: 
 Name: yohoo.com 
 Address: 216.116.98.143 
 Aliases:  www.yohoo.com 
tung@traveler:~> nslookup 
 Default Server: sun4.ee.ncku.edu.tw 
 Address: 140.116.72.14 
 >  www.yohoo.com 
 Server: sun4.ee.ncku.edu.tw 
 Address: 140.116.72.14 
 Non-authoritative answer: 
 Name: yohoo.com 
 Address: 216.116.98.143 
 Aliases:  www.yohoo.com 
Authoritative/Non-Authoritative
在查询时有时会出现 Non-authoritative answer, 代表这个答案是由 local DNS 的 cache 中直接读出来的, 而不是 local DNS 向真正负责这个 domain 的 name server 问来的.
 1. set all 
 可以得知目前 nslookup 的一些 default 设定值 
 tung@traveler:~> nslookup 
 Default Server: sun4.ee.ncku.edu.tw 
 Address: 140.116.72.14 
 > set all 
 Default Server: sun4.ee.ncku.edu.tw 
 Address: 140.116.72.14 
 Set options: 
 nodebug defname search recurse 
 nod2 novc noignoretc port=53 
 querytype=A class=IN timeout=5 retry=4 
 root=a.root-servers.net. 
 domain=ee.ncku.edu.tw 
 srchlist=ee.ncku.edu.tw 
 2. server dns_server_ip 
 表示将内定的 local DNS 换成另一部 server 
 Ex: server 140.116.2.6 
 3. set type=any 
 表示在查询某个 domain name 时, 将和这个 domain name 的一些相关数据一并显示出来 
 > set type=any 
 >  www.yohoo.com 
 Server: sun4.ee.ncku.edu.tw 
 Address: 140.116.72.14 
 Non-authoritative answer: 
 www.yohoo.com canonical name = yohoo.com 
 Authoritative answers can be found from: 
 yohoo.com nameserver = ns1.netgateway.net 
 yohoo.com nameserver = ns2.netgateway.net 
 ns1.netgateway.net internet address = 216.116.98.7 
 ns2.netgateway.net internet address = 216.116.98.8 
 在上面的这个例子, 我们除了知道  www.yohoo.com 的 IP 外, 我们还得知了 yohoo.com 是由哪部 name server 在负责的. 因此如果想要知道  www.yohoo.com 真正在 yohoo.com 上的记录是如何, 而不要有 local DNS cache 中传回的资料, 我们可以配合使用 server 这个 command 将 default local DNS 改为负责 yohoo.com 的 DNS, 然后再查询一次 
 > server 216.116.98.7 
 Default Server: ns1.netgateway.net 
 Address: 216.116.98.7 
 >  www.yohoo.com 
 Server: ns1.netgateway.net 
 Address: 216.116.98.7 
 Name: yohoo.com 
 Address: 216.116.98.143 
 Aliases:  www.yohoo.com 
 4. set type=ptr 
 本来要由 IP 反查 domain name时, 在直接打 IP 就行了, 但如果已经下了 type=any 的话, 要由 IP 反查时就没那么方便了, 此时 IP 4 个数字要倒着写, 最后还要加上 in-addr.arpa. 以查 140.116.72.219 为例, 要输入的就是 219.72.116.140.in-addr.arpa 
 tung@traveler:~> nslookup 
 Default Server: sun4.ee.ncku.edu.tw 
 Address: 140.116.72.14 
 > 140.116.72.219 
 Server: sun4.ee.ncku.edu.tw 
 Address: 140.116.72.14 
 Name: garfield.ee.ncku.edu.tw 
 Address: 140.116.72.219 
 > set type=any 
 > 140.116.72.219 
 Server: sun4.ee.ncku.edu.tw 
 Address: 140.116.72.14 
 *** sun4.ee.ncku.edu.tw can't find 140.116.72.219: Non-existent host/domain 
 > 219.72.116.140.in-addr.arpa 
 Server: sun4.ee.ncku.edu.tw 
 Address: 140.116.72.14 
 219.72.116.140.in-addr.arpa name = garfield.ee.ncku.edu.tw 
 72.116.140.IN-ADDR.ARPA nameserver = sun4.ee.ncku.edu.tw 
 sun4.ee.ncku.edu.tw internet address = 140.116.72.14 
 另外一个办法就是先下 set type=ptr 或 set type=a 命令, 脱离 type=any 模式, 再进行 IP 反查 domain name 的 command 
 > set typr=ptr 
 > 140.116.72.219 
 Server: sun4.ee.ncku.edu.tw 
 Address: 140.116.72.14 
 219.72.116.140.in-addr.arpa name = garfield.ee.ncku.edu.tw 
 72.116.140.IN-ADDR.ARPA nameserver = sun4.ee.ncku.edu.tw 
 sun4.ee.ncku.edu.tw internet address = 140.116.72.14 
 5. ls domain 
 这个命令是要求 name server 将其负责的 zone 内容 show 出来, 这个动作相当于 name server 的整份记录从 server 端传回给 nslookup 这个程序, 这种传回整个 zone 的动作叫作 zone transfer 
 > set type=any 
 > ee.ncku.edu.tw 
 Server: cs.ncku.edu.tw 
 Address: 140.116.2.6 
 ee.ncku.edu.tw nameserver = sun4.ee.ncku.edu.tw 
 ee.ncku.edu.tw preference = 1, mail exchanger = eembox.ee.ncku.edu.tw 
 ee.ncku.edu.tw internet address = 140.116.72.15 
 ee.ncku.edu.tw 
 origin = sun4.ee.ncku.edu.tw 
 mail addr = root.sun4.ee.ncku.edu.tw 
 serial = 1999033001 
 refresh = 3600 (1H) 
 retry = 900 (15M) 
 expire = 3600000 (5w6d16h) 
 minimum ttl = 3600 (1H) 
 ee.ncku.edu.tw nameserver = sun4.ee.ncku.edu.tw 
 sun4.ee.ncku.edu.tw internet address = 140.116.72.14 
 eembox.ee.ncku.edu.tw internet address = 140.116.72.15 
 > ls ee.ncku.edu.tw 
 Default Server: cs.ncku.edu.tw 
 Address: 140.116.2.6 
 > [sun4.ee.ncku.edu.tw] 
 $ORIGIN ee.ncku.edu.tw. 
 @ 1H IN A 140.116.72.15 
 hdlib4 1H IN A 140.116.72.4 
 ds114 1H IN A 140.116.72.114 
 hdlib5 1H IN A 140.116.72.5 
 ds115 1H IN A 140.116.72.115 
 yokoyama1 1H IN A 140.116.227.217 
 hdlib6 1H IN A 140.116.72.6 
 ds116 1H IN A 140.116.72.116 
 yokoyama2 1H IN A 140.116.227.218 
 ds117 1H IN A 140.116.72.117 
 ds120 1H IN A 140.116.72.120 
 ds118 1H IN A 140.116.72.118 
 ds121 1H IN A 140.116.72.121 
 ds119 1H IN A 140.116.72.119 
 ds122 1H IN A 140.116.72.122 
 ds123 1H IN A 140.116.72.123 
 intelab01 1H IN A 140.116.227.39 
网址:nslookup https://www.yuejiaxmz.com/news/view/257069
相关内容
智能体平台—购物小助手IT日常生活中的一些电脑技巧总结
网络安全中黑客主要手段和攻击方法
网络安全(黑客)自学
黑客入门教程(非常详细)从零基础入门到精通,看完这一篇就够了

