You are on page 1of 13

DHCP: Dynamic Host Configuration Protocol

GSR 2013/2014 PS-DEI/FCTUC

Topics
Key Concepts What is DHCP? What does it do? Basic functioning DHCP Clients Installation / configuration DHCP Servers installation configuration Database definition DHCP Relay Agents

GSR 2013/2014 PS-DEI/FCTUC

Key concepts
The Dynamic Host Configuration Protocol (DHCP) provides a framework for passing configuration information to hosts on a TCP/IP network. DHCP consists of two components: a protocol for delivering host-specific configuration parameters from a DHCP server to a host, and a mechanism for allocation of network addresses to hosts. (from IETF RFC 2131)

GSR 2013/2014 PS-DEI/FCTUC

Key concepts
DHCP is a protocol for automatic and dynamic delivery of IP addresses and other configuration parameters to local computers: Mobility support (e.g. laptops) More efficient management of the addressing space (notion of lease loaning of addresses) Centralized management of the configuration of network clients (addresses, routers, DNS servers, etc.), without the need for local configurations on each client, whenever a parameter is modified. DHCP is a standard, OS-independent protocol

GSR 2013/2014 PS-DEI/FCTUC

Key Concepts
client-server model DHCP is an evolution of BOOTP (Boot Protocol), used to provide diskless clients with an IP address provides to the clients: addresses (IP address, network mask, default gateway) pointers to name servers (DNS, etc.) other parameters (domain name, Microsoft Windows-parameters, etc.)

GSR 2013/2014 PS-DEI/FCTUC

Key Concepts
DHCP reply: - IP address - default gateway - DNS server - ... ...

DHCP request

cliente DHCP

servidor DHCP

GSR 2013/2014 PS-DEI/FCTUC

Obtaining an IP address (I)


1. Client sends a broadcast message DHCP Discover (UDP/67). Since the client has no IP address yet, the message is sent using IP address 0.0.0.0 as sender ID. 2. One or several servers respond with a DHCP Offer message (UDP/ 68), which includes the IP address offered to the client, the network mask, the DHCP server address and the duration of the lease (and possibly other service parameters). The server reserves this address until the client accepts/rejects the offer or a timeout occurs. 3. The Client selects one of the offered addresses and broadcasts a DHCP Request message. This message identifies the selected address and the server that offered this address. By sending this message by broadcast, the other servers may immediately release the addresses they previously reserved. 4. The server confirms the lease with a DHCP Ack
GSR 2013/2014 PS-DEI/FCTUC 7

Obtaining an IP address (II)


5. The client which gets the DHCP Ack starts using the IP address. 7. The client may optionally release the address before its lease expires.

GSR 2013/2014 PS-DEI/FCTUC

Source: http://www.isoc.org/inet95/proceedings/PAPER/127/html/paper.html

Address Management (Server-side)


the server keeps a list with all the addresses it can assign an address assigned to a client by the DHCP server is designated a lease. Each lease is associated with a maximum lifetime. The DHCP server keeps a record of all leases and their respective lifetime. addresses are leased by a limited period of time (lease time). After this period, they can no longer be used by the clients without express renewal authorization from the servers. the server can also be configured to always assign the same address to a specific client (based on its physical address).
GSR 2013/2014 PS-DEI/FCTUC 9

Address Management (Client-side)

the client tries to renew the leased address when the lease time reaches half its lifetime, sending a DHCP Request to the server. If the client is not able to renew the lease, he will retry later, and keep retrying until the lease expires. Usually the client stores the leased address in persistent memory, therefore keeping the assigned address between reboots (as well as the lease does not expire meanwhile). However, this behavior is not 100% assured (some clients may have a different behavior).

GSR 2013/2014 PS-DEI/FCTUC

10

DHCP Implementations

for Unix environments the most known DHCP implementation is from Internet Software Consortium (http://www.isc.org/). It is usually included in Linux distributions. the DHCP client is included in every Windows flavor. Windows Server also includes a DHCP server.

GSR 2013/2014 PS-DEI/FCTUC

11

ISC Implementation
DHCP server (/usr/sbin/dhcpd) DHCP client (/sbin/dhclient) DHCP relay agent (/usr/sbin/dhcrelay) Server configuration file (/etc/dhcpd.conf) Example configuration file: /usr/share/doc/dhcp-x.0/dhcpd.conf.sample File with assigned leases: /var/lib/dhcp/dhcpd.leases (file names and location may vary from OS to OS)
GSR 2013/2014 PS-DEI/FCTUC 12

DHCP Clients configuration


REDHAT
For instance on the file /etc/sysconfig/network-scripts/cfg-eth0
DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes

WINDOWS Obtain IP Address / DNS automatically

GSR 2013/2014 PS-DEI/FCTUC

13

DHCP Server configuration


the main configuration file is /etc/dhcpd.conf this file is composed of declarations, parameters and options: parameters: global or local to declarations; define the server behavior (for instance lease time) options: define configuration values which must be sent to the clients (for instance the IP address of the DNS server) declarations: define networks, hosts or groups; define the address ranges; can be nested (declarations nested inside declarations)

GSR 2013/2014 PS-DEI/FCTUC

14

dhcpd.conf - some types of declarations


GROUP: allows the application of a set of parameters and declarations to a set of clients or subnets HOST: defines parameters and declarations specific to a certain host SUBNET: allows the application of a set of parameters and declarations to all the clients of a certain subnet RANGE: defines the range of IP addresses which can be assigned to DHCP clients

GSR 2013/2014 PS-DEI/FCTUC

15

dhcpd.conf - some typos of declarations


ALWAYS-REPLY-RFC1048: used for clients that only understand the BOOTP protocol DEFAULT-LEASE-TIME: default lease time FIXED-ADDRESS: used for the host declarations; specifices the assignment of a fixed address (when used with the hardware parameter) HARDWARE: identifies an host using its physical (MAC) address MAX-LEASE-TIME: maximum lease time

GSR 2013/2014 PS-DEI/FCTUC

16

dhcpd.conf - some types of options


Broadcast-address: broadcast address in the client subnet Domain-name: name of the local DNS domain Domain-name-servers: DNS servers to be used by the clients Host-name: string that identifies the name of the client routers: list of routers to be used by the clients Subnet-mask: network mask to be used by the clients. For a larger list:
http://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xml

GSR 2013/2014 PS-DEI/FCTUC

17

dhcpd.conf example (1/3)


# Global Options (may be overriden) option domain-name "dei.uc.pt"; option domain-name-servers 193.136.212.1, 193.136.212.21; option netbios-name-servers master.dei.uc.pt; option ntp-servers ntp1.dei.uc.pt, ntp2.dei.uc.pt, ntp3.dei.uc.pt;

GSR 2013/2014 PS-DEI/FCTUC

18

dhcpd.conf example (2/3)


# Accounting subnet subnet 10.10.0.0 netmask 255.255.255.0 { range 10.10.0.1 10.10.0.20; # dynamic range default-lease-time 86400; # 24h lease time max-lease-time 90000; # 25h maximum lease time option subnet-mask 255.255.255.0; option broadcast-address 10.10.0.255; option routers 10.10.0.254; host contab1 { hardware ethernet 00:50:04:0a:86:db; fixed-address 10.10.0.50; } ( ) }
GSR 2013/2014 PS-DEI/FCTUC 19

dhcpd.conf example (3/3)


subnet 10.20.0.0 netmask 255.255.255.0 { deny unknown-clients; default-lease-time 28800; # 8h max-lease-time 36000; # 10h option subnet-mask 255.255.255.0; option broadcast-address 10.20.0.255; option routers 10.20.0.254; host pardal { hardware ethernet 00:02:3F:72:83:CE; fixed-address 10.20.0.20; } host student { hardware ethernet 00:E0:4C:39:00:2F; fixed-address 10.20.0.29; } }
GSR 2013/2014 PS-DEI/FCTUC 20

# Classes

10

DHCP and DDNS (Dynamic DNS Updates)

Standardized update mechanism defined by the IETF (RFC 2136). DHCP server may be configured to dynamically update the database of DNS zones, based on the assigned leases, either for direct mapping (A) or reverse mapping (PTR). For instance: a PC may have its Windows name reflected on DNS RRs. only active (leased) addresses appear on DNS RRs. It is necessary to ensure secure communication between the DHCP server and the DNS master server. more details after the first assignment
GSR 2013/2014 PS-DEI/FCTUC 21

DHCP relay agents


DHCP uses broadcast for initial address assignment this assumes that the server and the client are in the same subnet, which can be impossible or, at least, inconvenient. DHCP relay agents are placed in the local network where clients are, and act as mediators between servers and clients. They receive broadcasted DHCP requests and forward them to the DHCP servers, using unicast communication they are frequently placed in routers (why?)

GSR 2013/2014 PS-DEI/FCTUC

22

11

DHCP Address Planning


DHCP is only a mechanism, not an addressing policy Suggestions/Issues: Whenever possible, use fixed IP addresses, even for normal PCs (why?) define lease-times according to the need of renewals, but without compromising the availability of addresses for new clients in more dynamic scenarios. keep DHCP for reasonable periods of time (why?) choose between public and private IP address (which factors?)

GSR 2013/2014 PS-DEI/FCTUC

23

A step ahead: bootp and pxe


bootp (boot protocol) Mechanism to load OS images from the network: diskless workstations; X-terminals thin clients; PCs with hard-drive (remote maintenance, image distribution) Current practices: bootp is now integrated with DHCP. Each DHCP client may have associated to its physical address a DHCP option with the URL where it can find its OS image (besides other kernel parameters) the client then loads this OS-image from a TFTP server
GSR 2013/2014 PS-DEI/FCTUC 24

12

A step ahead: bootp and pxe


PXE (Preboot eXecution Environment) extension of the bootp concept, integrates with DHCP provides a basic execution environment for preOS applications, making it possible to use more efficient and more secure image transfer mechanisms typical preOS applications: diagnosis and recover from hardware failures, user authentication, file system recovery
Network Bootstrap Programs

PXE BIOS
GSR 2013/2014 PS-DEI/FCTUC

PreBoot API

TFTP API

UDP API

UNDI API

Network Interface Hardware


25

Additional References
On-line Resources: http://www.isc.org (ISC DHCP server) http://www.bind9.net/dhcp Bibliographic Resources: Jorge Granjal, Gesto de Sistemas e Redes em Linux, 2009 (Captulo 15) RFC 2131, Dynamic Host Configuration Protocol Craig Hunt, TCP/IP Network Administration, 3rd Edition, 2002 (chapter 9) RFC 2136, Dynamic DNS Updates

GSR 2013/2014 PS-DEI/FCTUC

26

13