评分并提供意见反馈 :
华为采用机器翻译与人工审校相结合的方式将此文档翻译成不同语言,希望能帮助您更容易理解此文档的内容。 请注意:即使是最好的机器翻译,其准确度也不及专业翻译人员的水平。 华为对于翻译的准确性不承担任何责任,并建议您参考英文文档(已提供链接)。
配置设备作为DHCP中继示例(中继与服务器处于同一网络)
操作步骤
- 在SwitchA上配置DHCP中继。
# 配置接口加入VLAN。
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan batch 100 200 [SwitchA] interface gigabitethernet 0/0/2 [SwitchA-GigabitEthernet0/0/2] port link-type hybrid [SwitchA-GigabitEthernet0/0/2] port hybrid pvid vlan 100 [SwitchA-GigabitEthernet0/0/2] port hybrid untagged vlan 100 [SwitchA-GigabitEthernet0/0/2] quit [SwitchA] interface gigabitethernet 0/0/1 [SwitchA-GigabitEthernet0/0/1] port link-type hybrid [SwitchA-GigabitEthernet0/0/1] port hybrid pvid vlan 200 [SwitchA-GigabitEthernet0/0/1] port hybrid untagged vlan 200 [SwitchA-GigabitEthernet0/0/1] quit [SwitchA] interface vlanif 200 [SwitchA-Vlanif200] ip address 10.10.20.1 24 [SwitchA-Vlanif200] quit
# 在接口下使能DHCP中继功能。
[SwitchA] dhcp enable [SwitchA] interface vlanif 100 [SwitchA-Vlanif100] ip address 10.20.20.1 24 [SwitchA-Vlanif100] dhcp select relay [SwitchA-Vlanif100] dhcp relay server-ip 10.10.20.2 [SwitchA-Vlanif100] quit
- 在SwitchA上配置缺省路由。
[SwitchA] ip route-static 0.0.0.0 0.0.0.0 10.10.20.2
- 在SwitchB上配置基于全局地址池的DHCP服务器功能。
# 使能DHCP服务。
<HUAWEI> system-view [HUAWEI] sysname SwitchB [SwitchB] dhcp enable
# 配置接口VLANIF200工作在全局地址池模式。
[SwitchB] vlan 200 [SwitchB-vlan200] quit [SwitchB] interface gigabitethernet 0/0/1 [SwitchB-GigabitEthernet0/0/1] port link-type hybrid [SwitchB-GigabitEthernet0/0/1] port hybrid pvid vlan 200 [SwitchB-GigabitEthernet0/0/1] port hybrid untagged vlan 200 [SwitchB-GigabitEthernet0/0/1] quit [SwitchB] interface vlanif 200 [SwitchB-Vlanif200] ip address 10.10.20.2 24 [SwitchB-Vlanif200] dhcp select global [SwitchB-Vlanif200] quit
# 创建地址池并配置相关属性。
[SwitchB] ip pool pool1 [SwitchB-ip-pool-pool1] network 10.20.20.0 mask 24 [SwitchB-ip-pool-pool1] gateway-list 10.20.20.1 [SwitchB-ip-pool-pool1] option121 ip-address 10.10.20.0 24 10.20.20.1 [SwitchB-ip-pool-pool1] quit
- 在SwitchB上配置静态路由。
[SwitchB] ip route-static 10.20.20.0 255.255.255.0 10.10.20.1
- 验证配置结果。
# 在SwitchA上执行命令display dhcp relay interface vlanif 100命令用来查看DHCP中继的配置信息。
[SwitchA] display dhcp relay interface vlanif 100 DHCP relay agent running information of interface Vlanif100 : Server IP address [00] : 10.10.20.2 Gateway address in use : 10.20.20.1
# 在SwitchB上使用display ip pool name pool1命令用来查看IP地址池的分配情况,“Used”字段表示已经分配出去的IP地址数量。
[SwitchB] display ip pool name pool1 Pool-name : pool1 Pool-No : 0 Lease : 1 Days 0 Hours 0 Minutes Domain-name : - Option-code : 121 Option-subcode : -- Option-type : hex Option-value : 18640A1414141401 DNS-server0 : - NBNS-server0 : - Netbios-type : - Position : Local Status : Unlocked Gateway-0 : 10.20.20.1 Network : 10.20.20.0 Mask : 255.255.255.0 VPN instance : -- Logging : Disable Conflicted address recycle interval: - Address Statistic: Total :253 Used :2 Idle :251 Expired :0 Conflict :0 Disabled :0 ------------------------------------------------------------------------------- Network section Start End Total Used Idle(Expired) Conflict Disabled ------------------------------------------------------------------------------- 10.20.20.1 10.20.20.254 253 2 251(0) 0 0 -------------------------------------------------------------------------------
配置文件
SwitchA的配置文件
# sysname SwitchA # vlan batch 100 200 # dhcp enable # interface Vlanif100 ip address 10.20.20.1 255.255.255.0 dhcp select relay dhcp relay server-ip 10.10.20.2 # interface Vlanif200 ip address 10.10.20.1 255.255.255.0 # interface GigabitEthernet0/0/1 port link-type hybrid port hybrid pvid vlan 200 port hybrid untagged vlan 200 # interface GigabitEthernet0/0/2 port link-type hybrid port hybrid pvid vlan 100 port hybrid untagged vlan 100 # ip route-static 0.0.0.0 0.0.0.0 10.10.20.2 # return
SwitchB的配置文件
# sysname SwitchB # vlan batch 200 # dhcp enable # ip pool pool1 gateway-list 10.20.20.1 network 10.20.20.0 mask 255.255.255.0 option121 ip-address 10.10.20.0 24 10.20.20.1 # interface Vlanif200 ip address 10.10.20.2 255.255.255.0 dhcp select global # interface GigabitEthernet0/0/1 port link-type hybrid port hybrid pvid vlan 200 port hybrid untagged vlan 200 # ip route-static 10.20.20.0 255.255.255.0 10.10.20.1 # return