dig-DNS lookup utility
当域名出现访问故障时,可通过域名解析来判断是否有错误的解析导致的问题。
dig chat.uniap.cn
; <<>> DiG 9.10.6 <<>> chat.uniap.cn
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18404
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;chat.uniap.cn. IN A
;; ANSWER SECTION:
chat.uniap.cn. 1 IN A 8.142.72.65
;; Query time: 4 msec
;; SERVER: 192.168.3.1#53(192.168.3.1)
;; WHEN: Tue Mar 14 13:27:19 CST 2023
;; MSG SIZE rcvd: 47
可以看到有请求段和应答段,最后解析出的 A 记录有两条
dig 命令做迭代查询
dig +trace 可跟踪整个解析流程 如下
dig chat.uniap.cn +trace
; <<>> DiG 9.10.6 <<>> chat.uniap.cn +trace
;; global options: +cmd
. 25 IN NS h.root-servers.net.
. 25 IN NS d.root-servers.net.
. 25 IN NS l.root-servers.net.
. 25 IN NS f.root-servers.net.
. 25 IN NS b.root-servers.net.
. 25 IN NS c.root-servers.net.
. 25 IN NS i.root-servers.net.
. 25 IN NS g.root-servers.net.
. 25 IN NS j.root-servers.net.
. 25 IN NS m.root-servers.net.
. 25 IN NS k.root-servers.net.
. 25 IN NS a.root-servers.net.
. 25 IN NS e.root-servers.net.
;; Received 239 bytes from 192.168.3.1#53(192.168.3.1) in 5 ms
cn. 172800 IN NS a.dns.cn.
cn. 172800 IN NS b.dns.cn.
cn. 172800 IN NS c.dns.cn.
cn. 172800 IN NS d.dns.cn.
cn. 172800 IN NS e.dns.cn.
cn. 172800 IN NS f.dns.cn.
cn. 172800 IN NS g.dns.cn.
cn. 172800 IN NS ns.cernet.net.
cn. 86400 IN DS 57724 8 2 5D0423633EB24A499BE78AA22D1C0C9BA36218FF49FD95A4CDF1A4AD 97C67044
cn. 86400 IN RRSIG DS 8 1 86400 20230326210000 20230313200000 951 . gHMYjWTADUwNLBaOuldFVkJ/zxSx+PBeSabc+H2s9/xzfbdhcMa1uZJM GvTCHb8XhU8sNx5VQrmoQknPQ14p8wU30S4QeTdjYnSvefoUqYhxD31J W8y5JwHFHsy61XbUYu1ST2JI5kX3THBbZaHE6N4Yn5MQ+Uv890SvYen/ +7ILseWYWrmven/GKAgMswsmK3YxTqXYVJHUQrsq/XkPgA2a0WwWUJQR B4toG+ZhXontIe86QZcjKduKeIsqAvMK0rmfHjf7wVfb4ohHXHMjTFob 5zLvLomdvR75QiEot9l+oJhXNCwzBj6L7t/CGoDcn78ipKLGsrDDAERR 7O8e7g==
;; Received 704 bytes from 192.203.230.10#53(e.root-servers.net) in 53 ms
uniap.cn. 86400 IN NS ns1.myhostadmin.net.
uniap.cn. 86400 IN NS ns2.myhostadmin.net.
3qdaqa092ee5belp64a74ebnb8j53d7e.cn. 21600 IN NSEC3 1 1 10 AEF123AB 3QHKTF6LTFG8AAFUUAJSR8RVAJP99SFU NS SOA RRSIG DNSKEY NSEC3PARAM
3qdaqa092ee5belp64a74ebnb8j53d7e.cn. 21600 IN RRSIG NSEC3 8 2 21600 20230327231921 20230225225500 38388 cn. Uqf/DGdVI4huRWD9gQnHzBP47D0+RhZtJYAcDDGJ9C5fXlSlKEs+6QGS fl46t4AG1HhQcONBrkLXRLkpc/VkbzuLzEaXopgU8HPBxS16DFvjydAI WU1xcpF1psYEI7vocu5gyUohsvdrAahqH6K9BMY99TmQllNeTDQ5zvzh TKg=
e0or0q7o350evg5sk3glt50rit2rk9hv.cn. 21600 IN NSEC3 1 1 10 AEF123AB E1LTQ1TCBU7DVQKIALC7T94HI7NVC83R NS DS RRSIG
e0or0q7o350evg5sk3glt50rit2rk9hv.cn. 21600 IN RRSIG NSEC3 8 2 21600 20230331092139 20230301084146 38388 cn. BFVT2xvxkQG+3dwREx3jgx/Gg2n7p/0l9BQP0Mqe4X02eJZzvqVVl9EP 7tDza++s1DKMLcz9OXHDCuAN2M/ZQ0VD7xhBKw3//vPa9rVh1TD4hofy kcH8SpJ+WozeCnRZbmwoygCki+4IrIr2U+CzUHEUMJu0q6dMhzcF+0x/ cTE=
;; Received 665 bytes from 203.119.29.1#53(e.dns.cn) in 285 ms
chat.uniap.cn. 900 IN A 39.98.93.50
;; Received 47 bytes from 61.240.129.143#53(ns2.myhostadmin.net) in 59 ms
nslookup 可以指定 dns 服务器来解析域名
nslookup chat.uniap.cn
Server: 192.168.3.1
Address: 192.168.3.1#53
Non-authoritative answer:
Name: chat.uniap.cn
Address: 39.98.93.50
nslookup 查询域名 A 记录是否生效,域名是否解析成功
nslookup 域名
查询 mx 记录是否生效
nslookup -qt=mx 域名
查询域名使用的是哪一家 DNS 服务器
nslookup -qt=ns 域名
查看域名的别名记录(cname 记录)
nslookup -qt=cname 回车即可得到域名解析的别名记录