现在我们利用华为S5700交换机配置一个DHCP服务器

拓扑图如下

 

操作步骤

    1. 全局启动DHCP服务。
      <Huawei>system-view
      Enter system view, return user view with Ctrl+Z.
      [Huawei]dhcp enable
    2. 创建地址池并配置相关属性。# 配置IP地址池10的属性(地址池范围、DNS地址、出口网关和地址池租期)。
      [Huawei]ip pool 10
      Info:It’s successful to create an IP address pool.
      [Huawei-ip-pool-10]network 192.168.10.0 mask 255.255.255.0
      [Huawei-ip-pool-10]dns-list 202.102.224.68
      [Huawei-ip-pool-10]gateway-list 192.168.10.1
      [Huawei-ip-pool-10]lease day 10
      [Huawei-ip-pool-10]quit
    3. # 配置IP地址池20的属性(地址池范围、DNS地址、出口网关、NetBOIS地址和地址池租期)
      [Huawei]ip pool 10
      Info:It’s successful to create an IP address pool.
      [Huawei-ip-pool-20]network 192.168.20.0 mask 255.255.255.0
      [Huawei-ip-pool-20]dns-list 202.102.224.68
      [Huawei-ip-pool-20]gateway-list 192.168.20.1
      [Huawei-ip-pool-20]lease day 10
      [Huawei-ip-pool-20]quit
    4. 配置VLANIF接口下地址分配方式。# 配置接口GE0/0/1和GE0/0/2分别加入相应的VLAN。
      [Huawei]vlan batch 10 20
      [Huawei]interface GigabitEthernet 0/0/1
      [Huawei-GigabitEthernet0/0/1]port link-type access
      [Huawei-GigabitEthernet0/0/1]port default vlan 10
      [Huawei-GigabitEthernet0/0/1]quit
      [Huawei]interface GigabitEthernet 0/0/2
      [Huawei-GigabitEthernet0/0/2]port link-type access
      [Huawei-GigabitEthernet0/0/2]port default vlan 20
      [Huawei-GigabitEthernet0/0/2]quit
    5. # 配置VLANIF10接口下的客户端从全局地址池中获取IP地址。
      [Huawei]interface Vlanif 10
      [Huawei-Vlanif10]ip address 192.168.10.1 24
      [Huawei-Vlanif10]dhcp select global
      [Huawei-Vlanif10]quit

      # 配置VLANIF20接口下的客户端从全局地址池中获取IP地址。
      [Huawei]interface Vlanif 20
      [Huawei-Vlanif20]ip add 192.168.20.1 24
      [Huawei-Vlanif20]dhcp select global
      [Huawei-Vlanif20]quit

    6. 验证配置结果。在Switch上使用display ip pool命令用来查看IP地址池配置情况。
      [Huawei]display ip pool
      ———————————————————————–
      Pool-name      : 10
      Pool-No        : 0
      Position       : Local           Status           : Unlocked
      Gateway-0      : 192.168.10.1
      Mask           : 255.255.255.0
      ××× instance   : —

      ———————————————————————–
      Pool-name      : 20
      Pool-No        : 1
      Position       : Local           Status           : Unlocked
      Gateway-0      : 192.168.20.1
      Mask           : 255.255.255.0
      ××× instance   : —
      IP address Statistic
      Total       :506
      Used        :0          Idle        :506
      Expired     :0          Conflict    :0          Disable   :0
      [Huawei]

    7. 在客户端上验证是否成功