专业IT设备第三方维保_IT设备维保服务_IT备件服务_IT基础架构运维_IT设备维修-网度通信

H3C S12500&S10500&S7500&S7600&S7000ET 系列华三交换机 DHCP Snooping 配置组网

2025-08-28 15:04
分享到:
        H3C S12500&S10500&S7500&S7600&S7000ET 系列华三交换机 DHCP Snooping 配置组网
 
        某企业研发部有三个项目组,分布在不同的楼层中,通过楼层间的 DHCP Snooping 设备与 DHCP Server 相连。
        为了方便管理,希望通过 DHCP 服务器统一分配 IP 地址,同时要求:
        • 根据项目组的规模,分配不同范围的 IP 地址,为 group1 分配 192.168.0.2~192.168.0.39之间的 IP 地址,为 group2 分配 192.168.0.40~192.168.0.99 之间的 IP 地址,为 group3 分配 192.168.0.100~192.168.0.200 之间的 IP 地址;
        • 保证客户端从合法的服务器获取 IP 地址;
        • 禁止用户通过配置静态 IP 地址的方式接入网络
        DHCP Snooping 配置组网
 
        配置思路
        • 在多个 DHCP Snooping 设备级联的网络中,为了节省系统资源,不需要每台 DHCP Snooping 设备都记录所有 DHCP 客户端的 IP 地址和 MAC 地址的绑定信息,只需在与客户端直接相连的不信任端口上记录绑定信息。间接与 DHCP 客户端相连的不信任端口不需要记录 IP 地址和 MAC 地址绑定信息,需要配置绑定关系的不信任端口
        • 在 DHCP Snooping 设备上指向合法的 DHCP 服务器方向的端口需要设置为信任端口,以便DHCP Snooping 设备正常转发 DHCP 服务器的应答报文,保证 DHCP 客户端能够从合法的DHCP 服务器获取 IP 地址,具体需要配置为信任端口的端口,
        信任端口和非信任端口(图)
        • 为防止非法用户通过配置静态 IP 地址的方式接入网络,在用户所在 VLAN 内启用 ARP 
        Detection 功能(本例为缺省 VLAN 1 内),基于 DHCP Snooping 表项对用户进行合法性检查,保证合法用户可以正常转发报文。
        • 配置 DHCP Snooping 支持 Option82 功能,并在 DHCP 服务器上配置根据 Option82 的分配策略,从而实现为每个区域分配特定范围内的 IP 地址
        适用版本 : S10500X S12500G-AF  S12500-XS S7600E-X S7500X-X  S10500 S7600-X S12500-S S7500E-X  S7500E S7500X S7600 S7000ET
 
        配置步骤
1. Device A 的配置
# 使能 DHCP Snooping 功能。
<DeviceA> system-view
[DeviceA] dhcp snooping enable
# 在 Ten-GigabitEthernet1/0/1 上启用 DHCP Snooping 表项记录功能。
[DeviceA] interface ten-gigabitethernet 1/0/1
[DeviceA-Ten-GigabitEthernet1/0/1] dhcp snooping binding record
# 为使 Option 82 功能正常使用,需要在 DHCP 服务器和 DHCP Snooping 上都进行相应配置。如
下为 DHCP Snooping 上的相关配置:
# 在 Ten-GigabitEthernet1/0/1 上配置 DHCP Snooping 支持 Option 82 功能,并配置 Circuit ID 填
充内容为 group1。
[DeviceA-Ten-GigabitEthernet1/0/1] dhcp snooping information enable
[DeviceA-Ten-GigabitEthernet1/0/1] dhcp snooping information circuit-id string group1
[DeviceA-Ten-GigabitEthernet1/0/1] quit
# 配置 Ten-GigabitEthernet1/0/2 端口为信任端口。
[DeviceA] interface ten-gigabitethernet 1/0/2
[DeviceA-Ten-GigabitEthernet1/0/2] dhcp snooping trust
[DeviceA-Ten-GigabitEthernet1/0/2] quit
# 使能 ARP Detection 功能,对用户合法性进行检查。
[DeviceA] vlan 1
[DeviceA-vlan1] arp detection enable
[DeviceA-vlan1] quit
# 端口状态缺省为非信任状态,上行端口配置为信任状态,下行端口按缺省配置。
[DeviceA] interface ten-gigabitethernet 1/0/2
[DeviceA-Ten-GigabitEthernet1/0/2] arp detection trust
[DeviceA-Ten-GigabitEthernet1/0/2] quit
2. Device B 的配置
# 使能 DHCP Snooping 功能。
<DeviceB> system-view
[DeviceB] dhcp snooping enable
# 在 Ten-GigabitEthernet1/0/1 上启用 DHCP Snooping 表项记录功能。
[DeviceB] interface ten-gigabitethernet 1/0/1
[DeviceB-Ten-GigabitEthernet1/0/1] dhcp snooping binding record
# 为使 Option 82 功能正常使用,需要在 DHCP 服务器和 DHCP Snooping 上都进行相应配置。如
下为 DHCP Snooping 上的相关配置:
# 在 Ten-GigabitEthernet1/0/1 上配置 DHCP Snooping 支持 Option 82 功能,并配置 Circuit ID 填
充内容为 group2。
[DeviceB-Ten-GigabitEthernet1/0/1] dhcp snooping information enable
[DeviceB-Ten-GigabitEthernet1/0/1] dhcp snooping information circuit-id string group2
[DeviceB-Ten-GigabitEthernet1/0/1] quit
# 配置 Ten-GigabitEthernet1/0/2 端口为信任端口。
[DeviceB] interface ten-gigabitethernet 1/0/2
[DeviceB-Ten-GigabitEthernet1/0/2] dhcp snooping trust
[DeviceB-Ten-GigabitEthernet1/0/2] quit
# 在 Ten-GigabitEthernet1/0/3 上启用 DHCP Snooping 表项记录功能。
[DeviceB] interface ten-gigabitethernet 1/0/3
[DeviceB-Ten-GigabitEthernet1/0/3] dhcp snooping binding record
# 为使 Option 82 功能正常使用,需要在 DHCP 服务器和 DHCP Snooping 上都进行相应配置。如
下为 DHCP Snooping 上的相关配置:
# 在 Ten-GigabitEthernet1/0/3 上配置 DHCP Snooping 支持 Option 82 功能,并配置 Circuit ID 填
充内容为 group3。
[DeviceB-Ten-GigabitEthernet1/0/3] dhcp snooping information enable
[DeviceB-Ten-GigabitEthernet1/0/3] dhcp snooping information circuit-id string group3
[DeviceB-Ten-GigabitEthernet1/0/3] quit
# 使能 ARP Detection 功能,对用户合法性进行检查。
[DeviceB] vlan 1
[DeviceB-vlan1] arp detection enable
[DeviceB-vlan1] quit
# 端口状态缺省为非信任状态,上行端口配置为信任状态,下行端口按缺省配置。
[DeviceB] interface Ten-GigabitEthernet 1/0/2
[DeviceB-Ten-GigabitEthernet1/0/2] arp detection trust
[DeviceB-Ten-GigabitEthernet1/0/2] quit
3. Device C 的配置
# 使能 DHCP Snooping 功能。
<DeviceC> system-view
[DeviceC] dhcp snooping enable
# 配置 Ten-GigabitEthernet1/0/2 端口为信任端口。
[DeviceC] interface ten-gigabitethernet 1/0/2
[DeviceC-Ten-GigabitEthernet1/0/2] dhcp snooping trust
[DeviceC-Ten-GigabitEthernet1/0/2] quit
4. Device D 的配置
# 配置 VLAN 接口 2 的 IP 地址。
<DeviceD> system-view
[DeviceD] vlan 2
[DeviceD-vlan2] port ten-gigabitethernet 1/0/1
[DeviceD-vlan2] quit
[DeviceD] interface vlan-interface 2
[DeviceD-Vlan-interface2] ip address 192.168.0.1 24
[DeviceD-Vlan-interface2] quit
# 使能 DHCP 服务。
[DeviceD] dhcp enable
# 配置 VLAN 接口 2 工作在 DHCP 服务器模式。
[DeviceD] interface vlan-interface 2
[DeviceD-Vlan-interface2] dhcp select server
[DeviceD-Vlan-interface2] quit
# 为使 Option 82 功能正常使用,需要在 DHCP 服务器和 DHCP 中继上都进行相应配置。如下为
DHCP 服务器上的相关配置:
# 创建 DHCP 用户类 group1,匹配请求报文中包含 Option 82 选项,并且该选项的第 3 字节到第
8 字节为 0x67726F757031(表示 Circuit ID 子选项内容为 group1)的客户端。
[DeviceD] dhcp class group1
[DeviceD-dhcp-class-group1] if-match rule 1 option 82 hex 67726F757031 offset 2 length 6
[DeviceD-dhcp-class-group1] quit
# 创建 DHCP 用户类 group2,匹配请求报文中包含 Option 82 选项,并且该选项的第 3 字节到第
8 字节为 0x67726F757032(表示 Circuit ID 子选项内容为 group2)的客户端。
[DeviceD] dhcp class group2
[DeviceD-dhcp-class-group2] if-match rule 1 option 82 hex 67726F757032 offset 2 length 6
[DeviceD-dhcp-class-group2] quit
# 创建 DHCP 用户类 group3,匹配请求报文中包含 Option 82 选项,并且该选项的第 3 字节到第
8 字节为 0x67726F757033(表示 Circuit ID 子选项内容为 group3)的客户端。
[DeviceD] dhcp class group3
[DeviceD-dhcp-class-group3] if-match rule 1 option 82 hex 67726F757033 offset 2 length 6
[DeviceD-dhcp-class-group3] quit
# 配置 DHCP 地址池 1。
[DeviceD] dhcp server ip-pool 1
# 配置地址池动态分配的主网段。
[DeviceD-dhcp-pool-1] network 192.168.0.0 mask 255.255.255.0
viceD-dhcp-pool-1] class group1 range 192.168.0.2 192.168.0.39
# 配置 DHCP 地址池为 DHCP 用户类 group2 动态分配的 IP 地址范围。
[DeviceD-dhcp-pool-1] class group2 range 192.168.0.40 192.168.0.99
# 配置 DHCP 地址池为 DHCP 用户类 group3 动态分配的 IP 地址范围。
[DeviceD-dhcp-pool-1] class group3 range 192.168.0.100 192.168.0.200
# 配置 VLAN 接口 2 引用地址池 1。
[DeviceD] interface vlan-interface 2
[DeviceD-Vlan-interface2] dhcp server apply ip-pool 1
[DeviceD-Vlan-interface2] quit
3.5 验证配置
# 在 group2 中的某一用户 PC 上输入如下命令,可查看申请到的 IP 地址。按照同样的方式,可以
确认 group 1 和 group 3 中的用户也得到指定范围内的地址。
C:Documents and SettingsAdministrator>ipconfig
Windows IP Configuration
Ethernet adapter bb:
 Connection-specific DNS Suffix . :
 IP Address. . . . . . . . . . . . : 192.168.0.44
 Subnet Mask . . . . . . . . . . . : 255.255.255.0
 Default Gateway . . . . . . . . . :
# 假设 group2 里的非法用户配置了一个 192.168.0.66 的 IP 地址,会发现无法访问外部网络。
3.6 配置文件
• Device A
#
dhcp snooping enable
#
vlan 1
arp detection enable
#
interface Ten-GigabitEthernet1/0/1
dhcp snooping binding record
dhcp snooping information enable
dhcp snooping information circuit-id string group1
#
interface Ten-GigabitEthernet1/0/2
arp detection trust
dhcp snooping trust
#
• Device B
#
dhcp snooping enable
#
vlan 1
arp detection enable
#
interface Ten-GigabitEthernet1/0/1
dhcp snooping binding record
dhcp snooping information enable
dhcp snooping information circuit-id string group2
#
interface Ten-GigabitEthernet1/0/2
arp detection trust
dhcp snooping trust
#
interface Ten-GigabitEthernet1/0/3
dhcp snooping binding record
dhcp snooping information enable
dhcp snooping information circuit-id string group3
#
• Device C
#
dhcp snooping enable
#
interface Ten-GigabitEthernet1/0/2
dhcp snooping trust
#
• Device D
#
dhcp enable
#
vlan 2
#
dhcp class group1
if-match rule 1 option 82 hex 67726f757031 offset 2 length 6
#
dhcp class group2
if-match rule 1 option 82 hex 67726f757032 offset 2 length 6
#
dhcp class group3
if-match rule 1 option 82 hex 67726f757033 offset 2 length 6
#
dhcp server ip-pool 1
network 192.168.0.0 mask 255.255.255.0
class group1 range 192.168.0.2 192.168.0.39
class group2 range 192.168.0.40 192.168.0.99
class group3 range 192.168.0.100 192.168.0.200
#
interface Vlan-interface2
ip address 192.168.0.1 255.255.255.0
dhcp server apply ip-pool 1
#
上一篇:IT设备维保服务核心内容与服务价值
下一篇:思科防火墙rommon模式恢复IOS的方法