一、实验拓扑
![](https://img-blog.csdnimg.cn/img_convert/f445db7ab82668a1f794d9ca7b4f06d2.png)
二、实验要求
- 要求PC通过DHCP中继的方式从服务器自动获取到IP地址和其他配置参数
三、实验步骤
[server]int g0/0
[server-GigabitEthernet0/0]ip add 10.0.0.1 30
[server-GigabitEthernet0/0]dhcp enable
[server]dhcp ser ip vlan10
[server-dhcp-pool-vlan10]net 192.168.1.0 24
[server-dhcp-pool-vlan10]gateway 192.168.1.254
[server-dhcp-pool-vlan10]dns 8.8.8.8
[server-dhcp-pool-vlan10]expired day 2 #配置地址池参数
[server]dhcp ser ip vlan20
[server-dhcp-pool-vlan20]net 192.168.2.0 24
[server-dhcp-pool-vlan20]gateway 192.168.2.254
[server-dhcp-pool-vlan20]ex d 2
[server-dhcp-pool-vlan20]dns 8.8.8.8
[server]dhcp server forbidden-ip 192.168.1.254 #不允许被分配的地址
[server]dhcp server forbidden-ip 192.168.2.254
[server]ip route-static 192.168.1.0 24 10.0.0.2
[server]ip route-static 192.168.2.0 24 10.0.0.2 #将中继与服务器间打通
[relay]vlan 10 20
[relay]int g1/0/2
[relay-GigabitEthernet1/0/2]p l t
[relay-GigabitEthernet1/0/2]p t per v 10 20 #放行相关vlan
[relay]int g1/0/1
[relay-GigabitEthernet1/0/1]p l r
[relay-GigabitEthernet1/0/1]ip add 10.0.0.2 30 #与服务器相连的接口配置IP地址
[relay]int vlan 10
[relay-Vlan-interface10]ip add 192.168.1.254 24
[relay-Vlan-interface10]dhcp select relay
[relay-Vlan-interface10]dhcp relay server 10.0.0.1
[relay-Vlan-interface10]int vlan 20
[relay-Vlan-interface20]ip add 192.168.2.254 24
[relay-Vlan-interface20]dhcp select relay #将需要被分配地址的接口配置为中继模式
[relay-Vlan-interface20]dhcp relay ser 10.0.0.1 #配置服务器地址
[relay]ip route-static 0.0.0.0 0 10.0.0.1 #打通与服务器间通信
[relay]dhcp enable #必须使能DHCP,否则无效
[jr]int g1/0/2
[jr-GigabitEthernet1/0/2]p a v 10
[jr-GigabitEthernet1/0/2]int g1/0/3
[jr-GigabitEthernet1/0/3]p a v 20 #规划所属vlan
[jr-GigabitEthernet1/0/3]int g1/0/1
[jr-GigabitEthernet1/0/1]p l t
[jr-GigabitEthernet1/0/1]p t per v 10 20 #放行
四、实验结果
![](https://img-blog.csdnimg.cn/img_convert/b0f3fb039d2aa9068032d8177336ae46.png)