Sub topic 8
Scopes, exclusions and reservations on a server
This chapter assumes you know IPv4 addressing and subnet masks, what a default gateway and DNS server do, and the Discover, Offer, Request, Acknowledge exchange. It shows how a DHCP server decides which addresses to hand out and which to keep back.
What a scope is
A scope is the set of configuration a server offers on one subnet. It has four parts:
- An address range, for example 192.168.1.100 to 192.168.1.200.
- A subnet mask that matches the subnet.
- A lease time.
- Options such as the router and DNS server, which are covered in the previous chapter.
A server keeps one scope for each subnet it serves. When a Discover arrives, the server picks the scope that matches the subnet the request came from. It then offers a free address from that scope. Chapter 10 explains how a relay agent tells the server which subnet that is.
Exclusions
An exclusion is an address or range inside a scope that the server must never hand out. You use exclusions for devices that have a static address inside the range, such as a printer at 192.168.1.150. Without an exclusion, the server could lease that address to a laptop, and two hosts would then claim the same address.
The simplest approach is to keep the dynamic range separate from the static addresses. For example, you can use .1 to .99 for static devices and .100 to .200 for DHCP. Then you need no exclusions at all. Exclusions are most useful when static devices already sit in the middle of a range you cannot change.
Reservations
A reservation ties one MAC address to one IP address. The device still uses DHCP and still receives all the scope options. The server simply always offers it the same address. This differs from a static address in three ways:
- The address is configured in one place, on the server, so you can change it without visiting the device.
- The device also gets the gateway, DNS server and other options automatically.
- If you replace the device, you update one MAC address on the server.
A reserved address is normally taken from inside the scope range, or at least from the same subnet. Check your server software for its exact rule.
A working example
The dnsmasq configuration below defines a scope with a 12-hour lease and one reservation.
# /etc/dnsmasq.conf (DHCP part only)
interface=eth0
# Hand out 192.168.1.100-192.168.1.200 with a 12-hour lease
dhcp-range=192.168.1.100,192.168.1.200,255.255.255.0,12h
# Option 3 (router) and option 6 (DNS server)
dhcp-option=option:router,192.168.1.1
dhcp-option=option:dns-server,192.168.1.1
# Reservation: this MAC address always gets the same IP
dhcp-host=aa:bb:cc:dd:ee:ff,192.168.1.50The dhcp-range line is the scope: it sets the pool, the mask and the lease time. The two dhcp-option lines add the router and DNS server. The dhcp-host line is the reservation. The range here is .100 to .200, so the reserved address .50 sits outside the pool. That is allowed in dnsmasq, and it also keeps the reservation from being used by any other client.
Common errors
- Pool too small. If the pool has fewer addresses than active devices, new clients get no offer. Size the pool for peak use plus growth, and shorten the lease on busy guest networks so addresses return sooner.
- Missing exclusion. A static device inside the pool causes an address conflict. A client can detect this and send a Decline message.
- Wrong MAC address. A reservation only works if the MAC matches. Some devices use a random MAC per network, so the reservation never matches.
- Reservation outside the subnet. The client gets an address that does not fit its mask and cannot reach the gateway.
Exercise
A scope covers 10.0.0.10 to 10.0.0.100. A printer has the static address 10.0.0.50. What should you do on the server, and why? Then say how a reservation would change this setup.
Show answer
Add an exclusion for 10.0.0.50 so the server never leases it to another client, which would cause an address conflict. With a reservation, you would instead set the printer to use DHCP and tie its MAC address to 10.0.0.50 on the server. The printer would then also receive the gateway and DNS options automatically.