Before configuring a DHCP pool, there are some things you should determine first
- Networks - What network ranges do you want to perform DHCP server services on
- Network Settings - DNS servers, domains and network gateways
- Exclusions - What addresses should be excluded from the DHCP scope
- DHCP database persistence - Are you going to have the DHCP database saved and updated somewhere?
- Lease time - How long do you want leases to persist
Firstly, enter in the addresses that have been excluded from pools. Once you have configured addresses in the DHCP pool, IOS will start handing them out, so it's a good idea to do this first and avoid collisions.
TestRTR(config)#ip dhcp excluded-address ?
A.B.C.D Low IP address TestRTR(config)#ip dhcp excluded-address 10.1.1.240 10.1.1.254 TestRTR(config)# |
Now we can create the DHCP pool to lease out addresses. Create the DHCP pool using the ip dhcp pool pool_name command and enter in the network number and mask for the network you want to lease out addresses on.
TestRTR(config)#ip dhcp pool PoolA
TestRTR(config)#network 10.1.1.0 /24 TestRTR(config)# |
Unlike other DHCP software, IOS is going to assume that all addresses in the network can be handed out to clients, excluding it's own IP address. Excluding addresses is the method in which you limit the scope of the IP address pool that IOS will use.
Next, we will configure the DNS server, domain name, lease time (days) and default gateway
TestRTR(dhcp-config)#domain-name lab.local
TestRTR(dhcp-config)#default-router 10.1.1.254 TestRTR(dhcp-config)#dns-server 10.1.1.254 TestRTR(dhcp-config)#lease 8 TestRTR(dhcp-config)# |
These settings are passed to the client as options in the DHCP response to the client. Additional options can be specified with the option command in the dhcp sub-configuration context.
Lastly, DHCP database persistence can be configured so that the router can keep track of what addresses have been handed out after a reload. This database can be stored in any area accessible from something like the copy command (e.g. flash (not recommended), tftp, ftp, rcp, http).
To configure DHCP database persistence, use the ip dhcp database command and specify the URL location that the database should be stored in.
TestRTR(config)#ip dhcp database tftp://10.1.1.5/dhcp.log write-delay 120
TestRTR(config)# |
Now that you have configured the DHCP server to provide addresses, we should have a look how the DHCP server is working and statistics on what has been handed out.
To view the pools that have been created, the number of addresses allocated and the hosts they are allocated to use both the show ip dhcp pool and show ip dhcp binding commands.
TestRTR(config)#sh ip dhcp pool
Pool home_pool : Utilization mark (high/low) : 100 / 0 Subnet size (first/next) : 0 / 0 Total addresses : 254 Leased addresses : 5 Pending event : none 1 subnet is currently in the pool : Current index IP address range Leased addresses 10.1.1.6 10.1.1.1 - 10.1.1.254 5 TestRTR#sh ip dhcp binding Bindings from all pools not associated with VRF: IP address Client-ID/ Lease expiration Type Hardware address/ User name 10.1.1.1 0100.17ab.ef13.bb Feb 18 2012 09:33 PM Automatic 10.1.1.2 0188.c663.b7e1.55 Feb 17 2012 09:03 PM Automatic 10.1.1.3 0100.24d7.d5c5.38 Feb 18 2012 06:09 AM Automatic 10.1.1.4 0100.22fa.96d7.84 Feb 18 2012 09:32 PM Automatic 10.1.1.5 0100.21c5.18de.7a Feb 17 2012 10:54 AM Automatic TestRTR# |
The above commands will show you the mapping from addresses to MAC addresses for DHCP clients and lease expiration. To view statistics on the DHCP server for things like leases, memory usage and offers, use the show ip dhcp server statistics command.
TestRTR(config)#sh ip dhcp server statistics
Memory usage 25085 Address pools 1 Database agents 0 Automatic bindings 5 Manual bindings 0 Expired bindings 0 Malformed messages 0 Secure arp entries 0 Message Received BOOTREQUEST 0 DHCPDISCOVER 6 DHCPREQUEST 389 DHCPDECLINE 0 DHCPRELEASE 0 DHCPINFORM 25 Message Sent BOOTREPLY 0 DHCPOFFER 6 DHCPACK 409 DHCPNAK 2 TestRTR(config)# |
In most environments, DHCP leasing services are handled by a windows server and the IOS device either is not involved or acts as a DHCP relay. DHCP server on IOS generally gets most use in small branch office environments where they may not have a dedicated server to run DHCP, but still need to function semi-autonomously.
No comments:
Post a Comment