Share this page : facebooktwitterlinkedinmailfacebooktwitterlinkedinmail
DHCP process

Lease Origination

When the client boots (or otherwise wants to join a network), it begins a four step process to obtain a lease.A client starts the process with a broadcast DHCPDISCOVER message with its own MAC address to discover available DHCPv4 servers.

  1. DHCP Discover (DHCPDISCOVER)
  2. DHCP Offer (DHCPOFFER)
  3. DHCP Request (DHCPREQUEST)
  4. DHCP Acknowledgment (DHCPACK)

1      The client broadcasts a DHCP-DISCOVER message to locate a DHCP server.

2      A DHCP server offers configuration parameters such as an IP address to the client in a DHCP-OFFER message.

3      If several DHCP servers send offers to the client, the client accepts the first received offer, and broadcasts it in a DHCP-REQUEST message to formally request the IP address.

4      All DHCP servers receive the DHCP-REQUEST message, but only the server from which the client accepts the offered IP address returns a DHCP-ACK message to the client, confirming that the IP address has been allocated to the client, or returns a DHCP-NAK unicast message, denying the IP address allocation.

Lease Renewal

  1. DHCP Request (DHCPREQUEST)
  2. DHCP Acknowledgment (DHCPACK)
DHCP message format

DHCPv4 messages sent from the client use UDP source port 68 and destination port 67.

DHCPv4 messages sent from the server to the client use UDP source port 67 and destination port 68.

dhcpformat

The figure shows the format of a DHCPv4 message. The fields are as follows:

  • Operation (OP) Code – Specifies the general type of message. A value of 1 indicates a request message; a value of 2 is a reply message.
  • Hardware Type – Identifies the type of hardware used in the network. For example, 1 is Ethernet, 15 is Frame Relay, and 20 is a serial line. These are the same codes used in ARP messages.
    Value Description
    1 Ethernet.
    2 Experimental Ethernet.
    3 Amateur Radio AX.25.
    4 Proteon ProNET Token Ring.
    5 Chaos.
    6 IEEE 802.
    7 ARCNET.
    8 Hyperchannel.
    9 Lanstar.
    10 Autonet Short Address.
    11 LocalTalk.
    12 LocalNet (IBM PCNet or SYTEK LocalNET).
    13 Ultra link.
    14 SMDS.
    15 Frame Relay.
    16 ATM, Asynchronous Transmission Mode.
    17 HDLC.
    18 Fibre Channel.
    19 ATM, Asynchronous Transmission Mode.
    20 Serial Line.
    21 ATM, Asynchronous Transmission Mode.
    22 MIL-STD-188-220.
    23 Metricom.
    24 IEEE 1394.1995.
    25 MAPOS.
    26 Twinaxial.
    27 EUI-64.
    28 HIPARP.
    29 IP and ARP over ISO 7816-3.
    30 ARPSec.
    31 IPsec tunnel.
    32 Infiniband.
    33 CAI, TIA-102 Project 25 Common Air Interface.
    34 Wiegand Interface.
    35 Pure IP.
  • Hardware Address Length – Specifies the length of the address.
  • Hops – Controls the forwarding of messages. Set to 0 by a client before transmitting a request.
  • Transaction Identifier – Used by the client to match the request with replies received from DHCPv4 servers.
  • Seconds – Identifies the number of seconds elapsed since a client began attempting to acquire or renew a lease. Used by DHCPv4 servers to prioritize replies when multiple client requests are outstanding.
  • Flags – Used by a client that does not know its IPv4 address when it sends a request. Only one of the 16 bits is used, which is the broadcast flag. A value of 1 in this field tells the DHCPv4 server or relay agent receiving the request that the reply should be sent as a broadcast.
  • Client IP Address – Used by a client during lease renewal when the address of the client is valid and usable, not during the process of acquiring an address. The client puts its own IPv4 address in this field if and only if it has a valid IPv4 address while in the bound state; otherwise, it sets the field to 0.
  • Your IP Address – Used by the server to assign an IPv4 address to the client.
  • Server IP Address – Used by the server to identify the address of the server that the client should use for the next step in the bootstrap process, which may or may not be the server sending this reply. The sending server always includes its own IPv4 address in a special field called the Server Identifier DHCPv4 option.
  • Gateway IP Address – Routes DHCPv4 messages when DHCPv4 relay agents are involved. The gateway address facilitates communications of DHCPv4 requests and replies between the client and a server that are on different subnets or networks.
  • Client Hardware Address – Specifies the physical layer of the client.
  • Server Name – Used by the server sending a DHCPOFFER or DHCPACK message. The server may optionally put its name in this field. This can be a simple text nickname or a DNS domain name, such as dhcpserver.netacad.net.
  • Boot Filename – Optionally used by a client to request a particular type of boot file in a DHCPDISCOVER message. Used by a server in a DHCPOFFER to fully specify a boot file directory and filename.
  • DHCP Options – Holds DHCP options, including several parameters required for basic DHCP operation. This field is variable in length. Both client and server may use this field.
  • For more configuration check here
DHCP Discover and Offer message
DHCP Dis_message
DHCP discover message
DHCP_Offer_Message
DHCP offer Message

The client transmits a DHCPDISCOVER message on its local network when it boots or senses an active network connection. Because the client has no way of knowing the subnet to which it belongs, the DHCPDISCOVER message is an IPv4 broadcast (destination IPv4 address of 255.255.255.255). The client does not have a configured IPv4 address yet, so the source IPv4 address of 0.0.0.0 is used.

Configure DHCP

Step1. Configure excluded address: Typically, some IPv4 addresses in a pool are assigned to network devices that require static address assignments, such as printers, servers, router interfaces, switch SVIs.

r1(config)#ip dhcp excluded-address low_address [high _address]

Step 2. Configuring a DHCPv4 Pool

Configuring a DHCPv4 server involves defining a pool of addresses to assign.

r1(config)#ip dhcp pool pool-name
r1(dhcp-config)#

Step 3. Configuring Specific Tasks

  • Address poolr1(dhcp-config)# network network_address[mask/prefix-length]
  • Default router: r1(dhcp-config)# default-router router_address
  • Domain name: r1(dhcp-config)# domain-name name
  • DNS server: r1(dhcp-config)#dns-server server_address
  • Lease length(days):  The default lease value is one day.
    r1(dhcp-config)# lease {days [hours [minutes]] | infinite}
    Example, Set the lease to 30 days 4 hours and 30 minutes

    R1(dhcp-config)# lease 30 4 30 

  • Name server:
    r1(dhcp-config)# netbios-name-server address1 [address2...address 8]
Cisco IP Phones download their configuration from a TFTP server. When a Cisco IP Phone starts, if it does not have both the IP address and TFTP server IP address preconfigured, it sends a request with option 150 or 66 to the DHCP server to obtain this information.
  • DHCP option 150 provides the IP addresses of a list of TFTP servers.
  • DHCP option 66 gives the IP address or the hostname of a single TFTP server.
r1(dhcp-config)#option 66 ascii "http://whatever.you.want.here/"
Enable or disable DHCP service

Disabling DHCPv4

The DHCPv4 service is enabled, by default, on versions of Cisco IOS software that support it.

To disable the service, use the no service dhcp global configuration mode command. Use the service dhcp to enable it.

Configure DHCP on client

The interface of the routers can be DHCP client:

          r1(config-if)# ip address dhcp

DHCP relay

DHCP relay enables a router to forward DHCPv4 broadcasts to the DHCPv4 server.

Configure it at interface configuratoin mode:
r1(config-if)# ip helper-address dhcp_server_address

   The IP helper-address forwards the following 8 UDP services:

  • Port 37: Time
  • Port 49: TACACS
  • Port 53: DNS
  • Port 67: DHCP/BOOTP client
  • Port 68: DHCP/BOOTP server
  • Port 69: TFTP
  • Port 137: NetBIOS name service
  • Port 138: NetBIOS datagram service
Verify DHCP
  • Diplay the DHCPv4 commands configured on R1:
    Show running-config | section dhcp
  • Display a list of all IPv4 address to MAC address bindings that have been provided by the DHCPv4 service:
    show ip dhcp binding
  • Display the messages are being received or sent by the router:
    show ip dhcp server statistics
Trouble shooting DHCP
  •    show ip dhcp conflict
  •    Test DHCPv4 Operation on the Same Subnet or VLANIt is important to distinguish whether DHCPv4 is functioning correctly when the client is on the same subnet or VLAN as the DHCPv4 server. If DHCPv4 is working correctly when the client is on the same subnet or VLAN, the problem may be the DHCP relay agent. If the problem persists even with testing DHCPv4 on the same subnet or VLAN as the DHCPv4 server, the problem may actually be with the DHCPv4 server.
  • Verify that “no service dhcp” has not been configured : use
    show running-config |include no service dhcp
Debugging DHCPv4
  • debug ip dhcp server events command. This command reports server events, like address assignments and database updates. It is also used for decoding DHCPv4 receptions and transmissions.
  • Use ACL to debugging the specific packets
  r1(config)# access-list 100 permit udp any any eq 67      //DHCP server port
r1(config)#access-list 100 permit udp any any eq 68      //DHCP client port
r1(config)#end
r1#debug ip packet 100