Dynamic Host Configuration Protocol (DHCP)
Vicente González Ruiz
December 14, 2014
Contents
1 Funci’on
- DHCP makes the process of assigning new IP addresses almost
transparent. DHCP assigns IP addresses and other important network
configuration information dynamically. Because desktop clients typically
make up the bulk of network nodes, DHCP is an extremely useful and
timesaving tool for network administrators. RFC 2131 describes DHCP.
- RFC 2131.
- Protocolo cliente-servidor, UDP, puerto 67. DHCP uses User Datagram
Protocol (UDP) as its transport protocol. The client sends messages to
the server on port 67. The server sends messages to the client on port 68.
- Los clientes lo utilizan para obtener de forma autom’atica los par’ametros
de conexi’on (dir IP, m’ascara, gateway y DNS) de la red.
- Especialmente utilizado en el caso de hosts m’oviles.
- T’ipicamente se utiliza para asignar un pool de
dirs IP a
hosts de forma din’amica, donde generalmente .
- Cuando un host arranca se pone en contacto con un servidor DHCP
preguntando a la dir de broadcast
(255.255.255.255) y usando la dir IP origen 0.0.0.0.
- Las configuraciones pueden asignarse de forma temporal o de forma
indefinida.
2 Operation
DHCP includes three different address allocation mechanisms to provide flexibility
when assigning IP addresses:
- Manual Allocation: The administrator assigns a pre-allocated IP address
to the client and DHCP only communicates the IP address to the device.
- Automatic Allocation: DHCP automatically assigns a static IP address
permanently to a device, selecting it from a pool of available addresses.
There is no lease and the address is permanently assigned to a device.
- Dynamic Allocation: DHCP automatically dynamically assigns, or leases,
an IP address from a pool of 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 a client/server mode and operates like any other client/server
relationship. When a PC connects to a DHCP server, the server assigns or leases an
IP address to that PC. The PC connects to the network with that leased IP address
until the lease expires. The host must contact the DHCP server periodically to
extend the lease. This lease mechanism ensures that hosts that move or
power off do not hold onto addresses that they do not need. The DHCP
server returns these addresses to the address pool and reallocates them as
necessary.
3 Clientes, servidores y agentes de retransmisi’on
- El DHCP es un protocolo cliente-servidor. Un cliente es una computadora
que desea configurar su IP y un servidor es otra que sabe con qu’e
par’ametros hacerlo.
- Aunque es raro, en una misma red pueden existir varios servidores DHCP.
En principio todos contestar’ian y es el cliente quien elige.
- Aunque es raro, puede que en una red no exista un servidor DHCP y
sin embargo, el servicio se est’e prestando. En este caso, un router que
funciona como relay agent conoce la dir IP de un servidor externo y
permite que los clientes accedan a ’el. In a complex hierarchical network,
enterprise servers are usually contained in a server farm. These servers
may provide DHCP, DNS, TFTP, and FTP services for the clients. The
problem is that the network clients typically are not on the same subnet
as those servers. Therefore, the clients must locate the servers to receive
services and often these services are located using broadcast messages.
- El proceso de consesi’on se lleva a cabo, siempre, bajo demanda del cliente.
4 Configuraciones est’aticas y din’amicas
- Las configuraciones del IP son est’aticas cuando los mismos hosts (en
funci’on de su direcci’on f’isica, por ejemplo) reciben siempre las mismas
direcciones IP. En caso contrario, son di’amicas.
- Al rango de direcciones IP est’aticas se le suele llamar intervalo de
exclusi’on y al conjunto de direcciones IP din’amicas, ’ambito. La uni’on
de ambos conjuntos forman el conjunto de direcciones IP disponibles.
- Clients lease the information from the server for an administratively
defined period. Administrators configure DHCP servers to set the leases to
time out at different intervals. Most ISPs and large networks use default
lease durations of up to three days. When the lease expires, the client
must ask for another address, although the client is typically reassigned
the same address.
- The DHCPREQUEST message also addresses the dynamic DHCP
process. The IP information sent in the DHCPOFFER might have been
offered to another client during the dynamic allocation. Each DHCP
server creates pools of IP addresses and associated parameters. Pools
are dedicated to individual, logical IP subnets. The pools allow multiple
DHCP servers to respond and IP clients to be mobile. If multiple servers
respond, a client can choose only one of the offers.
5 El proceso de concesi’on
- Se ejecuta en 4 pasos (v’ease la Figura
1):
- Solicitud (DHCP DISCOVER packet).
- Oferta (DHCP OFFER packet).
- Petici’on (DHCP REQUEST packet).
- Reconocimiento (DHCP ACK) / No reconocimiento (DHCP NAK
packet).
6 La solucitud (DHCP Discover)
- Broadcast message.
- In the first step, the client broadcasts a DHCPDISCOVER message. The
DHCPDISCOVER message finds DHCP servers on the network. Because
the host has no valid IP information at bootup, it uses L2 and L3 broadcast
addresses to communicate with the server. If a client is configured to
receive its IP settings dynamically, it transmits a DHCPDISCOVER
message on its local physical subnet 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 is an IP broadcast (destination
IP address of 255.255.255.255). The client does not have a configured IP
address, so the source IP address of 0.0.0.0 is used. The client IP address
(CIADDR), default gateway address (GIADDR), and subnetwork mask
are all marked with question marks.
- Cuando un host es encendido y no tiene configurado el IP a mano, o desea
renovar su configuraci’on, emite un paquete UDP dirigido a la direcci’on de
broadcast de su red, puerto 67 (servicio bootps ).
Dicho paquete contiene un mensaje DHCP Discover. Este mensaje llegar’a
a todos los adaptadores de red de la subred, y entre ellos al del servidor
DHCP o del relay agent.
- El cliente esperar’a un tiempo (determinado por ’el) a la contestaci’on del
servidor.
7 La oferta (DHCP Offer)
- Unicast message.
- When the DHCP server receives a DHCDISCOVER message, it finds 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 transmits a
binding offer with a DHCPOFFER message. The DHCPOFFER message
is sent as a unicast, using the L2 MAC address of the server as the source
address and the L2 address of the client as the destination.
- This message contains initial configuration information for the client,
including the MAC address of the client, followed by the IP address that
the server is offering, the subnet mask, the lease duration, and the IP
address of the DHCP server making the offer. The subnet mask and default
gateway are specified in the options field, subnet mask, and router options,
respectively. The DHCPOFFER message can be configured to include
other information, such as the lease renewal time, domain name server,
and NetBIOS Name Service (Microsoft Windows Internet Name Service
[Microsoft WINS]).
- The server determines the configuration, based on the hardware address
of the client as specified in the CHADDR field.
- Administrators set up DHCP servers to assign addresses from predefined
pools. Most DHCP servers also allow the administrator to define
specifically which client MAC addresses can be serviced and automatically
assign them the same IP address each time.
- Uno o m’as servidores DHCP contestan (en un paquete UDP) al cliente
con un mensaje del tipo DHCP Offer. Este contiene una direcci’on IP,
una m’ascara de red, la direcci’on del gateway, la/s direcci’on/es IP con
el/los servidores DNS y el tiempo de pr’estamo (lease time).
- Como el cliente no tiene todav’ia una direcci’on IP v’alida, el servidor
env’ia la oferta de nuevo a la direcci’on de broadcast.
8 La petici’on (DHCP Request)
- Broadcast message.
- When the client receives the DHCPOFFER from the server, it sends
back a DHCPREQUEST message. This message has two purposes: lease
origination and lease renewal and verification. When used for lease origination,
the DHCPREQUEST of the client is requesting that the IP information
be verified just after it has been assigned. The message provides error
checking to ensure that the assignment is still valid. The DHCPREQUEST
also serves as a binding acceptance notice to the selected server and an
implicit decline to any other servers that may have provided the host a
binding offer.
- El cliente seleciona una de las ofertas y env’ia un paquete UDP a la
direcci’on de broadcast de la subred con el mensaje DHCP Request. Dicho
mensaje incluye los datos de la oferta seleccionada.
- Los servidores DHCP van a recibir este mensaje y el que realiz’o la oferta
va a emitir, de nuevo a la direcci’on de broadcast un paquete UDP con el
mensaje DHCP Ack (Acknowledgment).
9 El reconocimiento (DHCP Ack)
- Unicast message.
- On receiving the DHCPREQUEST message, the server verifies the lease
information, creates a new ARP entry for the client lease, and replies with
a unicast DHCPACK message. The DHCPACK message is a duplicate
of the DHCPOFFER, except for a change in the message type field.
When the client receives the DHCPACK message, it logs the configuration
information and performs an ARP lookup for the assigned address. If it
does not receive a reply, it knows that the IP address is valid and starts
using it as its own.
- Cuando el cliente recibe el DHCP Ack, aplica la configuraci’on recibida.
- Si el servidor finalmente negara al cliente el uso de la configuraci’on
ofertada ,
en lugar de transmitirse un DHCP Ack se transmitir’ia un DHCP NAck
(Negative Ack) y todo el proceso comienza de nuevo.
10 Atacks
11 BOOTP (Bootstrap Protocol)
The Bootstrap Protocol (BOOTP), defined in RFC 951, is the predecessor
of DHCP and shares some operational characteristics. BOOTP is a way
to download address and boot configurations for diskless workstations. A
diskless workstation does not have a hard drive or an operating system. For
example, many automated cash register systems at your local super market are
examples of diskless workstations. Both DHCP and BOOTP are client/server
based and use UDP ports 67 and 68. Those ports are still known as BOOTP
ports.
DHCP and BOOTP have two components. The server is a host with a static
IP address that allocates, distributes, and manages IP and configuration
data assignments. Each allocation (IP and configuration data) is stored
on the server in a data set called a binding. The client is any device using
DHCP as a method for obtaining IP addressing or supporting configuration
information.
There are three primary differences between DHCP and BOOTP:
- The main difference is that BOOTP was designed for manual
pre-configuration of the host information in a server database, while
DHCP allows for dynamic allocation of network addresses and
configurations to newly attached hosts. When a BOOTP client requests
an IP address, the BOOTP server searches a predefined table for an
entry that matches the MAC address for the client. If an entry exists,
the corresponding IP address for that entry is returned to the client. This
means that the binding between the MAC address and the IP address
must have already been configured in the BOOTP server.
- DHCP allows for recovery and reallocation of network addresses through a
leasing mechanism. Specifically, DHCP defines mechanisms through which
clients can be assigned an IP address for a finite lease period. This lease
period allows for reassignment of the IP address to another client later,
or for the client to get another assignment if the client moves to another
subnet. Clients may also renew leases and keep the same IP address.
BOOTP does not use leases. Its clients have reserved IP address which
cannot be assigned to any other host.
- BOOTP provides a limited amount of information to a host. DHCP
provides additional IP configuration parameters, such as WINS and
domain name.
12 DHCP message format
0 7 8 15 16 23 24 31
+--------------+---------------+----------------+----------------+
| OP | Hardware | Hardware | Hops |
| code | type | addr length | |
+--------------+---------------+----------------+----------------+
| Transaction Identifier |
+------------------------------+---------------------------------+
| Seconds | Flags |
+------------------------------+---------------------------------+
| Client IP addr (CIADDR) |
+----------------------------------------------------------------+
| Your IP addr (YIADDR) |
+----------------------------------------------------------------+
| Server IP addr (SIADDR) |
+----------------------------------------------------------------+
| Gateway IP addr (GIADDR) |
+----------------------------------------------------------------+
| Client hardware addr (CHADDR) |
+----------------------------------------------------------------+
| Server name (SNAME) |
+----------------------------------------------------------------+
| Filename |
+----------------------------------------------------------------+
| DHCP options |
+----------------------------------------------------------------+
- Operation Code (OP) - 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.
- Hardware Address length - 8 bits to specify the length of the address.
Hops - Set to 0 by a client before transmitting a request and 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 replies received from DHCP servers.
Seconds - Number of seconds elapsed since a client began attempting to
acquire or renew a lease. Busy DHCP servers use this number to prioritize
replies when multiple client requests are outstanding.
- Flags - Only one of the 16 bits is used, which is the broadcast flag. A client
that does not know its IP address when it sends a request, sets the flag to
1. This value tells the DHCP server or relay agent receiving the request
that it should send the reply back as a broadcast.
- Client IP Address - The client puts its own IP address in this field if and
only if it has a valid IP address while in the bound state; otherwise, it
sets the field to 0. The client can only use this field when its address is
actually valid and usable, not during the process of acquiring an address.
- Your IP Address - IP address that the server assigns to the client. Server
IP Address - 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 IP address in a
special field called the Server Identifier DHCP option.
- Gateway IP Address - Routes DHCP messages when DHCP relay agents
are involved. The gateway address facilitates communications of DHCP
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 - The server sending a DHCPOFFER or DHCPACK message
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.
- 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.
References