DHCP 与 DNS CCNA 解释:是什么让网络悄无声息地运作?
DHCP 与 DNS CCNA 简单解释:两种协议在每一次连接背后悄悄工作。
每当设备连接到网络并浏览网站时,两个无形的英雄在幕后工作:
- DHCP(动态主机配置协议) – 自动分配 IP 地址
- DNS(域名系统) – 将域名转换为 IP 地址
两者都是 必不可少的 用于网络和 经过严格测试 在 CCNA 考试中。
什么是 DHCP?
DHCP 自动分配 IP 地址, 子网掩码, 默认网关,以及 DNS 服务器地址 给网络中的设备。
没有 DHCP:
你必须手动配置每个设备。
使用 DHCP:
IP 地址会自动分配——无需手动设置。
DHCP 工作原理 – DORA 过程
| 步骤 | 描述 |
|---|---|
| 发现 | 客户端广播请求以寻找 DHCP 服务器 |
| 提供 | 服务器回复可用 IP |
| 请求 | 客户端请求接受所提供的 IP |
| 确认 | 服务器确认并租赁 IP |
👉 该过程被称为 DORA (Discover, Offer, Request, Acknowledge).
DHCP Configuration in Cisco Routers
Router(config)# ip dhcp pool LAN-POOL
Router(dhcp-config)# network 192.168.10.0 255.255.255.0
Router(dhcp-config)# default-router 192.168.10.1
Router(dhcp-config)# dns-server 8.8.8.8
Router(config)# ip dhcp excluded-address 192.168.10.1 192.168.10.10
➡️ This sets up a pool of IP addresses and reserves .1 to .10 for static/manual assignments.
DHCP Relay: When the Server Isn’t on the Local Subnet
DHCP’s Discover message is a broadcast, and broadcasts do not cross a router by default – so a client on a subnet with no local DHCP server would never reach one sitting elsewhere on the network. The fix is a DHCP relay (also called an IP helper), configured on the router interface closest to the client:
Router(config)# interface gigabitEthernet 0/1
Router(config-if)# ip helper-address 192.168.1.5
This converts the client’s broadcast into a unicast packet aimed directly at the DHCP server’s address, and relays the server’s reply back the same way. This is exactly how most real enterprise networks work – one or two central DHCP servers, with every other subnet’s router relaying requests to them rather than running a DHCP server on every single subnet.
DHCP Troubleshooting Commands
When a client is not getting an address, these three commands narrow down the cause quickly:
Router# show ip dhcp binding
Router# show ip dhcp conflict
Router# debug ip dhcp server events
show ip dhcp binding confirms whether the router has actually leased an address to the client’s MAC – no binding means the Discover never reached the pool, which usually points back to a missing ip helper-address on the client’s subnet. show ip dhcp conflict shows addresses the server detected as already in use, often caused by a static IP accidentally set inside the DHCP pool’s range.
What is DNS?
DNS (Domain Name System) translates human-friendly domain names like google.com into machine-friendly IP addresses like 142.250.190.78.
Without DNS, users would need to remember numeric IP addresses to visit websites.
Testing DNS Resolution Directly
Before assuming a “website won’t load” problem is DNS, confirm it directly rather than guessing – a browser error message does not tell you which layer actually failed:
C:\> nslookup google.com
$ dig google.com
nslookup (Windows and also available on Linux/macOS) and dig (Linux/macOS, more detailed output) both query a DNS server directly and show exactly what it returned. If the lookup succeeds here but the website still does not load in a browser, the problem is not DNS – it is routing, a firewall, or the web server itself. This distinction, confirmed with one command instead of assumed, is exactly the kind of troubleshooting discipline the CCNA exam expects and that saves real time in the field.
How DNS Works – Step-by-Step
- You type
facebook.comin your browser. - The DNS resolver checks if it already knows the IP.
- If not, it queries a root server → top-level domain server → authoritative server.
- It returns the IP to your browser → website loads!
DNS Terms to Know (for CCNA)
| Term | 描述 |
|---|---|
| A Record | Maps domain to IPv4 address |
| AAAA Record | Maps domain to IPv6 address |
| CNAME | Alias for another domain |
| MX Record | Directs email to the mail server |
DHCP vs Static IP – When to Use What?
| DHCP (Dynamic) | Static IP |
|---|---|
| Automatically assigned | Manually configured |
| Great for clients | Best for servers, printers |
| Easy to manage | Harder in large networks |
| IP may change | IP remains the same |
🧪 CCNA Packet Tracer Lab – DHCP in Action
Lab Scenario:
You have a router, a switch, and multiple PCs. PCs should receive IPs automatically.
- Configure DHCP pool on router
- Connect PCs and enable DHCP
- Verify IPs are assigned correctly using
ipconfig
Optional: Assign a static IP to a printer or server and exclude that range.
📡 Real-World DNS Example
Let’s say you own yourbrand.com.
To point it to a hosting server:
- A Record → your website’s IP
- CNAME → alias like
blog.yourbrand.comto redirect to a CMS - MX Record → email hosting provider
DNS is the backbone of all web and mail-based services.
✅ Essential Network Devices for CCNA
🌐 Cisco DHCP Configuration Guide
🌐 How DNS Works – Cloudflare Docs
🙋♂️ FAQ – DHCP and DNS
What is DHCP in CCNA?
DHCP stands for Dynamic Host Configuration Protocol. It automatically assigns IP configuration to network devices, covered in CCNA exams and labs.
What does DNS do in a network?
DNS resolves domain names to IP addresses, allowing users to access websites using names instead of numbers.
Can I use DHCP and DNS together?
Yes. DHCP assigns the IP, and includes the DNS server address in the lease, allowing devices to resolve domain names immediately.
Is DHCP better than static IP?
For clients, yes. For devices like printers, servers, and routers — static IPs are preferred.
如果你更愿意有人一步步带你完成此过程,或者需要特定的 Packet Tracer 实验完成并解释,而不是自己摸索,请查看 CCNA 与 Packet Tracer 辅导 页面了解其工作原理。

