DNS知识精要:快速掌握DNS基础
INFO
DNS 通过使用服务器的分层系统来工作。当用户在Web浏览器中输入域名时,浏览器会向 DNS 服务器发送请求。然后,DNS 服务器在其数据库中查找域名并返回网站或服务的 IP 地址。最后,浏览器使用 IP 地址连接到网站或服务。
本文原创,转载请注明出处
DNS解析
txt
现代常用域名解析方式:递归,迭代+递归
递归解析
本地 DNS 服务器会将请求转发到更高级别的 DNS 服务器,直到找到存储该域名IP地址的 DNS 服务器。然后,更高级别的 DNS 服务器将 IP 地址返回给本地 DNS 服务器,本地 DNS 服务器再将 IP 地址返回给客户端。
迭代解析
一种特殊的 DNS 解析方式,允许客户端直接与更高级别的 DNS 服务器通信。在迭代解析中,客户端将请求发送到更高级别的 DNS 服务器。更高级别的 DNS 服务器将返回一个包含域名信息的响应。如果该响应包含 IP 地址,客户端将使用该 IP 地址连接到网站或服务。如果该响应不包含 IP 地址,客户端将再次发送请求,直到找到 IP 地址。
域名服务器分类
:
根域名
顶级域名
权限域名服务器(总能将主机名转化为IP)
常用域名解析类型
:
txt
A类型 域名直接指向IPv4
AAAA类型 域名直接指向IPv6
CNAME类型 域名网络指向主机名(允许多个域名映射到同一个主机名,通常用来使用CDN)
NS类型 域名网络指向DNS解析服务器,由指向的DNS服务器进行解析
PTR类型 反向域名解析
MX类型 域名指向邮件服务器
域名信息查询网站
txt
域名注册信息
https://whois.aliyun.com/
域名备案信息
https://www.beianx.cn/
DNS相关命令
nslookup
shell
nslookup monody.net
Output
txt
Default server: 172.26.0.2
Address: 172.26.0.2#53
Default server: 192.168.1.1
Address: 192.168.1.1#53
Default server: 8.8.8.8
Address: 8.8.8.8#53
Set options:
novc nodebug nod2
search recurse
timeout = 0 retry = 3 port = 53 ndots = 1
querytype = A class = IN
srchlist =
Server: 172.26.0.2
Address: 172.26.0.2#53
Non-authoritative answer:
Name: monody.net
Address: 216.239.32.21
Name: monody.net
Address: 216.239.36.21
Name: monody.net
Address: 216.239.34.21
Name: monody.net
Address: 216.239.38.21
Name: monody.net
Address: 2001:4860:4802:32::15
Name: monody.net
Address: 2001:4860:4802:36::15
Name: monody.net
Address: 2001:4860:4802:38::15
Name: monody.net
Address: 2001:4860:4802:34::15
dig
shell
dig docs.monody.net any #解析全部记录
Output
txt
; <<>> DiG 9.18.16-1-Debian <<>> monody.net any
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34883
;; flags: qr rd ra; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;monody.net. IN ANY
;; ANSWER SECTION:
monody.net. 3600 IN AAAA 2001:4860:4802:38::15
monody.net. 3600 IN AAAA 2001:4860:4802:32::15
monody.net. 3600 IN AAAA 2001:4860:4802:34::15
monody.net. 3600 IN AAAA 2001:4860:4802:36::15
monody.net. 21600 IN SOA ns-cloud-e1.googledomains.com. cloud-dns-hostmaster.google.com. 110 21600 3600 259200 300
monody.net. 21600 IN NS ns-cloud-e3.googledomains.com.
monody.net. 21600 IN NS ns-cloud-e2.googledomains.com.
monody.net. 21600 IN NS ns-cloud-e4.googledomains.com.
monody.net. 21600 IN NS ns-cloud-e1.googledomains.com.
monody.net. 3600 IN A 216.239.38.21
monody.net. 3600 IN A 216.239.36.21
monody.net. 3600 IN A 216.239.34.21
monody.net. 3600 IN A 216.239.32.21
;; Query time: 307 msec
;; SERVER: 172.26.0.2#53(172.26.0.2) (TCP)
;; WHEN: Sat Sep 09 10:48:56 CST 2023
;; MSG SIZE rcvd: 400
shell
dig -x 216.239.34.21 #反向解析
Output
txt
; <<>> DiG 9.18.16-1-Debian <<>> -x 216.239.36.21
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55097
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;21.36.239.216.in-addr.arpa. IN PTR
;; ANSWER SECTION:
21.36.239.216.in-addr.arpa. 300 IN PTR any-in-2415.1e100.net.
;; Query time: 248 msec
;; SERVER: 172.26.0.2#53(172.26.0.2) (UDP)
;; WHEN: Sat Sep 09 10:49:26 CST 2023
;; MSG SIZE rcvd: 90
host
shell
host monody.net
Output
txt
monody.net has address 216.239.36.21
monody.net has address 216.239.32.21
monody.net has address 216.239.38.21
monody.net has address 216.239.34.21
monody.net has IPv6 address 2001:4860:4802:34::15
monody.net has IPv6 address 2001:4860:4802:38::15
monody.net has IPv6 address 2001:4860:4802:36::15
monody.net has IPv6 address 2001:4860:4802:32::15
whois
shell
whois monody.net
Output
txt
Domain Name: MONODY.NET
Registry Domain ID: 2749741945_DOMAIN_NET-VRSN
Registrar WHOIS Server: whois.google.com
Registrar URL: http://domains.google.com
Updated Date: 2023-09-03T03:47:39Z
Creation Date: 2023-01-07T13:42:45Z
Registry Expiry Date: 2024-01-07T13:42:45Z
Registrar: Google LLC
Registrar IANA ID: 895
Registrar Abuse Contact Email: registrar-abuse@google.com
Registrar Abuse Contact Phone: +1.8772376466
Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
Name Server: NS-CLOUD-E1.GOOGLEDOMAINS.COM
Name Server: NS-CLOUD-E2.GOOGLEDOMAINS.COM
Name Server: NS-CLOUD-E3.GOOGLEDOMAINS.COM
Name Server: NS-CLOUD-E4.GOOGLEDOMAINS.COM
DNSSEC: unsigned
traceroute
shell
traceroute google.com
Output
txt
21 100.92.133.11 (100.92.133.11) 307.119 ms 100.92.125.33 (100.92.125.33) 306.961 ms 100.92.133.9 (100.92.133.9) 306.857 ms
22 240.1.228.12 (240.1.228.12) 307.004 ms 99.83.116.85 (99.83.116.85) 309.066 ms 99.83.117.223 (99.83.117.223) 308.960 ms
23 99.83.116.80 (99.83.116.80) 287.935 ms 100.92.128.133 (100.92.128.133) 288.263 ms 99.83.116.80 (99.83.116.80) 287.874 ms
24 99.83.117.223 (99.83.117.223) 287.932 ms 287.841 ms 99.83.116.85 (99.83.116.85) 287.968 ms
25 * 99.83.116.85 (99.83.116.85) 287.939 ms 209.85.254.247 (209.85.254.247) 287.812 ms
26 100.92.125.51 (100.92.125.51) 287.944 ms 142.251.241.136 (142.251.241.136) 287.692 ms 100.92.133.35 (100.92.133.35) 287.884 ms
27 240.1.228.15 (240.1.228.15) 287.685 ms 240.1.228.13 (240.1.228.13) 287.754 ms 108.170.245.108 (108.170.245.108) 289.466 ms
28 74.125.243.177 (74.125.243.177) 289.443 ms 99.83.116.84 (99.83.116.84) 407.705 ms 240.1.228.12 (240.1.228.12) 407.851 ms
29 sea30s02-in-f14.1e100.net (172.217.14.238) 407.567 ms 99.83.117.223 (99.83.117.223) 407.744 ms 99.83.117.218 (99.83.117.218) 407.680 ms