DHCP Dynamic Host Configuration Protocol Polytechnic University Debie
DHCP Dynamic Host Configuration Protocol Polytechnic University Debie Beemsigne Dominic Joy Max Pereira Ravidev Mohan Edited by Malathi Veeraraghavan 1
Outline § § § What is DHCP, and when & where is it used? Components of DHCP BOOTP and DHCP relation DHCP message format DHCP procedures § allocating new address § lease renewal § § § State machine Questions & answers re. DHCP Benefits of DHCP 2
What is DHCP ? § Dynamic Host Configuration Protocol § Used for dynamic allocation of IP addresses § only possible for hosts that exclusively run client applications § Allows for host-specific configuration parameters to be delivered from a DHCP server to a host § DHCP can also be used to convey permanent IP address assignments to hosts § Server interfaces need permanent addresses because clients need to be able to reach them § Also, router interfaces should be permanent addresses for stability of routing data 3
Where is DHCP used? § Since class B and class C address spaces have been exhausted, service providers and enterprises use dynamically allocated IP addresses § e. g. , a cable modem service provider who has many customers § since not all customers are simultaneously on the Internet, a client host dynamically obtains an address for a short period of time and releases it for use by some other client § e. g. , used on the Poly campus on our 802. 11 wireless network, where many students, faculty and staff members use their wireless cards for access to the Poly campus network 4
Relevance of DHCP to wireless and mobile networking § If an end host only runs the “client” ends of applications § e. g. a web browser, but not a web server § e. g. Outlook to download email messages delivered to a PC user’s incoming mail server, but not the mail server itself § e. g. Windows PCs have ftp clients but not ftp servers § you ftp into utopia, but do you typically ftp into your PC? § Then, the end host can simply connect to the network at any “point of attachment, ” obtain a network address and start receiving information 5
Why is a dynamically obtained address sufficient for such hosts? § Because, such end hosts only make “outgoing calls” § When such an end host initiates a call (TCP connection), the called server receives an IP packet from the calling host with the host’s new temporary address and hence can, in turn, send the caller back requested data § These hosts do not receive “incoming calls, ” i. e. , no one calls them § Therefore, such end hosts do not need a permanent address that potentially “callees” will need to know § Question: can we categorize a cellular telephone as such an “end point” 6
Answer to question in previous slide § No, because a cell phone can be called § Therefore callees (calling parties) will need to know the network address of the cellular phone 7
Is DHCP needed only for wireless users or also wired? § DHCP can be used whether link to endpoint is “wired” or “wireless” § Even with an Ethernet NIC, a host can use DHCP to dynamically obtain an IP address § e. g. cable modem user; Ethernet from host to cable modem; cable from modem to Internet 8
DHCP for mobile users? § DHCP not designed to handle mobility by itself § location management problem is to enable the delivery of calls to mobiles; end hosts that can dynamically obtain addresses are never “called; ” so location management problem does not arise for DHCP hosts § handoff management requires a rerouting of packets when end host is in a connection; “costly” to update far end of connection with a new temporary address if DHCP is used to change addresses when a user moves 9
Components § DHCP client: a host using DHCP to obtain an IP address and other configuration information § DHCP server: a host that returns IP addresses and other configuration information § BOOTP relay agents: host or router that passes DHCP messages between DHCP clients and DHCP servers 10
DHCP uses BOOTP § Based on BOOTP § Uses BOOTP format for messages § Uses BOOTP relay agents to avoid having one DHCP server per network segment § BOOTP used to bootstrap hosts § First operation, get address and bootfile selection (diskless client) § Second operation, uses TFTP to download file § BOOTP uses UDP § 67 for the server port § 68 for the client port 11
Differences between BOOTP and DHCP § Two differences § DHCP specifies a “lease time” for IP address usage allowing for allocation of the same address to another client upon lease expiry § DHCP can acquire all IP-related configuration information, not just an address § BOOTP clients can talk to DHCP servers (backward compatibility) § DHCP is an extension of BOOTP § Message format similar 12
Format of a DHCP message op (1) htype (1) hlen (1) xid (4) secs (2) hops(1) flags (2) ciaddr (4) yiaddr (4) siaddr (4) giaddr (4) chaddr (16) sname (64) file (128) options ( variable) 13
BACK Format of a DHCP message cont. § Op - message op code / message type § 1=Boot. Request, 2= Boot. Reply § htype - hardware address type § hlen - hardware address length (i. e. ‘ 6’ for 10 mbps Ethernet) § hops - client sets to 0, optionally used by relay agents when booting § § § via a relay agent xid - transaction ID, a random number chosen by the client, used by the client and server to associate messages and responses between a client and a server secs – filled in by the client, seconds elapsed since client began address acquisition or renewal process flags – “broadcast flag” used if client cannot accept unicast IP packets before IP layer is configured (“chicken-and-egg” problem) § destination IP address in IP header is a broadcast IP address instead of yiaddress and destination MAC address is all ones; then set this flag to “broadcast” mode. Server receiving this flag in Bootrequest will know to send the Bootreply in broadcast mode 14
BACK Format of a DHCP message cont. § ciaddr – client IP address; only filled in if client is in § § § § BOUND, RENEW or REBINDING state and can respond to ‘ARP’ requests yiaddr – ‘your’ (client) IP address siaddr – IP address of next server to use in bootstrap; returned in DHCPOFFER, DHCPACK by server giaddr – relay agent IP address, used in booting via a relay agent chaddr – client hardware addresses sname – optional server host name, null terminated string file – Boot file name, null terminated string; “generic” name or null in DHCPDISCOVER, fully qualified directory-path name in DHCPOFFER 15 options – optional parameters field (see RFC 1533)
DHCP options § § § § Client IP Address Subnet Mask Client Hostname DHCP Lease Time DHCP Message Type Renewal Time Value Rebinding Time Value § Max Datagram § § Reassembly Interface MTU Broadcast Address Mobile. IP Home Agent DNS (Domain Name Server) §For all other options refer to RFC 2132 16
Types of DHCP messages § DHCPDISCOVER § DHCPOFFER § DHCPREQUEST § DHCPACK § DHCPNAK § DHCPDECLINE § DHCPRELEASE § DHCPINFORM 17
How does DHCP work? § When a client needs to start up TCP/IP operations, it broadcasts a request for address information. The DHCP server receives the request, assigns a new address for a specific time period (called a lease period) and sends it to the client together with the other required configuration information. This information is acknowledged by the client, and used to set up its configuration. The DHCP server will not reallocate the address during the lease period and will attempt to return the same address every time the client requests an address. The client may extend its lease with subsequent requests, and may send a message to the server before the lease expires telling it that it no longer needs the address so it can be released and assigned to another client on the network. 18
DHCP procedures § Allocating/obtaining new addresses § Lease renewal/reuse of address 19
Allocating new address Server (not selected) Server (selected) Client DHCP DISC. FER DHCPOF F DHCPOF ER DHCP REQ. Collects replies DHCP REQ. CK DHCPA Initialization Complete Graceful Shutdown Client selects configuration; in DCHP REQ it accepts one server’s offer and implicitly reject rest DHCPRELEASE Discard lease 20
How the server selects ‘ a new address § The client's current address as recorded in the § § § client's current binding, ELSE The client's previous address as recorded in the client's (now expired or released) binding, if that address is in the server's pool of available addresses and not already allocated, ELSE The address requested in the 'Requested IP Address' option, if that address is valid and not already allocated, ELSE A new address allocated from the server's pool of available addresses; the address is selected based on the subnet from which the message was received (if 'giaddr' is 0) or on the address of the relay agent that forwarded the message ('giaddr' when not 0). 21
Obtaining an IP address § DHCPDISCOVER is broadcast because client does not know IP address of DHCP server; BOOTP relay agents may relay it to other DHCP servers § One or more DHCP servers respond with DHCPOFFER, which carry yiaddr (Your IP address, i. e. , client address) after checking that the address is free using ICMP echo request (ping) § ping needed because often a user will leave without graceful release of address 22
Obtaining an IP address contd. § If the client receives no DHCP offer before it times out, it retransmits DHCPDISCOVER § Client may wait for multiple replies and then choose one offer. It broadcasts DHCPREQUEST with ‘server identifier’ option included identifying the server whose offer it has accepted and ‘requested IP address’ option § Client should probe address with an ARP; if client detects that the address is already in use, it issues DHCPDECLINE 23
Obtaining an IP address contd. § Servers other than the one selected in the DHCPREQUEST will release their offered addresses, while the selected server will note the binding § If selected server cannot meet the needs of the DHCPREQ. it sends a DHCPNAK § If the client does not receive a DHCPACK or DHCPNAK before timeout it resends DHCPREQ. § Retransmission attempts use exponential backoff times; 24
Lease renewal Server Client Begin Initialization DHCP REQUEST Locates Configuration DHCPACK Initialization complete Time DHCPACK (Subsequent DHCPACKS ignored) 25
Reuse of address Server (selected) Client DHCP REQ. Locates Config. Server (selected) DHCP REQ. Locates Config. DHCPACK Initialization Complete (Subsequent DHCP Packets Ignored) 26
Reuse of IP address § DHCP REQUEST - client message to servers § requesting offered parameters from one server and implicitly declining offers from all others § confirming correctness of previously allocated address after, e. g. , system reboot, § extending the lease on a particular network address. 27
Reuse of IP address cont. § DHCPACK - Server to client with configuration parameters, including committed network address. 28
State machine init with known network address Init with acquiring new network address DHCPNAK Restart Send DHCPDISCOVER SELECTING REBOOTING DHCPACK/Record lease, set timers DHCPNAK/ Discard DHCPACK + not accept Send DHCPDECLINE DHCPOFFER/ Send DHCPREQUESTING DHCPACK/ Record lease, set Timers T 1, T 2 DHCPNAK/Halt Network Send DHCPREQUEST INIT DHCPNAK, Lease expired/Halt Network INIT/ REBOOT REBINDING DHCPOFFER/ Discard DHCPACK/ Record lease, set timers. T 1, T 2 BOUND DHCPOFFER, DHCPACK DHCPNAK/Discard DHCPACK/Record lease set timers. T 1, T 2 expires/ Broadcast DHCPREQUEST RENEWING T 1 expires/ Send DHCPREQUEST To leasing server T 1 is earlier than T 2, which should expire before lease expires 29
Questions on DHCP § What happens if there is no DHCP server on a network § § and an IP host connects to it with the “Obtain IP address automatically” option selected? Who makes and sells DHCP servers? Are these standalone entities or are they add-ons to IP routers? Perform a tcpdump and explain DHCP message parameters. Can DHCP support mobility across 802. 11 LANs (on different subnets)? Comment on the speed of DHCP. 30
What happens if there is no DHCP server on a network and an IP host connects to it with the “Obtain IP address automatically” option selected? 31
What happens if there is no DHCP server on a network and an IP host connects to it with the “Obtain IP address automatically” option selected? If there is no DHCP server, and no BOOTP relay agent, then no IP address will be assigned and hence host cannot communicate; In this case “Static Addressing” needs to be used In static addressing, the following fields: Gateway, WINS Configuration, DNS Configuration and IP Address would have to be manually set for a host to have connectivity into the network. 32
Who makes and sells DHCP servers? Are these standalone entities or are they add-ons to IP routers? § Commercial DHCP servers § Microsoft: DHCP server included in Windows NT Server 3. 51, 4. 0, Windows 2000 § Sun. Soft: Solstice Solar. Net PC-Admin 1. 5 includes a DHCP/BOOTP server § Cisco IOS DHCP Server (IOS is used in routers) 33
Use tcpdump and obtain a trace of a DHCP session Current IP configuration (before release) 34
Use tcpdump and obtain a trace of a DHCP session § Tcpdump Output (Release) C: WINDOWSDESKTOPWINDUMP. EXE: listening on EL 3 C 574 17: 18: 20. 069309 0: 50: 4: fd: 10: 85 0: b 0: c 2: f 3: 15: 80 0800 342: 128. 238. 112. 144. 68 > 128. 238. 29. 25. 67: xid: 0 xc 29 c 14 f flags: 0 x 8000 C: 128. 238. 112. 144 [|bootp] 4500 0148 3801 0000 8011 721 e 80 ee 7090 hops IP header 80 ee 1 d 19 0044 0043 0134 f 6 e 1 0101 0600 hlen 0 c 29 c 14 f 0000 80 ee 7090 0000 Source Port Number htype field #68 0000 0050 04 fd 1085 0000 Op field 0000 0000 xid field 0000 Destination Port Number#67 adapter address flags ciaddr field 35
IP configuration after release 36
Tcpdump output for a renew § § § § § § § 17: 26: 32. 135029 0: b 0: c 2: f 3: 15: 80 0: 50: 4: fd : 10: 85 0800 482: 128. 238. 112. 1. 67 > 128. 238. 112. 144. 68: xid: 0 x 596 f 374 e Y: 128. 238. 112. 144 0: 50: 4: fd: 10: 85 S: 128. 238. 29. 25 G: 128. 238. 112. 1 [|bootp] 4500 01 d 4 b 330 0000 ff 11 247 a 80 ee 7001 80 ee 7090 0043 0044 01 c 0 3 bb 7 0201 0600 596 f 374 e 0000 80 ee 7090 80 ee 1 d 19 80 ee 7001 0050 04 fd 1085 0000 0000 0000 17: 26: 32. 135144 0: 50: 4: fd : 10: 85 ff: ff: ff: ff 0800 342: 0. 0. 68 > 255. 67: xid: 0 x 596 f 374 e [|bootp] 0: 50: 4: fd: 10: 85 4500 0148 4401 0000 8011 f 5 a 4 0000 ffff 0044 0043 0134 a 8 ac 0101 0600 596 f 374 e 0000 0000 0000 0050 04 fd 1085 0000 0000 0000 17: 26: 32. 142934 0: b 0: c 2: f 3: 15: 80 0: 50: 4: fd : 10: 85 0800 487: 128. 238. 112. 1. 67 > 128. 238. 112. 144. 68: xid: 0 x 596 f 374 e Y: 128. 238. 112. 144 0: 50: 4: fd: 10: 85 G: 128. 238. 112. 1 [|bootp] 4500 01 d 9 b 332 0000 ff 11 2473 80 ee 7001 80 ee 7090 0043 0044 01 c 5 cb 6 b 0201 0600 596 f 374 e 0000 80 ee 7090 0000 80 ee 7001 0050 04 fd 1085 0000 0000 0000 17: 26: 32. 143044 0: 50: 4: fd : 10: 85 ff: ff: ff: ff 0800 346: 0. 0. 68 > 255. 67: xid: 0 x 596 f 374 e [|bootp] 0: 50: 4: fd: 10: 85 4500 014 c 4501 0000 8011 f 4 a 0 0000 ffff 0044 0043 0138 ddee 0101 0600 596 f 374 e 0000 0000 0000 0050 04 fd 1085 0000 0000 0000 37
IP configuration after the renew 38
TCP DHCP Release and Renew § § § § § § C: WINDOWSCOMMANDWINDUMP. EXE: listening on EL 3 C 574 14: 33: 57. 285551 128. 238. 110. 84. 68 > 128. 238. 29. 25. 67: xid: 0 x 2 c 12 fc 0 c flags: 0 x 80 00 C: 128. 238. 110. 84 [|bootp] 14: 33: 59. 923127 128. 238. 110. 1. 67 > 128. 238. 110. 84. 68: xid: 0 x 77514 b 14 Y: 128. 238. 110. 84 S: 128. 238. 29. 25 G: 128. 238. 110. 1 [|bootp] 14: 33: 59. 929897 128. 238. 110. 1. 67 > 128. 238. 110. 84. 68: xid: 0 x 77514 b 14 Y: 128. 238. 110. 84 G: 128. 238. 110. 1 [|bootp] 14: 33: 59. 930499 arp who-has 128. 238. 110. 84 tell 128. 238. 110. 84 14: 34: 00. 769168 128. 238. 110. 84 > 224. 0. 0. 2: icmp: router solicitation 14: 34: 01. 714654 128. 238. 29. 23. 137 > 128. 238. 110. 84. 137: >>> NBT UDP PACKET(137): REGISTRATION; POSITIVE; RESPONSE; UNICAST 14: 34: 01. 714775 128. 238. 110. 84. 137 > 128. 238. 29. 23. 137: >>> NBT UDP PACKET(137): REGISTRATION; REQUEST; UNICAST 14: 34: 01. 714790 128. 238. 110. 84. 137 > 128. 238. 29. 23. 137: >>> NBT UDP PACKET(137): REGISTRATION; REQUEST; UNICAST 14: 34: 01. 714799 128. 238. 110. 84. 137 > 128. 238. 29. 23. 137: >>> NBT UDP PACKET(137): REGISTRATION; REQUEST; UNICAST 14: 34: 01. 715000 128. 238. 29. 23. 137 > 128. 238. 110. 84. 137: >>> NBT UDP PACKET(137): REGISTRATION; POSITIVE; RESPONSE; UNICAST 14: 34: 01. 715429 128. 238. 29. 23. 137 > 128. 238. 110. 84. 137: >>> NBT UDP PACKET(137): REGISTRATION; POSITIVE; RESPONSE; UNICAST 14: 34: 03. 774056 128. 238. 110. 84 > 224. 0. 0. 2: icmp: router solicitation 14: 34: 06. 773913 128. 238. 110. 84 > 224. 0. 0. 2: icmp: router solicitation Release Renew 39
Comment on the speed of DHCP § If DHCP servers have to ping all hosts to check if an address is truly free, this will take time § Depends on location of BOOTP relay agents and DHCP servers § Why is this ping necessary? § Because a host does not issue a renewal but is still online past its lease time; if client coded to issue a renewal, why would this happen? § Will a server ping for an address whose lease is still not up if all addresses are taken with the “hope” that a host left without gracefully releasing address? § Is a conflict of address space possible between different DHCP servers if multiple are present on one subnet? There is no server -to-server protocol yet 40
Benefits of using DHCP for dynamic address allocation § Address reuse § A service provider/enterprise with 1000 addresses can support a much larger number of subscribers/hosts with time multiplexing of addresses (one host uses an address, and releases it when done; another host is allocated the same address) § Removes error-prone manual host configuration process to set IP addresses, DNS server addresses, gateways, etc. § Configuration information can be administered from a single point. § Major network resource changes (e. g. a router changing an interface address) requires an update of only the DHCP server, rather than every system. § Caveat: cannot allocate temporary addresses to 41 servers/routers
References § § RFC 2131: DHCP RFC 2132: DHCP options RFC 951: Bootstrap protocol (BOOTP) Steven M. Glass, “Use of DHCP in Mobile IP, ” 2000, http: //www. ietf. org/proceedings/00 jul/SLIDES/mobileipdhcpinmip/index. htm § Charles Perkins, “Mobile IP”, Addison Wesley, 1998 § Other RFCs: 1533, 1541, 1542, 2132 42
- Slides: 42