华为删除dhcp地址池_配置DHCP客户端示例

79652c9ef35ad2a27819b1c83fa68cde.png

组网需求

如图1所示,Switch_1作为DHCP客户端,希望从DHCP服务器(Switch_2)中动态获取IP地址、DNS服务器、网关地址等信息。

图1 配置DHCP客户端组网图

938ab705092b6d909e30a23a402828f3.png

配置思路

1. 在Switch_1上使能DHCP客户端,实现Switch_1可以从DHCP服务器动态获取IP地址。

2. 在Switch_2上配置DHCP服务器,实现为Switch_1动态分配IP地址等网络参数。

Switch_2以S2750, S5700, S6720系列交换机为例。

操作步骤

1. 在Switch_1上配置DHCP客户端功能

# 创建VLAN10并将GE0/0/1接口加入到VLAN10中。

<HUAWEI> system-view
[HUAWEI] sysname Switch_1
[Switch_1] vlan 10
[Switch_1-vlan10] quit
[Switch_1] interface gigabitethernet 0/0/1
[Switch_1-GigabitEthernet0/0/1] port link-type trunk
[Switch_1-GigabitEthernet0/0/1] port trunk allow-pass vlan 10
[Switch_1-GigabitEthernet0/0/1] quit

# 在VLANIF10接口上使能DHCP客户端功能。

[Switch_1] interface vlanif 10
[Switch_1-Vlanif10] ip address dhcp-alloc

2. 在Switch_2上创建DHCP服务器的全局地址池并配置网络参数

a. 使能DHCP服务。

<HUAWEI> system-view
[HUAWEI] sysname Switch_2
[Switch_2] dhcp enable

b. 创建VLAN10并将GE0/0/1接口加入到VLAN10中。

[Switch_2] vlan 10
[Switch_2-vlan10] quit
[Switch_2] interface gigabitethernet 0/0/1
[Switch_2-GigabitEthernet0/0/1] port link-type trunk
[Switch_2-GigabitEthernet0/0/1] port trunk allow-pass vlan 10
[Switch_2-GigabitEthernet0/0/1] quit

c. 配置VLANIF10接口工作在全局地址池模式。

[Switch_2] interface vlanif 10
[Switch_2-Vlanif10] ip address 192.168.1.1 24
[Switch_2-Vlanif10] dhcp select global
[Switch_2-Vlanif10] quit

d. 创建地址池并配置相关属性。

[Switch_2] ip pool pool1
[Switch_2-ip-pool-pool1] network 192.168.1.0 mask 24
[Switch_2-ip-pool-pool1] gateway-list 192.168.1.126
[Switch_2-ip-pool-pool1] dns-list 192.168.1.2
[Switch_2-ip-pool-pool1] excluded-ip-address 192.168.1.2
[Switch_2-ip-pool-pool1] quit

3. 验证配置结果

# 在Switch_1的接口VLANIF10上执行display this命令,查看DHCP客户端功能的配置信息。

[Switch_1] interface vlanif 10
[Switch_1-Vlanif10] display this
#
interface Vlanif10
 ip address dhcp-alloc
#
return      

# 当接口成功分配到IP地址,在Switch_1执行display dhcp client命令,查看DHCP客户端的状态信息。

[Switch_1] display dhcp client
DHCP client lease information on interface Vlanif10 :
 Current machine state         : Bound
 Internet address assigned via : DHCP
 Physical address              : 0025-9efb-be55
 IP address                    : 192.168.1.254
 Subnet mask                   : 255.255.255.0
 Gateway ip address            : 192.168.1.126
 DHCP server                   : 192.168.1.1
 Lease obtained at             : 2014-09-10 20:30:39
 Lease expires at              : 2014-09-11 20:30:39
 Lease renews at               : 2014-09-11 08:30:39
 Lease rebinds at              : 2014-09-11 17:30:39
 DNS                           : 192.168.1.2   

# 在Switch_2上执行display ip pool name pool1命令,查看IP地址池的分配情况,“Used”字段表示已经分配出去的IP地址数量。

[Switch_2] display ip pool name pool1
  Pool-name      : pool1
  Pool-No        : 0
  Lease          : 1 Days 0 Hours 0 Minutes
  Domain-name    : -
  DNS-server0    : 192.168.1.2
  NBNS-server0   : -
  Netbios-type   : -
  Position       : Local           Status           : Unlocked
  Gateway-0      : 192.168.1.126
  Network        : 192.168.1.0
  Mask           : 255.255.255.0
  VPN instance   : --
 
 -----------------------------------------------------------------------------
         Start           End     Total  Used  Idle(Expired)  Conflict  Disable
 -----------------------------------------------------------------------------
     192.168.1.1   192.168.1.254   253     1        251(0)         0        1
 -----------------------------------------------------------------------------   

配置文件

Switch_1的配置文件

#
sysname Switch_1
#
vlan batch 10
#
interface Vlanif10
 ip address dhcp-alloc
#
interface GigabitEthernet0/0/1
 port link-type trunk
 port trunk allow-pass vlan 10
#
return

Switch_2的配置文件

#
sysname Switch_2
#
vlan batch 10
#
dhcp enable
#
ip pool pool1
 gateway-list 192.168.1.126
 network 192.168.1.0 mask 255.255.255.0
 excluded-ip-address 192.168.1.2
 dns-list 192.168.1.2
#
interface Vlanif10
 ip address 192.168.1.1 255.255.255.0
 dhcp select global
#
interface GigabitEthernet0/0/1
 port link-type trunk
 port trunk allow-pass vlan 10
#
return

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

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