计算机网络中的 DNS 与 DHCP 详解
文章目录
- [计算机网络中的 DNS 与 DHCP 详解](#计算机网络中的 DNS 与 DHCP 详解)
-
- 一、域名的分类、作用与常见域名
-
- [1. 域名分类体系](#1. 域名分类体系)
- [2. 顶级域名(TLD)的详细分类](#2. 顶级域名(TLD)的详细分类)
-
- (1)通用顶级域名(gTLD)
- (2)国家/地区顶级域名(ccTLD)
- [(3)新通用顶级域名(new gTLD)](#(3)新通用顶级域名(new gTLD))
- [3. 二级域名与子域名](#3. 二级域名与子域名)
- [二、DNS 的作用](#二、DNS 的作用)
-
- 核心功能
- [DNS 解析过程简述](#DNS 解析过程简述)
- [常见 DNS 记录类型](#常见 DNS 记录类型)
- [三、DHCP 的作用](#三、DHCP 的作用)
-
- 核心功能
- [DHCP 工作流程(DORA 四步握手)](#DHCP 工作流程(DORA 四步握手))
- [DHCP 分配方式](#DHCP 分配方式)
- [DHCP 与 DNS 的协作关系](#DHCP 与 DNS 的协作关系)
- 四、递归查询和迭代查询
一、域名的分类、作用与常见域名
域名(Domain Name)是互联网上用于标识和定位计算机的层次化命名系统,采用点分层次结构,从右向左层级递减。
1. 域名分类体系
| 层级 | 名称 | 示例 | 说明 |
|---|---|---|---|
| 第一级 | 根域名 | .(通常省略) |
域名树的最高层 |
| 第二级 | 顶级域名(TLD) | .com、.cn |
分为 gTLD 和 ccTLD |
| 第三级 | 二级域名 | example.com |
由注册者申请使用 |
| 第四级及以下 | 子域名 | www.example.com |
由域名所有者自行划分 |
2. 顶级域名(TLD)的详细分类
(1)通用顶级域名(gTLD)
面向全球开放注册,不限定国家/地区。
| 域名 | 全称 | 用途 |
|---|---|---|
| .com | commercial | 商业机构(最常用) |
| .net | network | 网络服务提供商 |
| .org | organization | 非营利组织 |
| .edu | education | 教育机构(主要在美国) |
| .gov | government | 政府机构(主要在美国) |
| .mil | military | 美国军事机构 |
| .int | international | 国际组织 |
(2)国家/地区顶级域名(ccTLD)
由 ISO 3166 标准定义,代表特定国家或地区。
| 域名 | 代表国家/地区 |
|---|---|
| .cn | 中国 |
| .us | 美国 |
| .uk | 英国 |
| .jp | 日本 |
| .de | 德国 |
| .hk | 中国香港 |
| .tw | 中国台湾 |
(3)新通用顶级域名(new gTLD)
ICANN 于 2012 年起大量开放的新后缀。
| 域名 | 用途 |
|---|---|
| .app | 应用程序 |
| .blog | 博客 |
| .shop | 电商/商店 |
| .xyz | 通用(因便宜而流行) |
| .io | 技术/初创公司(原为英属印度洋领地) |
| .ai | 人工智能(原为安圭拉) |
3. 二级域名与子域名
- 二级域名 :注册者向域名注册商购买的唯一标识,如
google.com中的google。 - 子域名 :域名所有者在 DNS 中自行创建的下一级域名,用于划分不同服务:
www.example.com--- 网站主站mail.example.com--- 邮件服务api.example.com--- 接口服务cdn.example.com--- 内容分发
二、DNS 的作用
DNS(Domain Name System,域名系统)是互联网的**"电话簿"**,负责将人类易读的域名转换为机器可识别的 IP 地址。
核心功能
| 功能 | 说明 |
|---|---|
| 域名解析 | 将域名(如 www.baidu.com)解析为对应的 IP 地址(如 110.242.68.3) |
| 反向解析 | 将 IP 地址反向查询为域名(PTR 记录) |
| 负载均衡 | 通过返回不同 IP 地址,将流量分散到多台服务器 |
| 邮件路由 | 通过 MX 记录指定邮件服务器地址 |
| 服务发现 | 通过 SRV 记录定位特定网络服务 |
DNS 解析过程简述
用户输入 www.example.com
↓
浏览器缓存 → 操作系统缓存 → 本地 DNS 服务器(ISP 提供)
↓
本地 DNS 向 根域名服务器 查询 → 获取 .com 服务器地址
↓
向 .com 顶级域名服务器 查询 → 获取 example.com 服务器地址
↓
向 example.com 权威域名服务器 查询 → 获取最终 IP 地址
↓
返回 IP 给用户,完成访问
常见 DNS 记录类型
| 记录类型 | 作用 |
|---|---|
| A | 将域名指向 IPv4 地址 |
| AAAA | 将域名指向 IPv6 地址 |
| CNAME | 域名别名(指向另一个域名) |
| MX | 邮件交换记录 |
| NS | 指定该域名的权威 DNS 服务器 |
| TXT | 文本记录(常用于验证域名所有权、SPF 反垃圾邮件) |
三、DHCP 的作用
DHCP (Dynamic Host Configuration Protocol,动态主机配置协议)是一种网络管理协议,用于自动为网络中的设备分配 IP 地址及其他网络配置参数。
核心功能
| 功能 | 说明 |
|---|---|
| 自动分配 IP 地址 | 设备接入网络时自动获取可用 IP,无需手动配置 |
| 分配网络参数 | 同时分配子网掩码、默认网关、DNS 服务器地址 |
| 租约管理 | IP 地址按"租期"分配,到期可续租或回收 |
| 防止 IP 冲突 | 由服务器统一分配,避免多台设备使用相同 IP |
| 简化网络管理 | 大型网络中无需逐台设备手动配置 |
DHCP 工作流程(DORA 四步握手)
服务器 客户端 (新接入) 服务器 客户端 (新接入) #mermaid-svg-XoimmEL0Sf75PVKw{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-XoimmEL0Sf75PVKw .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-XoimmEL0Sf75PVKw .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-XoimmEL0Sf75PVKw .error-icon{fill:#552222;}#mermaid-svg-XoimmEL0Sf75PVKw .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-XoimmEL0Sf75PVKw .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-XoimmEL0Sf75PVKw .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-XoimmEL0Sf75PVKw .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-XoimmEL0Sf75PVKw .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-XoimmEL0Sf75PVKw .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-XoimmEL0Sf75PVKw .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-XoimmEL0Sf75PVKw .marker{fill:#333333;stroke:#333333;}#mermaid-svg-XoimmEL0Sf75PVKw .marker.cross{stroke:#333333;}#mermaid-svg-XoimmEL0Sf75PVKw svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-XoimmEL0Sf75PVKw p{margin:0;}#mermaid-svg-XoimmEL0Sf75PVKw .actor{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-XoimmEL0Sf75PVKw text.actor>tspan{fill:black;stroke:none;}#mermaid-svg-XoimmEL0Sf75PVKw .actor-line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-XoimmEL0Sf75PVKw .innerArc{stroke-width:1.5;stroke-dasharray:none;}#mermaid-svg-XoimmEL0Sf75PVKw .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#mermaid-svg-XoimmEL0Sf75PVKw .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#mermaid-svg-XoimmEL0Sf75PVKw #arrowhead path{fill:#333;stroke:#333;}#mermaid-svg-XoimmEL0Sf75PVKw .sequenceNumber{fill:white;}#mermaid-svg-XoimmEL0Sf75PVKw #sequencenumber{fill:#333;}#mermaid-svg-XoimmEL0Sf75PVKw #crosshead path{fill:#333;stroke:#333;}#mermaid-svg-XoimmEL0Sf75PVKw .messageText{fill:#333;stroke:none;}#mermaid-svg-XoimmEL0Sf75PVKw .labelBox{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-XoimmEL0Sf75PVKw .labelText,#mermaid-svg-XoimmEL0Sf75PVKw .labelText>tspan{fill:black;stroke:none;}#mermaid-svg-XoimmEL0Sf75PVKw .loopText,#mermaid-svg-XoimmEL0Sf75PVKw .loopText>tspan{fill:black;stroke:none;}#mermaid-svg-XoimmEL0Sf75PVKw .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-XoimmEL0Sf75PVKw .note{stroke:#aaaa33;fill:#fff5ad;}#mermaid-svg-XoimmEL0Sf75PVKw .noteText,#mermaid-svg-XoimmEL0Sf75PVKw .noteText>tspan{fill:black;stroke:none;}#mermaid-svg-XoimmEL0Sf75PVKw .activation0{fill:#f4f4f4;stroke:#666;}#mermaid-svg-XoimmEL0Sf75PVKw .activation1{fill:#f4f4f4;stroke:#666;}#mermaid-svg-XoimmEL0Sf75PVKw .activation2{fill:#f4f4f4;stroke:#666;}#mermaid-svg-XoimmEL0Sf75PVKw .actorPopupMenu{position:absolute;}#mermaid-svg-XoimmEL0Sf75PVKw .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#mermaid-svg-XoimmEL0Sf75PVKw .actor-man line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-XoimmEL0Sf75PVKw .actor-man circle,#mermaid-svg-XoimmEL0Sf75PVKw line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;stroke-width:2px;}#mermaid-svg-XoimmEL0Sf75PVKw :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 客户端新接入网络 获得 IP,可以上网了 ① DHCP Discover(广播) ② DHCP Offer(提供 IP) ③ DHCP Request(请求) ④ DHCP ACK(确认)
DHCP 分配方式
| 方式 | 说明 |
|---|---|
| 自动分配 | 客户端首次获取 IP 后永久使用 |
| 动态分配 | IP 有租期限制,到期释放回地址池(最常用) |
| 手动分配 | 管理员将特定 IP 绑定到特定 MAC 地址(保留地址) |
DHCP 与 DNS 的协作关系
DNS 服务器 DHCP 服务器 客户端 DNS 服务器 DHCP 服务器 客户端 #mermaid-svg-i3XI3cq5NWsUnXHC{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-i3XI3cq5NWsUnXHC .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-i3XI3cq5NWsUnXHC .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-i3XI3cq5NWsUnXHC .error-icon{fill:#552222;}#mermaid-svg-i3XI3cq5NWsUnXHC .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-i3XI3cq5NWsUnXHC .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-i3XI3cq5NWsUnXHC .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-i3XI3cq5NWsUnXHC .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-i3XI3cq5NWsUnXHC .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-i3XI3cq5NWsUnXHC .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-i3XI3cq5NWsUnXHC .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-i3XI3cq5NWsUnXHC .marker{fill:#333333;stroke:#333333;}#mermaid-svg-i3XI3cq5NWsUnXHC .marker.cross{stroke:#333333;}#mermaid-svg-i3XI3cq5NWsUnXHC svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-i3XI3cq5NWsUnXHC p{margin:0;}#mermaid-svg-i3XI3cq5NWsUnXHC .actor{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-i3XI3cq5NWsUnXHC text.actor>tspan{fill:black;stroke:none;}#mermaid-svg-i3XI3cq5NWsUnXHC .actor-line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-i3XI3cq5NWsUnXHC .innerArc{stroke-width:1.5;stroke-dasharray:none;}#mermaid-svg-i3XI3cq5NWsUnXHC .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#mermaid-svg-i3XI3cq5NWsUnXHC .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#mermaid-svg-i3XI3cq5NWsUnXHC #arrowhead path{fill:#333;stroke:#333;}#mermaid-svg-i3XI3cq5NWsUnXHC .sequenceNumber{fill:white;}#mermaid-svg-i3XI3cq5NWsUnXHC #sequencenumber{fill:#333;}#mermaid-svg-i3XI3cq5NWsUnXHC #crosshead path{fill:#333;stroke:#333;}#mermaid-svg-i3XI3cq5NWsUnXHC .messageText{fill:#333;stroke:none;}#mermaid-svg-i3XI3cq5NWsUnXHC .labelBox{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-i3XI3cq5NWsUnXHC .labelText,#mermaid-svg-i3XI3cq5NWsUnXHC .labelText>tspan{fill:black;stroke:none;}#mermaid-svg-i3XI3cq5NWsUnXHC .loopText,#mermaid-svg-i3XI3cq5NWsUnXHC .loopText>tspan{fill:black;stroke:none;}#mermaid-svg-i3XI3cq5NWsUnXHC .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-i3XI3cq5NWsUnXHC .note{stroke:#aaaa33;fill:#fff5ad;}#mermaid-svg-i3XI3cq5NWsUnXHC .noteText,#mermaid-svg-i3XI3cq5NWsUnXHC .noteText>tspan{fill:black;stroke:none;}#mermaid-svg-i3XI3cq5NWsUnXHC .activation0{fill:#f4f4f4;stroke:#666;}#mermaid-svg-i3XI3cq5NWsUnXHC .activation1{fill:#f4f4f4;stroke:#666;}#mermaid-svg-i3XI3cq5NWsUnXHC .activation2{fill:#f4f4f4;stroke:#666;}#mermaid-svg-i3XI3cq5NWsUnXHC .actorPopupMenu{position:absolute;}#mermaid-svg-i3XI3cq5NWsUnXHC .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#mermaid-svg-i3XI3cq5NWsUnXHC .actor-man line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-i3XI3cq5NWsUnXHC .actor-man circle,#mermaid-svg-i3XI3cq5NWsUnXHC line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;stroke-width:2px;}#mermaid-svg-i3XI3cq5NWsUnXHC :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 请求联网 获得配置,开始上网 ① 获取 IP 地址 ② 告知 DNS 服务器地址 确认 / 更新域名记录 ③ 返回 IP + DNS 地址 ④ 发起 DNS 查询(访问域名) 返回解析结果
- DHCP 负责让设备"连上网"(获得 IP 和网络参数)
- DNS 负责让设备"找到目的地"(将域名解析为 IP)
--
四、递归查询和迭代查询
DNS完整流程图:
#mermaid-svg-EDhJD87TLOhcXTen{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-EDhJD87TLOhcXTen .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-EDhJD87TLOhcXTen .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-EDhJD87TLOhcXTen .error-icon{fill:#552222;}#mermaid-svg-EDhJD87TLOhcXTen .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-EDhJD87TLOhcXTen .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-EDhJD87TLOhcXTen .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-EDhJD87TLOhcXTen .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-EDhJD87TLOhcXTen .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-EDhJD87TLOhcXTen .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-EDhJD87TLOhcXTen .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-EDhJD87TLOhcXTen .marker{fill:#333333;stroke:#333333;}#mermaid-svg-EDhJD87TLOhcXTen .marker.cross{stroke:#333333;}#mermaid-svg-EDhJD87TLOhcXTen svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-EDhJD87TLOhcXTen p{margin:0;}#mermaid-svg-EDhJD87TLOhcXTen .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-EDhJD87TLOhcXTen .cluster-label text{fill:#333;}#mermaid-svg-EDhJD87TLOhcXTen .cluster-label span{color:#333;}#mermaid-svg-EDhJD87TLOhcXTen .cluster-label span p{background-color:transparent;}#mermaid-svg-EDhJD87TLOhcXTen .label text,#mermaid-svg-EDhJD87TLOhcXTen span{fill:#333;color:#333;}#mermaid-svg-EDhJD87TLOhcXTen .node rect,#mermaid-svg-EDhJD87TLOhcXTen .node circle,#mermaid-svg-EDhJD87TLOhcXTen .node ellipse,#mermaid-svg-EDhJD87TLOhcXTen .node polygon,#mermaid-svg-EDhJD87TLOhcXTen .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-EDhJD87TLOhcXTen .rough-node .label text,#mermaid-svg-EDhJD87TLOhcXTen .node .label text,#mermaid-svg-EDhJD87TLOhcXTen .image-shape .label,#mermaid-svg-EDhJD87TLOhcXTen .icon-shape .label{text-anchor:middle;}#mermaid-svg-EDhJD87TLOhcXTen .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-EDhJD87TLOhcXTen .rough-node .label,#mermaid-svg-EDhJD87TLOhcXTen .node .label,#mermaid-svg-EDhJD87TLOhcXTen .image-shape .label,#mermaid-svg-EDhJD87TLOhcXTen .icon-shape .label{text-align:center;}#mermaid-svg-EDhJD87TLOhcXTen .node.clickable{cursor:pointer;}#mermaid-svg-EDhJD87TLOhcXTen .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-EDhJD87TLOhcXTen .arrowheadPath{fill:#333333;}#mermaid-svg-EDhJD87TLOhcXTen .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-EDhJD87TLOhcXTen .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-EDhJD87TLOhcXTen .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-EDhJD87TLOhcXTen .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-EDhJD87TLOhcXTen .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-EDhJD87TLOhcXTen .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-EDhJD87TLOhcXTen .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-EDhJD87TLOhcXTen .cluster text{fill:#333;}#mermaid-svg-EDhJD87TLOhcXTen .cluster span{color:#333;}#mermaid-svg-EDhJD87TLOhcXTen div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-EDhJD87TLOhcXTen .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-EDhJD87TLOhcXTen rect.text{fill:none;stroke-width:0;}#mermaid-svg-EDhJD87TLOhcXTen .icon-shape,#mermaid-svg-EDhJD87TLOhcXTen .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-EDhJD87TLOhcXTen .icon-shape p,#mermaid-svg-EDhJD87TLOhcXTen .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-EDhJD87TLOhcXTen .icon-shape .label rect,#mermaid-svg-EDhJD87TLOhcXTen .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-EDhJD87TLOhcXTen .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-EDhJD87TLOhcXTen .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-EDhJD87TLOhcXTen :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 🟡 迭代查询区域
🔵 递归查询区域
递归查询
www.example.com?
返回 IP
93.184.216.34
① 问根
去问 .com 服务器
② 问 TLD
去问 example.com
③ 问权威
IP: 93.184.216.34 ✅
C
L
R
T
A
时序图(按时间线展示):
权威服务器 (example.com) TLD 服务器 (.com) 根服务器 本地 DNS 服务器 客户端 权威服务器 (example.com) TLD 服务器 (.com) 根服务器 本地 DNS 服务器 客户端 #mermaid-svg-pokLVhqY6kZj8bwS{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-pokLVhqY6kZj8bwS .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-pokLVhqY6kZj8bwS .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-pokLVhqY6kZj8bwS .error-icon{fill:#552222;}#mermaid-svg-pokLVhqY6kZj8bwS .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-pokLVhqY6kZj8bwS .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-pokLVhqY6kZj8bwS .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-pokLVhqY6kZj8bwS .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-pokLVhqY6kZj8bwS .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-pokLVhqY6kZj8bwS .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-pokLVhqY6kZj8bwS .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-pokLVhqY6kZj8bwS .marker{fill:#333333;stroke:#333333;}#mermaid-svg-pokLVhqY6kZj8bwS .marker.cross{stroke:#333333;}#mermaid-svg-pokLVhqY6kZj8bwS svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-pokLVhqY6kZj8bwS p{margin:0;}#mermaid-svg-pokLVhqY6kZj8bwS .actor{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-pokLVhqY6kZj8bwS text.actor>tspan{fill:black;stroke:none;}#mermaid-svg-pokLVhqY6kZj8bwS .actor-line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-pokLVhqY6kZj8bwS .innerArc{stroke-width:1.5;stroke-dasharray:none;}#mermaid-svg-pokLVhqY6kZj8bwS .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#mermaid-svg-pokLVhqY6kZj8bwS .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#mermaid-svg-pokLVhqY6kZj8bwS #arrowhead path{fill:#333;stroke:#333;}#mermaid-svg-pokLVhqY6kZj8bwS .sequenceNumber{fill:white;}#mermaid-svg-pokLVhqY6kZj8bwS #sequencenumber{fill:#333;}#mermaid-svg-pokLVhqY6kZj8bwS #crosshead path{fill:#333;stroke:#333;}#mermaid-svg-pokLVhqY6kZj8bwS .messageText{fill:#333;stroke:none;}#mermaid-svg-pokLVhqY6kZj8bwS .labelBox{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-pokLVhqY6kZj8bwS .labelText,#mermaid-svg-pokLVhqY6kZj8bwS .labelText>tspan{fill:black;stroke:none;}#mermaid-svg-pokLVhqY6kZj8bwS .loopText,#mermaid-svg-pokLVhqY6kZj8bwS .loopText>tspan{fill:black;stroke:none;}#mermaid-svg-pokLVhqY6kZj8bwS .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);}#mermaid-svg-pokLVhqY6kZj8bwS .note{stroke:#aaaa33;fill:#fff5ad;}#mermaid-svg-pokLVhqY6kZj8bwS .noteText,#mermaid-svg-pokLVhqY6kZj8bwS .noteText>tspan{fill:black;stroke:none;}#mermaid-svg-pokLVhqY6kZj8bwS .activation0{fill:#f4f4f4;stroke:#666;}#mermaid-svg-pokLVhqY6kZj8bwS .activation1{fill:#f4f4f4;stroke:#666;}#mermaid-svg-pokLVhqY6kZj8bwS .activation2{fill:#f4f4f4;stroke:#666;}#mermaid-svg-pokLVhqY6kZj8bwS .actorPopupMenu{position:absolute;}#mermaid-svg-pokLVhqY6kZj8bwS .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#mermaid-svg-pokLVhqY6kZj8bwS .actor-man line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;}#mermaid-svg-pokLVhqY6kZj8bwS .actor-man circle,#mermaid-svg-pokLVhqY6kZj8bwS line{stroke:hsl(259.6261682243, 59.7765363128%, 87.9019607843%);fill:#ECECFF;stroke-width:2px;}#mermaid-svg-pokLVhqY6kZj8bwS :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 🔵 递归查询 🟡 迭代查询 查询 www.example.com ① 询问根服务器 返回 .com TLD 服务器地址 ② 询问 TLD 服务器 返回 example.com 权威服务器地址 ③ 询问权威服务器 返回 IP: 93.184.216.34 返回最终 IP 地址
分层结构图(展示域名层次):
#mermaid-svg-ZUTfy7sS6UKv0yKH{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-ZUTfy7sS6UKv0yKH .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-ZUTfy7sS6UKv0yKH .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-ZUTfy7sS6UKv0yKH .error-icon{fill:#552222;}#mermaid-svg-ZUTfy7sS6UKv0yKH .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-ZUTfy7sS6UKv0yKH .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-ZUTfy7sS6UKv0yKH .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-ZUTfy7sS6UKv0yKH .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-ZUTfy7sS6UKv0yKH .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-ZUTfy7sS6UKv0yKH .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-ZUTfy7sS6UKv0yKH .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-ZUTfy7sS6UKv0yKH .marker{fill:#333333;stroke:#333333;}#mermaid-svg-ZUTfy7sS6UKv0yKH .marker.cross{stroke:#333333;}#mermaid-svg-ZUTfy7sS6UKv0yKH svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-ZUTfy7sS6UKv0yKH p{margin:0;}#mermaid-svg-ZUTfy7sS6UKv0yKH .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-ZUTfy7sS6UKv0yKH .cluster-label text{fill:#333;}#mermaid-svg-ZUTfy7sS6UKv0yKH .cluster-label span{color:#333;}#mermaid-svg-ZUTfy7sS6UKv0yKH .cluster-label span p{background-color:transparent;}#mermaid-svg-ZUTfy7sS6UKv0yKH .label text,#mermaid-svg-ZUTfy7sS6UKv0yKH span{fill:#333;color:#333;}#mermaid-svg-ZUTfy7sS6UKv0yKH .node rect,#mermaid-svg-ZUTfy7sS6UKv0yKH .node circle,#mermaid-svg-ZUTfy7sS6UKv0yKH .node ellipse,#mermaid-svg-ZUTfy7sS6UKv0yKH .node polygon,#mermaid-svg-ZUTfy7sS6UKv0yKH .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-ZUTfy7sS6UKv0yKH .rough-node .label text,#mermaid-svg-ZUTfy7sS6UKv0yKH .node .label text,#mermaid-svg-ZUTfy7sS6UKv0yKH .image-shape .label,#mermaid-svg-ZUTfy7sS6UKv0yKH .icon-shape .label{text-anchor:middle;}#mermaid-svg-ZUTfy7sS6UKv0yKH .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-ZUTfy7sS6UKv0yKH .rough-node .label,#mermaid-svg-ZUTfy7sS6UKv0yKH .node .label,#mermaid-svg-ZUTfy7sS6UKv0yKH .image-shape .label,#mermaid-svg-ZUTfy7sS6UKv0yKH .icon-shape .label{text-align:center;}#mermaid-svg-ZUTfy7sS6UKv0yKH .node.clickable{cursor:pointer;}#mermaid-svg-ZUTfy7sS6UKv0yKH .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-ZUTfy7sS6UKv0yKH .arrowheadPath{fill:#333333;}#mermaid-svg-ZUTfy7sS6UKv0yKH .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-ZUTfy7sS6UKv0yKH .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-ZUTfy7sS6UKv0yKH .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-ZUTfy7sS6UKv0yKH .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-ZUTfy7sS6UKv0yKH .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-ZUTfy7sS6UKv0yKH .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-ZUTfy7sS6UKv0yKH .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-ZUTfy7sS6UKv0yKH .cluster text{fill:#333;}#mermaid-svg-ZUTfy7sS6UKv0yKH .cluster span{color:#333;}#mermaid-svg-ZUTfy7sS6UKv0yKH div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-ZUTfy7sS6UKv0yKH .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-ZUTfy7sS6UKv0yKH rect.text{fill:none;stroke-width:0;}#mermaid-svg-ZUTfy7sS6UKv0yKH .icon-shape,#mermaid-svg-ZUTfy7sS6UKv0yKH .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-ZUTfy7sS6UKv0yKH .icon-shape p,#mermaid-svg-ZUTfy7sS6UKv0yKH .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-ZUTfy7sS6UKv0yKH .icon-shape .label rect,#mermaid-svg-ZUTfy7sS6UKv0yKH .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-ZUTfy7sS6UKv0yKH .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-ZUTfy7sS6UKv0yKH .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-ZUTfy7sS6UKv0yKH :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 迭代查询
迭代查询
迭代查询
递归查询
Root
Com
Net
Cn
Auth1
Auth2
🌐 www.example.com
93.184.216.34
📧 mail.example.com
🌐 www.google.com
LocalDNS
Client
对比图(递归 vs 迭代):
#mermaid-svg-dXSZcKhxUBOJj128{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-dXSZcKhxUBOJj128 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-dXSZcKhxUBOJj128 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-dXSZcKhxUBOJj128 .error-icon{fill:#552222;}#mermaid-svg-dXSZcKhxUBOJj128 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-dXSZcKhxUBOJj128 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-dXSZcKhxUBOJj128 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-dXSZcKhxUBOJj128 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-dXSZcKhxUBOJj128 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-dXSZcKhxUBOJj128 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-dXSZcKhxUBOJj128 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-dXSZcKhxUBOJj128 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-dXSZcKhxUBOJj128 .marker.cross{stroke:#333333;}#mermaid-svg-dXSZcKhxUBOJj128 svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-dXSZcKhxUBOJj128 p{margin:0;}#mermaid-svg-dXSZcKhxUBOJj128 .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-dXSZcKhxUBOJj128 .cluster-label text{fill:#333;}#mermaid-svg-dXSZcKhxUBOJj128 .cluster-label span{color:#333;}#mermaid-svg-dXSZcKhxUBOJj128 .cluster-label span p{background-color:transparent;}#mermaid-svg-dXSZcKhxUBOJj128 .label text,#mermaid-svg-dXSZcKhxUBOJj128 span{fill:#333;color:#333;}#mermaid-svg-dXSZcKhxUBOJj128 .node rect,#mermaid-svg-dXSZcKhxUBOJj128 .node circle,#mermaid-svg-dXSZcKhxUBOJj128 .node ellipse,#mermaid-svg-dXSZcKhxUBOJj128 .node polygon,#mermaid-svg-dXSZcKhxUBOJj128 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-dXSZcKhxUBOJj128 .rough-node .label text,#mermaid-svg-dXSZcKhxUBOJj128 .node .label text,#mermaid-svg-dXSZcKhxUBOJj128 .image-shape .label,#mermaid-svg-dXSZcKhxUBOJj128 .icon-shape .label{text-anchor:middle;}#mermaid-svg-dXSZcKhxUBOJj128 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-dXSZcKhxUBOJj128 .rough-node .label,#mermaid-svg-dXSZcKhxUBOJj128 .node .label,#mermaid-svg-dXSZcKhxUBOJj128 .image-shape .label,#mermaid-svg-dXSZcKhxUBOJj128 .icon-shape .label{text-align:center;}#mermaid-svg-dXSZcKhxUBOJj128 .node.clickable{cursor:pointer;}#mermaid-svg-dXSZcKhxUBOJj128 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-dXSZcKhxUBOJj128 .arrowheadPath{fill:#333333;}#mermaid-svg-dXSZcKhxUBOJj128 .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-dXSZcKhxUBOJj128 .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-dXSZcKhxUBOJj128 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-dXSZcKhxUBOJj128 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-dXSZcKhxUBOJj128 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-dXSZcKhxUBOJj128 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-dXSZcKhxUBOJj128 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-dXSZcKhxUBOJj128 .cluster text{fill:#333;}#mermaid-svg-dXSZcKhxUBOJj128 .cluster span{color:#333;}#mermaid-svg-dXSZcKhxUBOJj128 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-dXSZcKhxUBOJj128 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-dXSZcKhxUBOJj128 rect.text{fill:none;stroke-width:0;}#mermaid-svg-dXSZcKhxUBOJj128 .icon-shape,#mermaid-svg-dXSZcKhxUBOJj128 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-dXSZcKhxUBOJj128 .icon-shape p,#mermaid-svg-dXSZcKhxUBOJj128 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-dXSZcKhxUBOJj128 .icon-shape .label rect,#mermaid-svg-dXSZcKhxUBOJj128 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-dXSZcKhxUBOJj128 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-dXSZcKhxUBOJj128 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-dXSZcKhxUBOJj128 :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 🟡 迭代查询
① 问根
去问 .com
② 问 TLD
去问权威
③ 问权威
返回 IP
IL
IR
IT
IA
🔵 递归查询
- 发请求
- 包办到底
RC
RL
客户端只交互一次
服务器负责全部查询
查询方自行追问
每个服务器只指向下一步