Give a device the same address every time#
You will end up with a device that always gets the same address from the router's DHCP server, without configuring anything on the device itself. This is what you want for a printer, a NAS, a camera, or anything a firewall rule or a port forward names by address.
Before you start#
- The operator role and a licence.
- The device's MAC address, and an address for it outside the pool. An address inside the pool can be handed to something else before the reservation's owner asks for it.
- A DHCP scope that already exists on that subnet.
Step 1 — Find the device#
Network → DHCP. The page shows the shared networks and subnets the configuration declares, the static reservations in each, and the live lease table — and it cross-links between them, so the fastest way to make a reservation is from the lease the device already has.
Step 2 — Add the reservation#
+ Add reservation. Choose the subnet, name the mapping, and give the address and MAC.
set service dhcp-server shared-network-name LAN subnet 192.0.2.0/24 static-mapping printer ip-address 192.0.2.10
set service dhcp-server shared-network-name LAN subnet 192.0.2.0/24 static-mapping printer mac 00:00:5e:00:53:01The name is the mapping's identifier in the configuration. VyOS accepts letters, digits and hyphens; keep it recognisable, because it is what you will see in a diff two years from now.
To change an existing one, open its row: the panel shows the current values and stages only what you edit.
Step 3 — Make the device ask again#
A reservation does not take a lease away from a device that already has one. Either wait for the lease to expire, or make the client renew — unplug and replug, or release and renew on the device.
Check it worked#
The lease table shows the new address. Network → DHCP, the live lease rows.
show dhcp server leasesAnd the device is where you expect it:
ping -c 3 192.0.2.10What you cannot do per reservation#
Undoing it#
delete service dhcp-server shared-network-name LAN subnet 192.0.2.0/24 static-mapping printerThe reservation panel's Delete reservation stages exactly that. The device keeps its current lease until it expires.
See also#
- Authoritative records for local names — give the reserved address a name too
- Publish a service — a forward names an address, so reserve it first
- Relay DHCP to another segment
- DHCP — IPv4
Checked against ui/src/pages/Dhcp.tsx ·
agent/main.go ·
tools/opnsense-import.py