思科设备参考:
一,技术简介
DHCP中继,可以实现在不同子网和物理网段之间处理和转发DHCP信息的功能。如果DHCP客户机与DHCP服务器在同一个物理网段,则客户机可以正确地获得动态分配的IP地址。如果不在同一个物理网段,则需要DHCP Relay Agent(中继代理)。
二,实验目的
使用DHCP中继技术让处于不同vlan的PC自动获取IP地址
三,配前测试
PC无法通过DHCP服务获取IP地址
四,配置命令
Switch1
[Huawei]undo info-center enable
[Huawei]vlan batch 10 20 批量创建vlan
-
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type access
[Huawei-GigabitEthernet0/0/1]port default vlan 10 默认vlan10通过
[Huawei-GigabitEthernet0/0/1]quit
-
[Huawei]int g0/0/2
[Huawei-GigabitEthernet0/0/2]port link-t
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 20 默认vlan20通过
[Huawei-GigabitEthernet0/0/2]quit
-
[Huawei]int g0/0/3
[Huawei-GigabitEthernet0/0/3]port link-type trunk
[Huawei-GigabitEthernet0/0/3]port trunk allow-pass vlan 10 20 允许vlan10,20通过
[Huawei-GigabitEthernet0/0/3]quit
-
[Huawei]display current-configuration
Switch2
[Huawei]undo info-center enable 关闭信息中心的日志功能
[Huawei]vlan batch 10 20 100 批量创建vlan
-
[Huawei]int g00/0/1
[Huawei-GigabitEthernet0/0/1]port link-type trunk
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20 允许vlan10,20通过
[Huawei-GigabitEthernet0/0/1]quit
-
[Huawei]int g0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 100 默认vlan100通过
[Huawei-GigabitEthernet0/0/2]quit
-
[Huawei]dhcp enable
-
[Huawei]dhcp server group mygroup 创建名为
mygroup
的DHCP服务器组[Huawei-dhcp-server-group-mygroup]dhcp-server 192.168.100.2 添加DHCP服务器的IP
[Huawei-dhcp-server-group-mygroup]quit
-
[Huawei]int vlanif 10 进vlanif 10接口的配置模式
[Huawei-Vlanif10]ip address 192.168.10.1 24 给vlanif 10接口分配IP地址
[Huawei-Vlanif10]dhcp select relay 设置该接口为DHCP中继模式
[Huawei-Vlanif10]dhcp relay server-ip 192.168.100.2 设置DHCP中继服务器的IP地址
[Huawei-Vlanif10]quit
-
[Huawei]int vlanif 20
[Huawei-Vlanif20]ip address 192.168.20.1 24
[Huawei-Vlanif20]dhcp select relay
[Huawei-Vlanif20]dhcp relay server-select mygroup 选择
mygroup
作为DHCP服务器组[Huawei-Vlanif20]quit server-select 和 server-ip 都可以
-
[Huawei]int vlanif 100 进vlan100接口的配置模式
[Huawei-Vlanif100]ip address 192.168.100.1 24 给vlan100接口分配IP地址
[Huawei-Vlanif100]quit
-
[Huawei]display current-configuration 显示当前设备的配置信息
Router
[Huawei]undo info-center enable 关闭信息中心的日志功能。
-
[Huawei]ip pool vlan_10 创建名为vlan_10的IP地址池
[Huawei-ip-pool-vlan_10]network 192.168.10.0 mask 24 设置IP地址池的网络地址
[Huawei-ip-pool-vlan_10]gateway-list 192.168.10.1 设置网关地址
[Huawei-ip-pool-vlan_10]dns-list 8.8.8.8 设置DNS服务器地址
[Huawei-ip-pool-vlan_10]excluded-ip-address 192.168.10.10 192.168.10.254 排除IP地址
[Huawei-ip-pool-vlan_10]quit
-
[Huawei]ip pool vlan_20
[Huawei-ip-pool-vlan_20]network 192.168.20.0 mask 24
[Huawei-ip-pool-vlan_20]gateway-list 192.168.20.1
[Huawei-ip-pool-vlan_20]dns-list 8.8.8.8
[Huawei-ip-pool-vlan_20]excluded-ip-address 192.168.20.10 192.168.20.254
[Huawei-ip-pool-vlan_20]quit
-
[Huawei]dhcp enable 全局启用DHCP服务
-
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.100.2 24 给接口分配IP地址
[Huawei-GigabitEthernet0/0/0]dhcp select global 接口使用全局地址池进行DHCP分配
[Huawei-GigabitEthernet0/0/0]quit
-
[Huawei]ip route-static 192.168.10.0 24 192.168.100.1
配置一条静态路由,目标网络为192.168.10.0/24,下一跳地址为192.168.100.1
-
[Huawei]ip route-static 192.168.20.0 24 192.168.100.1
配置一条静态路由,目标网络为192.168.20.0/24,下一跳地址为192.168.100.1
-
[Huawei]display current-configuration 显示当前设备的配置信息。
五,配后测试
PC可以通过DHCP服务获取IP地址