ELEC3506

Topics

DHCP and WANsLecture 9 PDF15 min

DHCP

How a host that has just joined a network gets an IP address, what else the DHCP server hands back, and the lecture's laptop example traced through UDP, IP and Ethernet.

By the end of this page you should be able to

  • Separate the two questions behind "how do I get an IP address" and say which one DHCP answers
  • List the four DHCP messages in order and say which two the lecture marks as skippable
  • List the extra items a DHCP server returns beyond the address
  • Trace the lecture's DHCP request from the laptop through each protocol layer to the router

The idea

A laptop that has just plugged into a network needs an IP address before it can do anything else. The lecture frames this as two separate questions. The first is how a host gets an address within its own network, the host part. The second is how a network gets an address for itself, the network part. DHCP answers only the first.

A sysadmin could type the address into a config file such as /etc/rc.config on UNIX. That does not suit a laptop that joins and leaves networks all day. DHCP, the Dynamic Host Configuration Protocol, lets the host ask a server for an address when it joins. The lecture calls it “plug-and-play”.

NAT and DHCP already covers the message exchange from Lecture 5. This page follows Lecture 9, which adds what else DHCP returns and traces the exchange through the protocol stack.

How it works

Goal and four messages

The lecture states the goal as a host dynamically obtaining an IP address from a network server when it joins. It lists four properties:

  • The host can renew its lease on an address in use.
  • Addresses can be reused, because a host only holds one while it is connected.
  • It supports mobile users who join and leave a network.
  • It is plug-and-play.

The overview is four messages:

  1. The host broadcasts a DHCP discover message. The lecture marks this one optional.
  2. The DHCP server responds with a DHCP offer message. Also optional.
  3. The host requests the address with a DHCP request message.
  4. The server sends the address in a DHCP ack message.

How it works

The client-server scenario

The lecture’s scenario has a router joining three subnets, with hosts such as 223.1.1.1, 223.1.2.5 and 223.1.3.27. The DHCP server is 223.1.2.5. A new client arrives and needs an address in this network.

Typically the DHCP server is co-located in the router, serving every subnet the router is attached to.

The message exchange in the lecture carries these details:

  • Discover. Source 0.0.0.0, port 68. Destination 255.255.255.255, port 67. The client has no address and does not know the server, so it broadcasts “is there a DHCP server out there?” with transaction ID 654.
  • Offer. Sent from the server, port 67, to the broadcast address, port 68. It proposes the address 223.1.2.4 and carries the same transaction ID 654 and a lifetime of 3600 secs.
  • Request. Source 0.0.0.0, port 68, destination 255.255.255.255, port 67. The client says “OK, I would like to use this address”, echoing 223.1.2.4, with a lifetime of 3600 secs.
  • Ack. Source 223.1.2.5, port 67, destination the broadcast address, port 68. The server confirms the address 223.1.2.4 and the 3600 secs lifetime.

The lecture notes that the first two steps can be skipped “if a client remembers and wishes to reuse a previously allocated network address” and cites RFC 2131.

Where marks get lost

Discover and offer are the optional pair

Only the first two messages can be skipped, and only when the client already remembers an address it wants to reuse. Request and ack always happen. A question that asks which messages are optional wants discover and offer.

How it works

DHCP returns more than an address

The lecture lists what DHCP can return besides the allocated address on the subnet:

  • The address of the first-hop router for the client, which is the client’s gateway router.
  • The name and IP address of the DNS server.
  • The network mask, which says which part of the address is the network and which part is the host.

This is why a laptop needs nothing configured by hand. The address gives it an identity. The router address tells it where to send anything outside the subnet. The DNS address lets it turn names into addresses.

How it works

The lecture's example, layer by layer

The connecting laptop uses DHCP to obtain its IP address, the address of the first-hop router and the address of the DNS server. The lecture shows the router at 168.1.1.1 with the DHCP server built in.

  1. The DHCP request is encapsulated in UDP, encapsulated in IP, encapsulated in Ethernet.
  2. The Ethernet frame is broadcast on the LAN, destination FFFFFFFFFFFF, and received at the router running the DHCP server.
  3. At the router the frame is demultiplexed: Ethernet demux’ed to IP, IP demux’ed to UDP, UDP demux’ed to DHCP.
  4. The server formulates a DHCP ack containing the client’s IP address, the IP address of the first-hop router, and the name and IP address of the DNS server.
  5. The reply is encapsulated and forwarded to the client, which demultiplexes it up to DHCP.
  6. The client now knows its own IP address, the name and IP address of the DNS server, and the IP address of its first-hop router.

DHCP rides on UDP because the client has no address and no connection, so a connectionless transport is the only option. See UDP.

Hard-coded addressDHCP
Who sets itSysadmin, in a config fileThe network, from a server, when the host joins
ReuseHeld whether or not the host is connectedHeld only while connected, so the address can be reused
Mobile usersPoor fitSupported, hosts join and leave freely
The lecture introduces DHCP as the plug-and-play alternative to a hand-edited config file.

In the exam

  • Two questions, one answer. DHCP is the host-part answer. Say so if asked what problem it solves.
  • Four messages in order: discover, offer, request, ack. Know that discover and offer are the optional ones.
  • Beyond the address: first-hop router, DNS server name and address, network mask. A “what else does DHCP return” question wants these three.
  • Encapsulation order for the request: DHCP in UDP in IP in Ethernet, sent as a broadcast to FFFFFFFFFFFF.
  • Ports: client 68, server 67. The client uses source 0.0.0.0 because it has no address yet.

Aside

The lecture’s figure for the scenario is partly garbled in the text dump, so the transaction ID on the request and ack is not quoted here. The four-message structure, the ports, the address 223.1.2.4 and the 3600 secs lifetime are all readable.

Check yourself

  • DHCP gives a host its host-part address when it joins, and lets it renew and release the lease.
  • Messages: discover, offer, request, ack. Discover and offer are optional if the client reuses a remembered address.
  • The server is usually in the router and also returns the first-hop router, the DNS server and the network mask.
  • The request travels as DHCP in UDP in IP in Ethernet, broadcast to FFFFFFFFFFFF.

Check yourself

  1. Which question does DHCP answer?
  2. A client already holds an address it wants to keep using. Which DHCP messages can it skip?
  3. Which of these does the lecture say a DHCP server can return in addition to the IP address?
  4. Why is the DHCP request sent to FFFFFFFFFFFF?