DHCP中继实验

DHCP中继实验

中继的功能

解决跨网段分配 IP 地址的问题,使 DHCP 客户端与服务器位于不同子网时仍能获取 IP。

工作原理
  1. 客户端广播请求中继设备(路由器/三层交换机) 接收请求。
  2. 中继设备 将请求单播转发至指定 DHCP 服务器。
  3. 服务器响应中继设备客户端

一 实验拓扑图

在这里插入图片描述

二 设备命名与IP地址规划

设备名接口编号IP地址规划
R1GE0/0192.168.1.1/24
R2GE0/0192.168.1.2/24
GE0/1192.168.2.254/24
R3GE0/0DHCP获取

三 实验步骤

​ 按照图示连接好线缆

​ 配置DHCP,R1为DHCP服务器,需要跨越网段为R3分配IP地址

​ 由于192.168.2.1~192.168.2.9已经被其他设备固定使用,所以需要排除该地址段

1 配置ip地址

在DHCP Server
[DHCP Server]int g0/0
[DHCP Server-GigabitEthernet0/0]ip ad 192.168.1.1 24
在DHCP Relay
[DHCP Relay]int g0/0
[DHCP Relay-GigabitEthernet0/0]ip ad 192.168.1.2 24
[DHCP Relay-GigabitEthernet0/0]int g0/1
[DHCP Relay-GigabitEthernet0/1]ip ad 192.168.2.254 24

2 在DHCP Server上使能DHCP功能

[DHCP Server]dhcp enable 

3 配置dhcp的地址池

[DHCP Server]dhcp server ip-pool 1
[DHCP Server-dhcp-pool-1]network 192.168.2.0 24
[DHCP Server-dhcp-pool-1]gateway-list 192.168.2.254
[DHCP Server-dhcp-pool-1]dns-list 114.114.114.114
[DHCP Server-dhcp-pool-1]expired day 1
[DHCP Server-dhcp-pool-1]qu
[DHCP Server]dhcp server forbidden-ip 192.168.2.1 192.168.2.9			//排除IP地址

4 配置DHCP中继

[DHCP Relay]dhcp enable
[DHCP Relay]int g0/1
[DHCP Relay-GigabitEthernet0/1]dhcp select relay	//	设置GE0/1接口为DHCP中继接口
[DHCP Relay-GigabitEthernet0/1]dhcp relay server-address 192.168.1.1	告诉中继接口,DHCP服务器的IP地址为192.168.1.1
[DHCP Relay-GigabitEthernet0/1]

5 查看DHCP Client分配效果

[DHCP Client]int g0/0
[DHCP Client-GigabitEthernet0/0]ip ad dhcp-a
[DHCP Client-GigabitEthernet0/0]ip ad dhcp-alloc 

6 查看DHCP Client客户端地址获取情况

[DHCP Client-GigabitEthernet0/0]dis ip int brief 
*down: administratively down
(s): spoofing  (l): loopback
Interface           Physical Protocol IP address/Mask    VPN instance Description  
GE0/0               up       up       169.254.3.0/16     --           --
GE0/1               down     down     --                 --           --
GE0/2               down     down     --                 --           --
GE5/0               down     down     --                 --           --
GE5/1               down     down     --                 --           --
GE6/0               down     down     --                 --           --
GE6/1               down     down     --                 --           --
Ser1/0              down     down     --                 --           --
Ser2/0              down     down     --                 --           --
Ser3/0              down     down     --                 --           --
Ser4/0              down     down     --                 --           --

7 在DHCP Server上配置一条去往DHCP Client的路由,使其网络互通

[DHCP Server]ip route-static 192.168.2.0 24 192.168.1.2		//手动配置IP路由目标网络为192.168.2.0/24,下一跳为192.168.1.2

8 重启DHCP Client接口

[DHCP Client-GigabitEthernet0/0]shutdown 	//关闭接口
%Jul  7 20:14:21:540 2025 DHCP Client IFNET/3/PHY_UPDOWN: Physical state on the interface GigabitEthernet0/0 changed to down.
%Jul  7 20:14:21:540 2025 DHCP Client IFNET/5/LINK_UPDOWN: Line protocol state on the interface GigabitEthernet0/0 changed to down.
[DHCP Client-GigabitEthernet0/0]undo shutdown 	// 取消接口
[DHCP Client-GigabitEthernet0/0]%Jul  7 20:14:32:490 2025 DHCP Client IFNET/3/PHY_UPDOWN: Physical state on the interface GigabitEthernet0/0 changed to up.
%Jul  7 20:14:32:492 2025 DHCP Client IFNET/5/LINK_UPDOWN: Line protocol state on the interface GigabitEthernet0/0 changed to up

9 再次查看DHCP Client客户端地址获取情况

[DHCP Client-GigabitEthernet0/0]dis ip int brief
*down: administratively down
(s): spoofing  (l): loopback
Interface           Physical Protocol IP address/Mask    VPN instance Description  
GE0/0               up       up       192.168.2.10/24    --           --
GE0/1               down     down     --                 --           --
GE0/2               down     down     --                 --           --
GE5/0               down     down     --                 --           --
GE5/1               down     down     --                 --           --
GE6/0               down     down     --                 --           --
GE6/1               down     down     --                 --           --
Ser1/0              down     down     --                 --           --
Ser2/0              down     down     --                 --           --
Ser3/0              down     down     --                 --           --
Ser4/0              down     down     --                 --           --
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值