如果DHCP服务器与客户端不在同一个物理网段,但客户机又需要正确地获得动态分配的地址,则需要使用到DHCP+Relay+Agent,也叫DHCP中继代理。DHCP+Relay也叫DHCP中继,其可以实现在不同子网和物理网段之间处理和转发dhcp信息的功能。这样,多个网络上的DHCP客户端可以使用同一个DHCP服务器,既节省了成本,又便于集中管理。
实验拓扑
配置需求
1. 按图所示配置IP地址、vlan等基础配置;2. DHCP Server服务器能够跨网段为vlan5、vlan6分配地址,PC_4能够从DHCP服务器上获取192.168.5.0/24网段的地址,PC_5能够从DHCP服务器上获取192.168.6.0/24网段的地址
配置步骤
1. 基础配置;完成各设备完成ip地址、vlan等基础配置;
DHCP服务器配置
[DHCP_Server_1]vlan 7[DHCP_Server_1-vlan7]int vlan7[DHCP_Server_1-Vlan-interface7]ip a 192.168.7.100 24[DHCP_Server_1-Vlan-interface7]int g 1/0/1[DHCP_Server_1-GigabitEthernet1/0/1]port access vlan 7
核心交换机配置
[HX_2]int g 1/0/1[HX_2-GigabitEthernet1/0/1]port access vlan 7[HX_2-GigabitEthernet1/0/1]int vlan 7[HX_2-Vlan-interface7]ip a 192.168.7.254 24[HX_2-Vlan-interface7]int vlan 5[HX_2-Vlan-interface5]ip a 192.168.5.254 24[HX_2-Vlan-interface5]int vlan 6[HX_2-Vlan-interface6]ip a 192.168.6.254 24[HX_2-Vlan-interface6]int g 1/0/2[HX_2-GigabitEthernet1/0/2]port link-type trunk [HX_2-GigabitEthernet1/0/2]port trunk permit vlan 5[HX_2-GigabitEthernet1/0/2]port trunk permit vlan 6[HX_2-GigabitEthernet1/0/2]undo port trunk permit vlan 1
汇聚交换机配置
[HJ_3]int g 1/0/2[HJ_3-GigabitEthernet1/0/2]port link-type trunk [HJ_3-GigabitEthernet1/0/2]undo port trunk permit vlan 1[HJ_3-GigabitEthernet1/0/2]port trunk permit vlan 5 to 7[HJ_3-GigabitEthernet1/0/4]vlan 5 to 7[HJ_3]int g 1/0/4[HJ_3-GigabitEthernet1/0/4]port access vlan 5[HJ_3-GigabitEthernet1/0/4]int g 1/0/5[HJ_3-GigabitEthernet1/0/5]port access vlan 6
PC_4配置
PC_5配置
2. DHCP服务器配置2.1 配置默认静态路由,使DHCP服务器与vlan5 vlan6网段互通;
[DHCP_Server_1]ip route-static 0.0.0.0 0 192.168.7.254
2.2 开启DHCP功能,并创建vlan5、vlan6的DHCP地址池,宣告网段,网关,DNS;
[DHCP_Server_1]dhcp enable [DHCP_Server_1]dhcp server ip-pool vlan5[DHCP_Server_1-dhcp-pool-vlan5]network 192.168.5.0 mask 255.255.255.0[DHCP_Server_1-dhcp-pool-vlan5]gateway-list 192.168.5.254[DHCP_Server_1-dhcp-pool-vlan5]dns-list 114.114.114.114 8.8.8.8[DHCP_Server_1-dhcp-pool-vlan5]dhcp server ip-pool vlan6[DHCP_Server_1-dhcp-pool-vlan6]network 192.168.6.0 mask 255.255.255.0[DHCP_Server_1-dhcp-pool-vlan6]gateway-list 192.168.6.254[DHCP_Server_1-dhcp-pool-vlan6]dns-list 114.114.114.114 8.8.8.8
3. 核心交换机配置
3.1 在核心交换机上打开DHCP功能
[HX_2]dhcp enable
3.2 在连接客户端的接口(vlan5、vlan6)上打开DHCP中继功能,并指定DHCP服务器的IP地址
[HX_2]int vlan 5[HX_2-Vlan-interface5]dhcp select relay [HX_2-Vlan-interface5]dhcp relay server-address 192.168.7.100[HX_2-Vlan-interface5]int vlan 6[HX_2-Vlan-interface6]dhcp select relay [HX_2-Vlan-interface6]dhcp relay server-address 192.168.7.100
配置验证:
dhcp客户端上自动获取到地址
附:
关注我,获取此次配置工程、更多配置案例、最新影视及常用办公软件