Dynamic IP address assignment configuration example

Network requirements

As shown in Figure 18, the DHCP server (Switch A) assigns IP addresses to clients on subnet 10.1.1.0/24, which is subnetted into 10.1.1.0/25 and 10.1.1.128/25.

Configure DHCP server on Switch A to implement the following assignment scheme.

Table 3: Assignment scheme

DHCP clients

IP address

Lease

Other configuration parameters

Clients connected to VLAN-interface 10

IP addresses on subnet 10.1.1.0/25

10 days and 12 hours

  • Gateway: 10.1.1.126/25

  • DNS server: 10.1.1.2/25

  • Domain name: aabbcc.com

  • WINS server: 10.1.1.4/25

Clients connected to VLAN-interface 20

IP addresses on subnet 10.1.1.128/25

Five days

  • Gateway: 10.1.1.254/25

  • DNS server: 10.1.1.2/25

  • Domain name: aabbcc.com

Figure 18: Network diagram

Configuration procedure

  1. Specify IP addresses for the VLAN interfaces. (Details not shown.)

  2. Configure the DHCP server:

    # Enable DHCP.

    <SwitchA> system-view
    [SwitchA] dhcp enable
    

    # Enable the DHCP server on VLAN-interface 10 and VLAN-interface 20.

    [SwitchA] interface vlan-interface 10
    [SwitchA-Vlan-interface10] dhcp select server
    [SwitchA-Vlan-interface10] quit
    [SwitchA] interface vlan-interface 20
    [SwitchA-Vlan-interface20] dhcp select server
    [SwitchA-Vlan-interface20] quit
    

    # Exclude the DNS server address, WINS server address, and gateway addresses from dynamic allocation.

    [SwitchA] dhcp server forbidden-ip 10.1.1.2
    [SwitchA] dhcp server forbidden-ip 10.1.1.4
    [SwitchA] dhcp server forbidden-ip 10.1.1.126
    [SwitchA] dhcp server forbidden-ip 10.1.1.254
    

    # Configure DHCP address pool 1 to assign IP addresses and other configuration parameters to clients on subnet 10.1.1.0/25.

    [SwitchA] dhcp server ip-pool 1
    [SwitchA-dhcp-pool-1] network 10.1.1.0 mask 255.255.255.128
    [SwitchA-dhcp-pool-1] expired day 10 hour 12
    [SwitchA-dhcp-pool-1] domain-name aabbcc.com
    [SwitchA-dhcp-pool-1] dns-list 10.1.1.2
    [SwitchA-dhcp-pool-1] gateway-list 10.1.1.126
    [SwitchA-dhcp-pool-1] nbns-list 10.1.1.4
    [SwitchA-dhcp-pool-1] quit
    

    # Configure DHCP address pool 2 to assign IP addresses and other configuration parameters to clients on subnet 10.1.1.128/25.

    [SwitchA] dhcp server ip-pool 2
    [SwitchA-dhcp-pool-2] network 10.1.1.128 mask 255.255.255.128
    [SwitchA-dhcp-pool-2] expired day 5
    [SwitchA-dhcp-pool-2] domain-name aabbcc.com
    [SwitchA-dhcp-pool-2] dns-list 10.1.1.2
    [SwitchA-dhcp-pool-2] gateway-list 10.1.1.254
    [SwitchA-dhcp-pool-2] quit
    

Verifying the configuration

# Verify that clients on subnets 10.1.1.0/25 and 10.1.1.128/25 can obtain correct IP addresses and all other network parameters from Switch A. (Details not shown.)

# On the DHCP server, display the IP addresses assigned to the clients.

[SwitchA] display dhcp server ip-in-use
IP address       Client identifier/    Lease expiration      Type
                 Hardware address
10.1.1.3         0031-3865-392e-6262-  Jan 14 22:25:03 2015  Auto(C)
                 3363-2e30-3230-352d-
                 4745-302f-30
10.1.1.5         0031-fe65-4203-7e02-  Jan 14 22:25:03 2015  Auto(C)
                 3063-5b30-3230-4702-
                 620e-712f-5e
10.1.1.130       3030-3030-2e30-3030-  Jan 9 10:45:11 2015   Auto(C)
                 662e-3030-3033-2d45-
                 7568-6572-1e
10.1.1.131       3030-0020-fe02-3020-  Jan 9 10:45:11 2015   Auto(C)
                 7052-0201-2013-1e02
                 0201-9068-23
10.1.1.132       2020-1220-1102-3021-  Jan 9 10:45:11 2015   Auto(C)
                 7e52-0211-2025-3402
                 0201-9068-9a
10.1.1.133       2021-d012-0202-4221-  Jan 9 10:45:11 2015   Auto(C)
                 8852-0203-2022-55e0
                 3921-0104-31