Sunteți pe pagina 1din 17

Dynamic Host Configuration Protocol

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

Host Configuration
Static IP configuration stored on local storage medium (disk, EEPROM, ...) 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

Dynamic Host Configuration Protocols


Reverse ARP Protocol RFC 903 IP address only IP address statically linked to MAC address Link level protocol - not routable Bootp Protocol RFC 951 Every conceivable IP option (address, subnetmask, DNS, routers, ...) 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

Leasing an IP Address
In DHCP negotiation, the client agrees on a lease time with the server Before the lease time is over, 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

DHCP Client-Server Interactions

1. DHCPDISCOVER 2. DHCPOFFERs 3. DHCPREQUEST


DHCP Client

DHCP Relay

DHCP Server

4. DHCPACK

DHCP Server

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

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.conf Works with Token Ring networks too ISC dhclient Basic syntax: dhclient [interface] Configuration file /etc/dhclient.conf Results stored in /var/lib/dhcp/dhclient.leases The client daemon is normally configured through the network configuration tools (redhat-config-network, yast) and started automatically

Linux DHCP Server


Most distributions use the DHCP server from the Internet Software Consortium (http://www.isc.org) Daemon program: dhcpd Configuration file: /etc/dhcpd.conf State file: dhcpd.leases Backup: dhcpd.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

Sample /etc/dhcpd.conf File


# cat /etc/dhcpd.conf option domain-name "example-company.com"; option domain-name-servers 10.1.1.3, 10.1.1.4; max-lease-time 3600; default-lease-time 600; ddns-update-style none; subnet 10.1.1.0 netmask 255.255.255.0 { option routers 10.1.1.1; option subnet-mask 255.255.255.0; range 10.1.1.10 10.1.1.50; host ns1 { hardware ethernet 00:04:ac:3f:45:9f; fixed-address 10.1.1.3; }

subnet 10.1.2.0 netmask 255.255.255.0 { }

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, but no standards formally exist so no interoperability with other DHCP servers. See man dhcpd.conf for more information

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 - interim standard used by ISC DHCP server and ISC DNS server
# vi /etc/dhcpd.conf ddns-update-style interim; key DHCP_UPDATER { algorithm hmac-md5; secret "pRP5FapFoJ95JEL06sv4PQ=="; }; zone example-company.com. { primary 10.1.1.3; key DHCP_UPDATER; } zone 1.1.10.in-addr.arpa. { primary 10.1.1.3; key DHCP_UPDATER; } # vi /etc/named.conf key DHCP_UPDATER { algorithm hmac-md5; secret "pRP5FapFoJ95JEL06sv4PQ=="; }; zone example-company.com. { type master; file "named.example-company.com"; allow-update{ DHCP_UPDATER; }; } zone 1.1.10.in-addr.arpa. { type master; file "named.10.1.1"; allow-update{ DHCP_UPDATER; }; }

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

Checkpoint
1. In what situations can you use DHCP? (Choose all that apply.)
a. To configure laptops automatically, regardless of the network the users connect their laptop to. b. To configure classroom PCs automatically with an IP address after restoring an image made by, for instance, ghost. c. If your customers dial in over a PPP link and need a dynamic IP address for that connection. d. To configure servers with a static IP address by using static DHCP addresses.

2. The DHCP packet used to figure out which DHCP servers are willing to offer you a lease is called _________________. 3. When a DHCP client shuts down cleanly, it "gives back" its IP address to the server by sending a _________________ packet. 4. Put the following DHCP messages in the correct order:
a. DHCPACK b. DHCPREQUEST c. DHCPREPLY d. DHCPRELEASE e. DHCPDISCOVER f. DHCPOFFER

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

S-ar putea să vă placă și