Dynamic Host Configuration Protocol

students should be able to: Describe the purpose and operation of DHCP Configure DHCP clients Configure DHCP servers .Objectives After completing this unit.

Host Configuration Static IP configuration stored on local storage medium (disk. .) Requires one IP address for every machine Requires local configuration on each system Typically used for servers Dynamic IP configuration assigned by server Requires one IP address for every active machine only Does not require any local configuration Typically used for clients .. EEPROM..

) IP address statically linked to MAC address Uses UDP .routable DHCP Protocol RFC 2131 and 2132 Downwards compatible with Bootp IP address dynamically assigned with lease time .not routable Bootp Protocol RFC 951 Every conceivable IP option (address.Dynamic Host Configuration Protocols Reverse ARP Protocol RFC 903 IP address only IP address statically linked to MAC address Link level protocol ... routers. subnetmask. DNS. .

the client has to: Abandon the lease Renew the lease All lease times are expressed as offset from now in seconds Prevents against problems when clocks are out of sync . the client agrees on a lease time with the server Before the lease time is over.Leasing an IP Address In DHCP negotiation.

DHCPREQUEST DHCP Client DHCP Relay DHCP Server 4. DHCPDISCOVER 2. DHCPOFFERs 3. DHCPACK DHCP Server .DHCP Client-Server Interactions 1.

DHCP Renewal T1(0.5* duration of lease) Client Renewing State DHCPREQUEST (unicast) DHCPACK Server [commits configuration] or [ignores request] T2 (0.875* duration of lease) Lease Expires [Rebinding State] DHCPREQUEST (broadcast) [Init State] DHCPDISCOVER Graceful shutdown DHCPRELEASE Discards lease [commits configuration] or [ignores request] .

Selected DHCP Options IP address Subnet mask Time offset Router Time server Domain name server LPR server Hostname Domain name IP forwarding enable/disable Static routes .

Linux DHCP Implementation Linux as a DHCP client dhcpcd pump dhclient Linux as a DHCP relay ISC dhcprelay Linux as a DHCP server ISC dhcpd .

leases The client daemon is normally configured through the network configuration tools (redhat-config-network. yast) and started automatically .conf Results stored in /var/lib/dhcp/dhclient.conf Works with Token Ring networks too ISC dhclient Basic syntax: dhclient [interface] Configuration file /etc/dhclient.Linux DHCP Clients dhcpcd Basic syntax: dhcpcd [interface] Results stored in /var/lib/dhcpcd directory Does not work on Token Ring networks Red Hat pump Basic syntax: pump [-i interface] Configuration file /etc/pump.

leases~ Server will not start if the state file is not present The server is started as any other service rcdhcpd start service dhcpd start .conf State file: dhcpd.leases Backup: dhcpd.org) Daemon program: dhcpd Configuration file: /etc/dhcpd.isc.Linux DHCP Server Most distributions use the DHCP server from the Internet Software Consortium (http://www.

host ns1 { hardware ethernet 00:04:ac:3f:45:9f.255.1.0 { } . ddns-update-style none.0 netmask 255. fixed-address 10. max-lease-time 3600.0 netmask 255.2. option subnet-mask 255.255. default-lease-time 600.0 { option routers 10.1.1.conf option domain-name "example-company. } } subnet 10. 10.Sample /etc/dhcpd.conf File # cat /etc/dhcpd. range 10.com". option domain-name-servers 10.1. subnet 10.1.

DHCP Considerations Every dynamic IP address needs a DNS entry Regular and reverse lookups! The get-lease-hostnames statement retrieves the hostname for each dynamic IP address and sends that to the client as hostname option Multiple DHCP servers: Make sure each DHCP server has its own range Make sure all static declarations are defined on each server Failover is supported.conf for more information . See man dhcpd. but no standards formally exist so no interoperability with other DHCP servers.

10.com". key DHCP_UPDATER. { type master. key DHCP_UPDATER { algorithm hmac-md5. } zone 1.conf ddns-update-style interim.1.10.arpa. } zone 1.interim standard used by ISC DHCP server and ISC DNS server # vi /etc/dhcpd.in-addr. }. zone example-company.com.com.3. } . } # vi /etc/named. key DHCP_UPDATER. file "named. }.1.1. { primary 10.1.Dynamic DNS DDNS: Method where the DHCP server automatically registers hostname/IP address combinations with the DNS server using the client's "host-name" DHCP option Currently no formal RFC available . { primary 10. zone example-company.example-company.1". { type master. }.1. secret "pRP5FapFoJ95JEL06sv4PQ==". allow-update{ DHCP_UPDATER.conf key DHCP_UPDATER { algorithm hmac-md5.1. secret "pRP5FapFoJ95JEL06sv4PQ==". }.3.arpa.1.10. allow-update{ DHCP_UPDATER. file "named.in-addr.

conf Check existence of state file Check server log file (/var/log/messages) Check server leases file (/var/lib/dhcp/dhcpd. ifconfig Verify time on systems is synchronized Check DHCP packet exchange with a sniffer tcpdump ethereal .Troubleshooting DHCP If server won't start at all: Check syntax of /etc/dhcpd.leases) Check client IP address assignment Win9x: winipcfg WinNT/2000: ipconfig Linux: pump -s. dhcpcd -s.

DHCPREQUEST c. If your customers dial in over a PPP link and need a dynamic IP address for that connection. To configure classroom PCs automatically with an IP address after restoring an image made by. 4. DHCPDISCOVER f.Checkpoint 1. Put the following DHCP messages in the correct order: a. d. 3. DHCPACK b. The DHCP packet used to figure out which DHCP servers are willing to offer you a lease is called _________________. it "gives back" its IP address to the server by sending a _________________ packet. DHCPREPLY d. In what situations can you use DHCP? (Choose all that apply. 2. To configure laptops automatically. DHCPRELEASE e. c. When a DHCP client shuts down cleanly.) a. ghost. To configure servers with a static IP address by using static DHCP addresses. DHCPOFFER . regardless of the network the users connect their laptop to. for instance. b.

Unit Summary It is very useful to configure IP clients dynamically No local configuration necessary Less IP addresses needed The DHCP protocol allows dynamic client configuration Linux can act as a DHCP client using the client daemons pump. dhcpcd or dhclient Linux can act as a DHCP server using the server daemon dhcpd The DHCP server is configured in /etc/dhcpd.conf The ISC DHCP server supports Dynamic DNS if you also use the ISC DNS server .