AQA 7517, section 4.9.4.7
Every device on a network needs an IP address, and other settings, to communicate. They could be typed in by hand for each device (static configuration), but on most networks they are given out automatically by DHCP.
What is DHCP?
DHCP (Dynamic Host Configuration Protocol) is a protocol that automatically assigns IP addresses and other network settings to devices when they join a network.
A DHCP server (often built into the home or office router) keeps a pool of available addresses. When a device connects, it is given one temporarily.
What does DHCP provide?
A device gets all that it needs to work on the network:
- an IP address;
- a subnet mask;
- the default gateway (the router's address);
- the address of the DNS server.
How it works
The conversation between a new device (the client) and the DHCP server is often remembered as DORA:
- Discover: the new device has no address, so it broadcasts a message to the whole network: "Is there a DHCP server?"
- Offer: the DHCP server offers an available address (with the mask, gateway and DNS).
- Request: the device replies that it accepts the offered address, by sending the accepted settings back to the server.
- Acknowledge: the server confirms, and records that the address is now in use by this device.
Leases
The address is leased, not given forever. The lease lasts for a set time (such as 24 hours). Before it expires, the device asks to renew it. If the device leaves the network and doesn't renew, the address returns to the pool and can be used by another device. This lets a small number of addresses serve many devices that come and go.
Why is DHCP used?
- Automatic and easy. Users don't need to know any network settings. A phone joining a WiFi network just works.
- Avoids errors and conflicts. Typing addresses by hand can lead to mistakes, or two devices with the same address, which causes problems. The server makes sure that each address is given to only one device.
- Saves addresses. Addresses are reused as devices leave.
- Easy to manage and change. An administrator can change settings, such as the DNS server, in one place, instead of on every device.
- Suited to mobile devices that move between networks.
Dynamic and static addresses
| Dynamic (DHCP) | Static (manual) | |
|---|---|---|
| Set by | The DHCP server | The administrator, by hand |
| Changes? | Can change each time | Fixed |
| Effort | Little | More, for every device |
| Risk of clashes | Low | Higher |
| Used for | Laptops, phones, ordinary computers | Servers, printers, routers, devices that must always be at the same address |
A reservation can combine the two, with the DHCP server always giving the same address to a particular device (recognised by its MAC address).
Worked example
Task: a school adds 30 new tablets to its WiFi. Explain why it uses DHCP, and what each tablet receives.
- Entering an address, mask, gateway and DNS server by hand on 30 tablets would take a long time and risk typing mistakes and duplicate addresses.
- With DHCP, each tablet automatically receives a unique IP address from the pool, plus the subnet mask, default gateway and DNS server, when it connects.
- When the tablets are switched off and leave the network, their addresses are returned to the pool when the leases expire.
- The school's web server, however, uses a static address, so that others can always find it. If DHCP changed its address, port forwarding (4.9.4.9) to it would stop working.
Exam tip: describe the four steps in order: discover (broadcast), offer, request (accept), acknowledge. Mention that addresses are leased from a pool and reused, which helps with the shortage of IPv4 addresses. Saying only "the server gives the device an IP address" is not enough.
Check yourself
What does DHCP do?
It automatically assigns IP addresses (and other network settings, such as the subnet mask, default gateway and DNS server) to devices when they join a network.
Give two advantages of using DHCP instead of setting addresses manually
Any two of: it is automatic and easy for users; it avoids typing errors and duplicate addresses; addresses are reused when devices leave; settings can be changed centrally; it suits mobile devices.
What is an address lease?
A DHCP address is given for a limited time. If it isn't renewed, it returns to the pool and can be given to another device.
Why might a web server be given a static address?
Other devices (and DNS) need to find it at the same address every time, so it must not change.