云服务器 ECS Linux 系统可以使用通常自带的 dig 命令来查询域名解析情况。本文对此进行简要说明。
查询域名 A 记录
命令格式:
dig <域名>
比如,查询域名 www.aliyun.com 的解析情况:
$ dig www.aliyun.com
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.7 <<>> www.aliyun.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15919
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 2, ADDITIONAL: 4
;; QUESTION SECTION:
;www.aliyun.com. IN A
;; ANSWER SECTION:
www.aliyun.com. 600 IN CNAME www-adns.aliyun.com.
www-adns.aliyun.com. 300 IN CNAME www-adns.aliyun.com.gds.alibabadns.com.
www-adns.aliyun.com.gds.alibabadns.com. 247 IN A 140.205.62.8
;; AUTHORITY SECTION:
gds.alibabadns.com. 82 IN NS gdsns2.alibabadns.com.
gds.alibabadns.com. 82 IN NS gdsns1.alibabadns.com.
;; ADDITIONAL SECTION:
gdsns1.alibabadns.com. 877 IN A 140.205.122.66
gdsns1.alibabadns.com. 877 IN A 198.11.138.254
gdsns2.alibabadns.com. 877 IN A 140.205.67.254
gdsns2.alibabadns.com. 877 IN A 140.205.122.88
;; Query time: 49 msec
;; SERVER: 10.242.197.247#53(10.242.197.247)
;; WHEN: Thu Jun 9 18:43:55 2016
;; MSG SIZE rcvd: 226
查询域名解析在指定 DNS 服务器解析是否生效
命令格式:
dig <域名> @<DNS 服务器地址>
比如,查询 www.aliyun.com 在 223.5.5.5 DNS 服务器是否解析生效:
$ dig www.aliyun.com @223.5.5.5
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.7 <<>> www.aliyun.com @223.5.5.5
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29651
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.aliyun.com. IN A
;; ANSWER SECTION:
www.aliyun.com. 95 IN CNAME www-adns.aliyun.com. # 查询到的解析记录
www-adns.aliyun.com. 95 IN CNAME www-adns.aliyun.com.gds.alibabadns.com. # 查询到的解析记录
www-adns.aliyun.com.gds.alibabadns.com. 95 IN A 140.205.63.8
;; Query time: 0 msec
;; SERVER: 223.5.5.5#53(223.5.5.5)
;; WHEN: Thu Jun 9 18:44:42 2016
;; MSG SIZE rcvd: 120
查询域名的 CNAME 记录
命令格式:
dig CNAME <域名>
比如,查询域名 www.aliyun.com 的 CNAME 记录:
# dig CNAME www.aliyun.com
; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> CNAME www.aliyun.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4690
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 7
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.aliyun.com. IN CNAME
;; ANSWER SECTION:
www.aliyun.com. 120 IN CNAME www-intl-adns.aliyun.com. # 查询到的 CNAME 信息
;; AUTHORITY SECTION:
aliyun.com. 172800 IN NS ns5.aliyun.com.
aliyun.com. 172800 IN NS ns4.aliyun.com.
aliyun.com. 172800 IN NS ns3.aliyun.com.
;; ADDITIONAL SECTION:
ns3.aliyun.com. 432000 IN A 42.120.250.251
ns4.aliyun.com. 432000 IN A 110.75.20.27
ns4.aliyun.com. 432000 IN A 140.205.71.248
ns4.aliyun.com. 432000 IN A 42.156.241.248
ns5.aliyun.com. 432000 IN A 140.205.2.187
ns5.aliyun.com. 432000 IN A 198.11.138.248
;; Query time: 10 msec
;; SERVER: 10.202.72.118#53(10.202.72.118)
;; WHEN: Fri Jul 08 11:46:33 CST 2016
;; MSG SIZE rcvd: 221
查询 IP 反解记录
命令格式:
dig -x <目标 IP 地址>
$ dig -x 140.205.62.8
; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> -x 140.205.62.8
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 38256
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;8.62.205.140.in-addr.arpa. IN PTR
;; AUTHORITY SECTION:
140.in-addr.arpa. 945 IN SOA z.arin.net. dns-ops.arin.net. 2016031910 1800 900 691200 10800
;; Query time: 3 msec
;; SERVER: 10.202.72.118#53(10.202.72.118)
;; WHEN: Fri Jul 08 11:51:32 CST 2016
;; MSG SIZE rcvd: 108
查询域名的 mx 解析记录
命令格式:
dig mx <目标域名>
?比如,查询域名 aliyun.com 的 mx 解析记录:
$ dig mx aliyun.com
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.37.rc1.el6_7.7 <<>> mx aliyun.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33606
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 7
;; QUESTION SECTION:
;aliyun.com. IN MX
;; ANSWER SECTION:
aliyun.com. 3600 IN MX 10 mx2.mail.aliyun.com.
;; AUTHORITY SECTION:
aliyun.com. 172800 IN NS ns4.aliyun.com.
aliyun.com. 172800 IN NS ns3.aliyun.com.
aliyun.com. 172800 IN NS ns5.aliyun.com.
;; ADDITIONAL SECTION:
mx2.mail.aliyun.com. 600 IN A 110.75.48.150
ns3.aliyun.com. 432000 IN A 42.120.250.251
ns4.aliyun.com. 432000 IN A 110.75.20.27
ns4.aliyun.com. 432000 IN A 140.205.71.248
ns4.aliyun.com. 432000 IN A 42.156.241.248
ns5.aliyun.com. 432000 IN A 198.11.138.248
ns5.aliyun.com. 432000 IN A 140.205.2.187
;; Query time: 1 msec
;; SERVER: 10.242.197.247#53(10.242.197.247)
;; WHEN: Thu Jun 9 18:59:44 2016
;; MSG SIZE rcvd: 219
时间: 2024-10-11 13:42:44