Consider your organization has 300 employees and each employee has one workstation, one laptop, and one IP phone. You, as a network administrator, must manually configure the IP address on each employee’s equipment. This would take a lot of time just for the initial configuration. If, in time, some of them will change their location, most probably they will need the IP address reconfigured. Using a DHCP server in your network, you will be able to automatically assign IP addresses depending on their physical or logical location. DHCP servers send the IP address, subnet mask, gateway and DNS servers configuration to the clients.
DHCP is able to use two types of IP address allocation:
- Automatic – the IP address is assigned permanently to a device.
- Dynamic – the IP address assigned to a device is selected from a pool of available addresses for a limited period of time chosen by the server or until the client tells the DHCP server that it no longer needs the address.
DHCP works in client/server mode. A DHCP server is accepting requests made by clients. When a DHCP client wants to make a request to get the IP address configuration, it sends a DHCPDISCOVER broadcast message. When the server receives the message, it searches for an available IP address to lease, creates an ARP entry consisting of the MAC address of the requesting host and the leased IP address, and sends the binding offer with a DHCPOFFER unicast message. When the client receives the DHCPOFFER messages, it sends back a DHCP REQUEST broadcast message to notify the server of his acceptance.
The server then acknowledges back with a DHCPACK unicast message which terminates the conversation.
A DHCP message has the following fields:
- Operation Code (OP) – indicates the general type of message. 1 represents a request message and 2 a reply message.
- Hardware Type – identifies the type of hardware used, for example, 1 is Ethernet, 15 is Frame Relay.
- Hardware Address length – 8 bits to specify the length of the address.
- Hops – is set to 0 by the client before transmitting a request and is used by relay agents to control the forwarding of DHCP messages.
- Transaction Identifier – 32-bit identification generated by the client to allow it to match up the request with the replies received from the server.
- Seconds – the number of seconds elapsed since a client began attempting to acquire or renew a lease.
- Flags – a client that does not know its IP address when it sends a request sets the flag to 1, which tells the DHCP server to send the reply back as a broadcast.
- Client IP address – if the client already has an IP address assigned, it fills this field with it, if not, the field is set to 0.
- Your IP address – used by the server to inform the client about the assigned IP address.
- Server IP address – the IP address of the server that the client should use for the next step in the bootstrap process.
- Gateway IP address – routes DHCP messages when DHCP relay agents are involved. This is used when the client and the server are on different subnets or networks.
- Client Hardware address – specifies the Physical layer of the client.
- Server Name – the server sending DHCPOFFER or DHCPACK may optionally put its name in this field.
- Boot Filename – optionally used by a client to request a particular type of boot file and used by the server to fully specify a boot file directory and filename.
- Options – is a variable field and holds DHCP options and parameters required for basic DHCP operation.
DHCP uses User Datagram Protocol (UDP) as its transport protocol. The client uses port 67 to send messages, and the server sends a messages on port 68.
Cisco routers running IOS provide full support for a router to act as a DHCP server. There are three steps required when you create a DHCP server:
- Define a range of addresses that the DHCP server will not allocate, usually the static addresses used by routers and servers.
- Create a DHCP pool with the ip dhcp pool command.
- Configure the pool.
Router(config)#ip dhcp excluded-address 192.168.10.1 192.168.10.9
Router(config)#ip dhcp excluded-address 192.168.10.254
Router(config)#ip dhcp pool LAN-POOL
Router(dhcp-config)#network 192.168.10.0 255.255.255.0
To verify the operation of DHCP use the show ip dhcp binding command.
Router# show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
192.168.10.10 0100.6973.5bdd.35 Sep 10 2009 04:36 AM Automatic
To verify the server is sending and receiving DHCP messages, use show ip dhcp statistics.
Router# show ip dhcp server statistics
Memory usage 40392
Address pools 3
Database agents 1
Automatic bindings 190
Manual bindings 1
Expired bindings 3
Malformed messages 0
Secure arp entries 1
If your DHCP server is in another network than the clients, you must configure your router to act as a DHCP relay agent. DHCP relay agents forward to received broadcast frames as unicast frames to a specified host. For example, the clients are in the 192.168.10.0/24 network, and the DHCP server is at 192.168.11.1. For the clients to be able to reach the DHCP server, you must use the ip helper-address ip-address interface configuration command, which forwards the broadcast frames for UDP services like DHCP, TACACS, DNS, DHCP, TFTP, NetBIOS to the specified address. This command must be applied to the interface connected to the client.
Router(config-if)#ip helper-address 192.168.11.1
If you need to specify more protocols to be forwarded with ip helper-address, you can use the ip forward-protocol to specify exactly which types of broadcast packets to forward.
We hope you found this topic covering DHCP helpful in your preparation for the CCNA exam. Using a DHCP server in your network will greatly decrease your time spent with configuring the other workstations and will let you focus on more important tasks.