From f0f0522fde9ff4afc6e9965be5e586b56ce2a4e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=A9=89=E5=A9=B7?= <14091842+dreaming-of-becoming-a-fupo@user.noreply.gitee.com> Date: Sun, 27 Apr 2025 03:31:00 +0800 Subject: [PATCH] =?UTF-8?q?4.25=E5=8F=B7=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...45\231\250dhcp\351\205\215\347\275\256.md" | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 "28 \345\274\240\345\251\211\345\251\267/20250425 \350\267\257\347\224\261\345\231\250dhcp\351\205\215\347\275\256.md" diff --git "a/28 \345\274\240\345\251\211\345\251\267/20250425 \350\267\257\347\224\261\345\231\250dhcp\351\205\215\347\275\256.md" "b/28 \345\274\240\345\251\211\345\251\267/20250425 \350\267\257\347\224\261\345\231\250dhcp\351\205\215\347\275\256.md" new file mode 100644 index 0000000..75ea5b1 --- /dev/null +++ "b/28 \345\274\240\345\251\211\345\251\267/20250425 \350\267\257\347\224\261\345\231\250dhcp\351\205\215\347\275\256.md" @@ -0,0 +1,102 @@ +# 笔记 + +## 二、路由器 DHCP 配置步骤 + +### 1. 全局配置模式下启用 DHCP 服务 + +``` +Router(config)#service dhcp +``` + +### 2. 定义 DHCP 地址池 + +``` +Router(config)#ip dhcp pool +``` + +- :自定义地址池名称,例如Office_Pool。 + +### 3. 配置地址池参数 + +``` +Router(dhcp - config)#network +Router(dhcp - config)#default - router +Router(dhcp - config)#dns - server +``` + +- network:指定可分配的 IP 地址段及子网掩码,如[192.168.1.0](https://gitee.com/link?target=http%3A%2F%2F192.168.1.0) [255.255.255.0](https://gitee.com/link?target=http%3A%2F%2F255.255.255.0)。 +- default - router:设置默认网关 IP 地址,例如[192.168.1.1](https://gitee.com/link?target=http%3A%2F%2F192.168.1.1)。 +- dns - server:配置 DNS 服务器 IP 地址,可设置多个,如[8.8.8.8](https://gitee.com/link?target=http%3A%2F%2F8.8.8.8) [8.8.4.4](https://gitee.com/link?target=http%3A%2F%2F8.8.4.4)。 + +### 4. 排除 IP 地址(可选) + +``` +Router(config)#ip dhcp excluded - address +``` + +- 用于排除不参与动态分配的 IP 地址,例如Router(config)#ip dhcp excluded - address [192.168.1.1](https://gitee.com/link?target=http%3A%2F%2F192.168.1.1) [192.168.1.10](https://gitee.com/link?target=http%3A%2F%2F192.168.1.10) ,将 1 - 10 的 IP 地址排除。 + +### 5. 接口配置(关联 DHCP 地址池) + +``` +Router(config)#interface +Router(config - if)#ip helper - address +``` + +- 如果路由器作为中继代理,需在连接客户端的接口配置ip helper - address,指定 DHCP 服务器 IP 地址。若路由器本身作为 DHCP 服务器,此步骤可省略。 + +## 三、验证与测试 + +1. **查看 DHCP 地址池配置** + +``` +Router#show ip dhcp pool +``` + +1. **查看 DHCP 绑定信息** + +``` +Router#show ip dhcp binding +``` + +1. **客户端验证** + +- - 在客户端(如 PC)使用ipconfig /renew命令获取 IP 地址。 +- - 使用ipconfig /all查看获取的 IP 地址、网关、DNS 等信息是否正确。 + +## 四、常见故障排查 + +1. **客户端无法获取 IP 地址** + +- - 检查路由器是否启用 DHCP 服务:show running - config | include service dhcp。 +- - 确认地址池配置是否正确,包括网络段、网关、DNS 等参数。 +- - 查看接口配置,若作为中继代理,检查ip helper - address配置是否正确。 + +1. **获取的 IP 地址不正确** + +- - 检查地址池排除地址范围是否有误,导致分配冲突。 +- - 确认子网掩码配置是否与网络规划一致。 + +## 五、案例示例 + +假设网络环境如下: + +- 网络地址:[192.168.1.0/24](https://gitee.com/link?target=http%3A%2F%2F192.168.1.0%2F24) +- 网关:[192.168.1.1](https://gitee.com/link?target=http%3A%2F%2F192.168.1.1) +- DNS 服务器:[8.8.8.8](https://gitee.com/link?target=http%3A%2F%2F8.8.8.8) +- 排除地址:[192.168.1.1](https://gitee.com/link?target=http%3A%2F%2F192.168.1.1) - [192.168.1.10](https://gitee.com/link?target=http%3A%2F%2F192.168.1.10) + +配置命令如下: + +``` +! 启用DHCP服务 +Router(config)#service dhcp +! 排除IP地址 +Router(config)#ip dhcp excluded - address 192.168.1.1 192.168.1.10 +! 定义DHCP地址池 +Router(config)#ip dhcp pool Office_Pool +Router(dhcp - config)#network 192.168.1.0 255.255.255.0 +Router(dhcp - config)#default - router 192.168.1.1 +Router(dhcp - config)#dns - server 8.8.8.8 +``` + -- Gitee