Configure a DHCP Server to Dynamically Allocate IP Addresses
Network Requirements
- Two interface VLANs of Device, VLAN2 and VLAN3, are respectively configured with IP addresses in the 1.0.0.3/24 and 2.0.0.3/24 network segments.
- The DHCP server Device dynamically allocates IP addresses in the 1.0.0.0/24 and 2.0.0.0.0/24 network segments to the two clients in the directly-connected physical network.
- The IP addresses in network segment 1.0.0.0/24 have a one-day lease, the gateway address is 1.0.0.3, the DNS server address is 2.0.0.4. The IP addresses in network segment 2.0.0.0/24 have a three-day lease the gateway address is 2.0.0.3, the DNS server address is 2.0.0.4.
- The first 10 IP addresses in network segments 1.0.0.0/24 are reserved and cannot be allocated.
Network Topology
Figure 3-2 Networking for Configuring DHCP to Dynamically Allocate IP Addresses
Configuration Steps
Step 1: Configure the IP address of the interface of the device, and make the interface work in the DHCP server mode.
Device(config)#interface vlan2
Device(config-if- vlan2)#ip address 1.0.0.3 255.255.255.0
Device(config-if- vlan2)#ip dhcp server
Device(config-if- vlan2)#exit
Device(config)#interface vlan3
Device(config-if- vlan3)#ip address 2.0.0.3 255.255.255.0
Device(config-if- vlan3)#ip dhcp server
Device(config-if- vlan3)#exit
|
Step 2: On the DHCP server Device, configure two dynamic address pools and their parameters.
#Configure the first 10 IP addresses in the two address pools as the reserved addresses.
Device(config)#ip dhcp excluded-address 1.0.0.1 1.0.0.10
Device(config)#ip dhcp excluded-address 2.0.0.1 2.0.0.10
|
#Configure the address pool named dynamic-pool1 and the parameters (address range, gateway, dns address, and address lease).
Device(config)#ip dhcp pool dynamic-pool1
Device(dhcp-config)#network 1.0.0.0 255.255.255.0
Device(dhcp-config)#default-router 1.0.0.3
Device(dhcp-config)#dns-server 2.0.0.4
Device(dhcp-config)#lease 1 0 0
Device(dhcp-config)#exit
|
#Configure the address pool named dynamic-pool2 and the parameters (address range, gateway, dns address, and address lease).
Device(config)#ip dhcp pool dynamic-pool2
Device(dhcp-config)#network 2.0.0.0 255.255.255.0
Device(dhcp-config)#default-router 2.0.0.3
Device(dhcp-config)#dns-server 2.0.0.4
Device(dhcp-config)#lease 3 0 0
Device(dhcp-config)#exit
|
Step 3: Check the result.
#Query the information of the associated address pool of the server on Device.
Device#show ip dhcp server interface vlan2
DHCP server status information:
DHCP server is enabled on interface: vlan2
Vrf : global
DHCP server pool information:
Available directly-connected pool:
Interface IP Pool name Pool Range Pool utilization
------------- --------------- -------------------- --------------
1.0.0.3/24 dynamic-pool1 1.0.0.0 – 1.0.0.255 0.00%
Device#show ip dhcp server interface vlan3
DHCP server status information:
DHCP server is enabled on interface: vlan3
Vrf : global
DHCP server pool information:
Available directly-connected pool:
Interface IP Pool name Pool Range Pool utilization
------------- --------------- -------------------- --------------
1.0.0.3/24 dynamic-pool2 2.0.0.0 – 2.0.0.255 0.00%
#Query the IP address information distributed for the client on Device.
Device#show ip dhcp pool danymic-pool1 lease
IP Address MAC Address Vendor Id Type Time Left(s)
-------------- ------------------ ------------ ------ -----------
1.0.0.11 0001.7a6a.0268 Global Lease 86390
Device#show ip dhcp pool danymic-pool2 lease
IP Address MAC Address Vendor Id Type Time Left(s)
-------------- ------------------ ------------ ------ -----------
2.0.0.11 0001.7a6a.0269 Global Lease 259194
#Query the distribution statistics information of the configured IP address pool on Device.
Device#show ip dhcp pool dynamic-pool1 summary
Pool: dynamic-pool1
Pool Configuration : 1.0.0.0 255.255.255.0
Pool Range : 1.0.0.0 1.0.0.255
Pool Utilization..... 0.39%
VRF : global
DNS Server : 2.0.0.4
Default Router : 1.0.0.3
Lease Time : 1 Days 0 Hours 0 Minutes
Free Addresses : 243
Static Bind : 0
Lease Count : 1
PingList : 0
OfferList : 0
ConflictList : 0
ExcludeList : 12
Device#show ip dhcp pool dynamic-pool2 summary
Pool: dynamic-pool2
Pool Configuration : 2.0.0.0 255.255.255.0
Pool Range : 2.0.0.0 2.0.0.255
Pool Utilization..... 0.39%
VRF : global
DNS Server : 2.0.0.4
Default Router : 2.0.0.3
Lease Time : 3 Days 0 Hours 0 Minutes
Free Addresses : 243
Static Bind : 0
Lease Count : 1
PingList : 0
OfferList : 0
ConflictList : 0
ExcludeList : 12
On the DHCP client, query whether the IP addresses have been obtained properly.
-
The IP address in the address pool should belong to the segment range of the interface providing the service.