Specifying IP address ranges for a DHCP address pool
You can configure both static and dynamic address allocation mechanisms in a DHCP address pool. For dynamic address allocation, you can specify either a primary subnet with multiple address ranges or a primary subnet with multiple secondary subnets for a DHCP address pool. You cannot configure both.
Specifying a primary subnet and multiple address ranges for a DHCP address pool
Some scenarios need to classify DHCP clients on the same subnet into different address groups. To meet this need, you can configure DHCP user classes and specify different address ranges for the classes. The clients matching a user class can then get the IP addresses of an address range. In addition, you can specify a common address range for the clients that do not match any user class. If no common address range is specified, such clients fail to obtain IP addresses.
If there is no need to classify clients, you do not need to configure DHCP user classes or their address ranges.
Follow these guidelines when you specify a primary subnet and multiple address ranges for a DHCP address pool:
If you use the network or address range command multiple times for the same address pool, the most recent configuration takes effect.
IP addresses specified by the forbidden-ip command are not assignable in the current address pool, but are assignable in other address pools. IP addresses specified by the dhcp server forbidden-ip command are not assignable in any address pool.
You can use class range to modify an existing address range, and the new address range can include IP addresses that are being used by clients. Upon receiving a lease extension request for such an IP address, the DHCP server allocates a new IP address to the requesting client. But the original lease continues aging in the address pool, and will be released when the lease duration is reached. To release such lease without waiting for its timeout, execute the reset dhcp server ip-in-use command.
To specify a primary subnet and multiple address ranges for a DHCP address pool:
Step | Command | Remarks |
---|---|---|
1. Enter system view. | system-view | N/A |
2. Create a DHCP user class and enter DHCP user class view. | dhcp class class-name | Required for client classification. By default, no DHCP user class exists. |
3. Configure a match rule for the DHCP user class. | if-match rule rule-number { hardware-address hardware-address mask hardware-address-mask | option option-code [ ascii ascii-string [ offset offset | partial ] | hex hex-string [ mask mask | offset offset length length | partial ] ] | relay-agent gateway-address } | Required for client classification. By default, no match rule is configured for a DHCP user class. |
4. Return to system view. | quit | N/A |
5. Create a DHCP address pool and enter its view. | dhcp server ip-pool pool-name | By default, no DHCP address pool exists. |
6. Specify the primary subnet for the address pool. | network network-address [ mask-length | mask mask ] | By default, no primary subnet is specified. |
7. (Optional.) Specify the common address range. | address range start-ip-address [ end-ip-address ] [ vpn-instance vpn-instance-name ] | By default, no IP address range is specified. |
8. (Optional.) Specify an IP address range for a DHCP user class. | class class-name range start-ip-address end-ip-address | By default, no IP address range is specified for a user class. The DHCP user class must already exist. To specify address ranges for multiple DHCP user classes, repeat this step. |
9. (Optional.) Set the address lease duration. | expired { day day [ hour hour [ minute minute [ second second ] ] ] | unlimited } | The default setting is 1 day. |
10. (Optional.) Exclude the specified IP addresses in the address pool from dynamic allocation. | forbidden-ip ip-address&<1-8> | By default, all the IP addresses in the DHCP address pool are assignable. To exclude multiple address ranges from dynamic allocation, repeat this step. |
11. Return to system view. | quit | N/A |
12. (Optional.) Exclude the specified IP addresses from automatic allocation globally. | dhcp server forbidden-ip start-ip-address [ end-ip-address ] [ vpn-instance vpn-instance-name ] | By default, except for the IP address of the DHCP server interface, all IP addresses in address pools are assignable. To exclude multiple IP address ranges, repeat this step. |
Specifying a primary subnet and multiple secondary subnets for a DHCP address pool
If an address pool has a primary subnet and multiple secondary subnets, the server assigns IP addresses on a secondary subnet when the primary subnet has no assignable IP addresses.
Follow these guidelines when you specify a primary subnet and secondary subnets for a DHCP address pool:
You can specify only one primary subnet in each address pool. If you use the network command multiple times, the most recent configuration takes effect.
You can specify a maximum of 32 secondary subnets in each address pool.
IP addresses specified by the forbidden-ip command are not assignable in the current address pool, but are assignable in other address pools. IP addresses specified by the dhcp server forbidden-ip command are not assignable in any address pool.
To specify a primary subnet and secondary subnets for a DHCP address pool:
Step | Command | Remarks |
---|---|---|
1. Enter system view. | system-view | N/A |
2. Create a DHCP address pool and enter its view. | dhcp server ip-pool pool-name | By default, no DHCP address pool exists. |
3. Specify the primary subnet. | network network-address [ mask-length | mask mask ] | By default, no primary subnet is specified. |
4. (Optional.) Specify a secondary subnet. | network network-address [ mask-length | mask mask ] secondary | By default, no secondary subnet is specified. |
5. (Optional.) Return to address pool view. | quit | N/A |
6. (Optional.) Set the address lease duration. | expired { day day [ hour hour [ minute minute [ second second ] ] ] | unlimited } | The default setting is 1 day. |
7. (Optional.) Exclude the specified IP addresses from dynamic allocation. | forbidden-ip ip-address&<1-8> | By default, all the IP addresses in the DHCP address pool can be dynamically allocated. To exclude multiple address ranges from the address pool, repeat this step. |
8. Return to system view. | quit | N/A |
9. (Optional.) Exclude the specified IP addresses from dynamic allocation globally. | dhcp server forbidden-ip start-ip-address [ end-ip-address ] [ vpn-instance vpn-instance-name ] | Except for the IP address of the DHCP server interface, IP addresses in all address pools are assignable by default. To exclude multiple address ranges globally, repeat this step. |
Configuring a static binding in a DHCP address pool
Some DHCP clients, such as a WWW server, need fixed IP addresses. To provide a fixed IP address for a client, you can statically bind the MAC address or ID of the client to an IP address in a DHCP address pool. When the client requests an IP address, the DHCP server assigns the IP address in the static binding to the client.
Follow these guidelines when you configure a static binding:
One IP address can be bound to only one client MAC or client ID. You cannot modify bindings that have been created. To change the binding for a DHCP client, you must delete the existing binding first.
The IP address of a static binding cannot be the address of the DHCP server interface. Otherwise, an IP address conflict occurs and the bound client cannot obtain an IP address correctly.
Multiple interfaces on the same device might all use DHCP to request a static IP address. In this case, use client IDs rather than the device's MAC address to identify the interfaces. Otherwise, IP address allocation will fail.
To configure a static binding:
Step | Command | Remarks |
---|---|---|
1. Enter system view. | system-view | N/A |
2. Create a DHCP address pool and enter its view. | dhcp server ip-pool pool-name | By default, no DHCP address pool exists. |
3. Configure a static binding. | static-bind ip-address ip-address [ mask-length | mask mask ] { client-identifier client-identifier | hardware-address hardware-address [ ethernet | token-ring ] } | By default, no static binding is configured. To add more static bindings, repeat this step. |
4. (Optional.) Set the lease duration for the IP address. | expired { day day [ hour hour [ minute minute [ second second ] ] ] | unlimited } | The default setting is 1 day. |