华为删除dhcp地址池_配置设备作为DHCP中继示例

62d6b224f7618b0b279011759d009790.png

补发一下DHCP中继

组网需求

如图1所示,某企业部署一台DHCP服务器(SwitchB),希望为企业内终端动态分配IP地址,终端与DHCP服务器部署在不同网段。

图1 配置设备作为DHCP中继组网图

dbe3f55b7fd3d84775dc4038f9bc2af3.png

配置思路

配置设备作为DHCP中继的配置思路如下:

在SwitchA上配置DHCP中继,设备作为DHCP中继转发终端与DHCP服务器间的DHCP报文,从而实现DHCP服务器为终端分配IP地址。

DHCP服务器(SwitchB)以S2750, S5700, S6720系列交换机为例。

操作步骤

1. 在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

2. 在SwitchA上配置缺省路由。

[SwitchA] ip route-static 0.0.0.0 0.0.0.0 10.10.20.2

3. 在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

4. 在SwitchB上配置缺省路由。

[SwitchB] ip route-static 10.20.20.0 255.255.255.0 10.10.20.1

5. 验证配置结果。

# 在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   : --
 
 -----------------------------------------------------------------------------
         Start           End     Total  Used  Idle(Expired)  Conflict  Disable
 -----------------------------------------------------------------------------
      10.20.20.1    10.20.20.254   253     1        252(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

PS:华为ENSP模拟器下载地址(提取码:f651 有任何下载安装问题可以在评论区讨论)

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页