DHCP Overview

RFC 2131 and RFC 2132 originally defined DHCP, with several RFC extensions augmenting its capabilities. (See http://www.dhcp.org/rfcs.html for an exhaustive list.) The primary purpose of DHCP is to dynamically assign IP addresses to requesters for a specified duration (called the lease time). DHCP clients request addresses from DHCP servers. In most cases, clients and servers are several hops apart and are separated by routers and other network devices. When that is the case, the first hop router needs to be DHCP-friendly and help forward the clients' requests to the servers. Such routers are called relay agents. Figure 5-1 visually summarizes the operation of DHCP.

Figure 5-1 Initial DHCP Exchange initial DHCP Exchange Client Server

Client Discovers DHCP Server(s)

Multiple Offers Can Arrive - Client Picks One

Client Broadcasts Request for One of the Received Offers

DHCP DISCOVER

DHCP OFFER

Client Broadcasts Request for One of the Received Offers

DHCP ACK

Server Reply with an Offer

Server ACKs Client's Request for the IP Address

Table 5-1 lists all the various DHCP packets defined by the principal DHCP RFCs. Table 5-1 DHCP Packet Types

DHCP Message

Use

DHCPDISCOVER

Client discovers servers (broadcast packet).

DHCPOFFER

Server unicasts a response containing various parameters (IP, subnet mask, and so on).

DHCPREQUEST

Client broadcasts interest in offer.

DHCPACK

Server confirms the request (unicast).

DHCPNAK

Server denies a request (unicast).

Table 5-1 DHCP Packet Types (Continued)

Readers' Questions

  • raimo
    What port on a name server is used for user datagram protocol (udp) name request packets?
    18 days ago
  • The port used for User Datagram Protocol (UDP) name request packets on a name server is typically port 53.
    • Aman
      What port on a name server is used for user datagram protocol (udp) name request packets?
      18 days ago
    • The port number 53 is used for User Datagram Protocol (UDP) name request packets on a name server.
      • petronio
        What port on a name server is used for user datagram protocol (udp) name request packets?
        2 months ago
      • The port used for User Datagram Protocol (UDP) name request packets on a name server is port 53.
        • violet
          What ports are used by dhcp and the dhcp client?
          9 months ago
        • DHCP (Dynamic Host Configuration Protocol) uses UDP port number 67 for server side and UDP port number 68 for client side.

          DHCP Message

          Use

          DHCPRELEASE

          Client relinquishes its IP address.

          DHCPINFORM

          Client requests configuration parameters.

          DHCPDECLINE

          Client notifies server that the IP is in use.

          DHCP clients listen to User Datagram Protocol (UDP) port 68, while DHCP servers listen to UDP port 67. For example, the DHCP client's first task is to obtain an IP address by broadcasting a DHCPDISCOVER message from UDP port 68 to UDP port 67. Referring to Figure 5-1, after completion of Step 4 (DHCPACK), the client is ready to use the proposed IP address. DHCP packets can contain a multitude of options to specify the address of default gateways and Domain Name System (DNS) servers, the domain name, and so on. Multiple DHCP servers can exist on a given LAN. If a client receives several DHCPOFFER packets, it is free to pick the one it prefers. For all practical purposes, clients usually pick the first reply to arrive. This property is important to keep in mind because at least one tool is capable of using it to its advantage. Figure 5-2 examines the format of a DHCP packet.

          Figure 5-2 DHCP Packet

          DHCP Packet Format

          Operation Code

          4 Bytes

          Hardware Type

          Hardware Length

          Hop Count

          Transaction ID

          Seconds Elapsed

          Client IP Address

          Your IP Address

          Server IP Address

          Relay Agent/Gateway IP Address

          Client Hardware Address (16 Bytes)

          Server Host Name (16 Bytes)

          Boot File Name (128 Bytes)

          Options (Variable)

          Table 5-2 complements Figure 5-2. It contains a description of the fields found inside a DHCP packet.

          Table 5-2 Fields Found Inside DHCP Packets

          Table 5-2 complements Figure 5-2. It contains a description of the fields found inside a DHCP packet.

          Table 5-2 Fields Found Inside DHCP Packets

          Field

          Bytes

          Description

          Operation Code

          1

          1 = request, 2 = reply

          Hardware Type

          1

          1 = 10 Mbps Ethernet, and so on

          Hardware Length

          1

          Length of MAC address: 6 for Ethernet

          Hop Count

          1

          Optionally used by relay agents

          Transaction ID

          4

          Random number chosen by client used to correlate requests/ replies

          Seconds Elapsed

          2

          Filled by client—counts seconds elapsed since beginning of transaction

          Flags

          2

          1 bit for broadcast flag, rest is zeroed

          Client IP

          4

          Set to zero for new requests

          Your IP

          4

          Address offered by server

          Server IP

          4

          Address to use in next step of bootstrap process—returned by DHCPOFFER/ACK

          Gateway IP

          4

          Address of the relay agent

          Client Hardware Address

          16

          MAC address of the client

          Server Host Name

          64

          Optional

          Boot File Name

          128

          Optional

          Options

          Varies

          Notice the absence of any authentication fields or any other security-inclined information in the packet. The protocol is built on a free-for-all model. Whoever requests an IP address is free to receive one, if available. When a client wants to obtain an IP address, it crafts a DHCPREQUEST packet by populating several of its fields. The client hardware address is of notable interest, because it serves as a (de)multiplexer on the server side to identify various clients. RFC 2131 reads as follows:

          The combination of client identifier or client hardware address and assigned network address constitute a unique identifier for the client's lease and are used both by the client and server to identify a lease referred to in any DHCP message.

          It is common for DHCP servers to contain many available scopes (a range of IP addresses that can be served), because servers handle requests from many different networks. To select the appropriate scope for the client's network, DHCP servers select the Gateway IP Address field as a selector. Because the client does not yet know the IP address of its gateway (this is its default router), the Gateway IP Address field is filled by the first router relaying the client DHCPDISCOVER to the actual DHCP server(s). This DHCP relay uses the IP address of the interface that received the original DHCPDISCOVER sent by the client.

          Continue reading here: Gobbler

          Was this article helpful?

          0 0