FreeBSD10以后,系统中没有nslookup,这个跟windows和Linux一脉相承的命令无法使用了,一下还真不习惯。找了drill的man,把常用的参数记录一下:
基本命令格式:
drill [Option] name [ @server ] [ Type ] [ class ]
描述:
drill 命令可以用来获取DNS相关的所有信息,并且支持DNSSEC。drill跟dig是双关命令,但是获取比dig更多的信息。
如果没有指定type,则默认为”IN”和”A”,如果没指定server,则使用/etc/resolv.con里面的DNS服务器。
示例:
drill mx miek.nl 查看miek.nl的mx记录 (注:好像不好用?)
drill -D www.baidu.com 使用DNSSEC来查询www.baidu.com记录
常用参数(摘选):
-D 使用DNSSEC进行查询
-T 从root开始,追踪查询的服务器
-V level 显示的信息级别,从1-5.
-Q 清静输出
-f file 从文件读取查询信息,这个文件必须是-w参数记录的数据包
-i file 从文件读取回应信息而不是从网上获取。(文件用-w?)
-w file 把回应包写入文件
-q file 把请求包写入文件
-v 显示版本
查询参数(摘选):
-4 仅使用ipv4
-6 使用ipv6
-a 如果回应包中有truncated(TC=1),则启用回退机制,如果收到truncated包,drill将选 发送一个包含EDNS0缓冲长度为4096的新包,原理见EDNS0,主要用来指定udp数据包的长度,默认为512字节,如果超出长度,则回应包中的TC置为1。如果仍然收到truncated包,或者EDNS0缓冲已经超过512字节,那就将回退到TCP模式。
-c file 不使用/etc/resolv.conf,使用指定的DNS配置文件
-t 强制使用TCP/IP来进行查询
-k keyfile 指定key文件,可以包含DNSKEY或DS记录
-o 指定头部的标志位。
-p port 不使用53端口
-u 强制使用udp协议
root@tt:~ % drill www.baidu.com
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 34575
;; flags: qr rd ra ; QUERY: 1, ANSWER: 3, AUTHORITY: 5, ADDITIONAL: 5
;; QUESTION SECTION:
;; www.baidu.com. IN A
;; ANSWER SECTION:
www.baidu.com. 1101 IN CNAME www.a.shifen.com.
www.a.shifen.com. 30 IN A 61.135.169.125
www.a.shifen.com. 30 IN A 61.135.169.121
;; AUTHORITY SECTION:
a.shifen.com. 217 IN NS ns4.a.shifen.com.
a.shifen.com. 217 IN NS ns1.a.shifen.com.
a.shifen.com. 217 IN NS ns5.a.shifen.com.
a.shifen.com. 217 IN NS ns2.a.shifen.com.
a.shifen.com. 217 IN NS ns3.a.shifen.com.
;; ADDITIONAL SECTION:
ns1.a.shifen.com. 176 IN A 61.135.165.224
ns2.a.shifen.com. 64 IN A 180.149.133.241
ns3.a.shifen.com. 372 IN A 61.135.162.215
ns4.a.shifen.com. 488 IN A 115.239.210.176
ns5.a.shifen.com. 372 IN A 119.75.219.43
;; Query time: 6 msec
;; SERVER: 202.102.154.3
;; WHEN: Mon Oct 20 10:56:58 2014
;; MSG SIZE rcvd: 260
root@tt:~ % drill -D www.baidu.com
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 3155
;; flags: qr rd ra ; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;; www.baidu.com. IN A
;; ANSWER SECTION:
www.baidu.com. 994 IN CNAME www.a.shifen.com.
www.a.shifen.com. 30 IN A 61.135.169.121
www.a.shifen.com. 30 IN A 61.135.169.125
;; AUTHORITY SECTION:
;; ADDITIONAL SECTION:
;; Query time: 6 msec
;; EDNS: version 0; flags: do ; udp: 4096
;; SERVER: 202.102.154.3
;; WHEN: Mon Oct 20 11:01:00 2014
;; MSG SIZE rcvd: 101
root@tt:~ % drill -DV 5 www.baidu.com
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 0
;; flags: rd ; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;; www.baidu.com. IN A
;; ANSWER SECTION:
;; AUTHORITY SECTION:
;; ADDITIONAL SECTION:
;; Query time: 0 msec
;; EDNS: version 0; flags: do ; udp: 4096
;; WHEN: Mon Oct 20 11:02:01 2014
;; MSG SIZE rcvd: 0
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 49715
;; flags: qr rd ra ; QUERY: 1, ANSWER: 3, AUTHORITY: 5, ADDITIONAL: 5
;; QUESTION SECTION:
;; www.baidu.com. IN A
;; ANSWER SECTION:
www.baidu.com. 814 IN CNAME www.a.shifen.com.
www.a.shifen.com. 266 IN A 61.135.169.121
www.a.shifen.com. 266 IN A 61.135.169.125
;; AUTHORITY SECTION:
a.shifen.com. 586 IN NS ns4.a.shifen.com.
a.shifen.com. 586 IN NS ns3.a.shifen.com.
a.shifen.com. 586 IN NS ns2.a.shifen.com.
a.shifen.com. 586 IN NS ns5.a.shifen.com.
a.shifen.com. 586 IN NS ns1.a.shifen.com.
;; ADDITIONAL SECTION:
ns1.a.shifen.com. 445 IN A 61.135.165.224
ns2.a.shifen.com. 445 IN A 180.149.133.241
ns3.a.shifen.com. 446 IN A 61.135.162.215
ns4.a.shifen.com. 551 IN A 115.239.210.176
ns5.a.shifen.com. 551 IN A 119.75.219.43
;; Query time: 6 msec
;; EDNS: version 0; flags: do ; udp: 4096
;; SERVER: 202.102.152.3
;; WHEN: Mon Oct 20 11:02:01 2014
;; MSG SIZE rcvd: 271
root@tt:~ % drill www.baidu.com @8.8.8.8
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 39233
;; flags: qr rd ra ; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;; www.baidu.com. IN A
;; ANSWER SECTION:
www.baidu.com. 1105 IN CNAME www.a.shifen.com.
www.a.shifen.com. 193 IN A 61.135.169.125
www.a.shifen.com. 193 IN A 61.135.169.121
;; AUTHORITY SECTION:
;; ADDITIONAL SECTION:
;; Query time: 234 msec
;; SERVER: 8.8.8.8
;; WHEN: Mon Oct 20 10:57:11 2014
;; MSG SIZE rcvd: 90
该贴由hui.chen转至本版2014-11-5 17:04:53