update_static_dhcp_lease
update_static_dhcp_lease
Section titled “update_static_dhcp_lease”Convert or update an existing client to a fixed-IP reservation.
Use this instead of create_static_dhcp_lease when the MAC already
has a user record on the controller (any client that has ever
connected). The controller rejects POST /rest/user for known MACs
with api.err.MacUsed; this tool resolves the existing _id and
PUTs an update to /rest/user/{_id} instead.
Side effects:
- Sets
use_fixedip=trueand pinsfixed_ipon the user record. - If
local_dns_recordis supplied, also setslocal_dns_record_enabled=trueso the name resolves on the LAN (controller version permitting). - Mutates controller state. Use dry_run=True to preview the change without applying.
- If no user record exists for
mac, the call fails with a clear error. In that case usecreate_static_dhcp_leaseinstead.
Example
Section titled “Example”update_static_dhcp_lease(mac="d0:11:e5:03:f6:3a", fixed_ip="192.168.1.50", network_id="6a0...", name="cypher")Parameters
Section titled “Parameters”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
mac | string | yes | — | Client MAC address (e.g. "d0:11:e5:03:f6:3a"). |
fixed_ip | string | yes | — | IPv4 address to pin. Must be inside the network’s subnet. |
network_id | string | yes | — | _id of the network/VLAN the IP belongs to. |
name | string | no | "" | Friendly display name / hostname alias (optional). |
local_dns_record | string | no | "" | Local DNS name to resolve to fixed_ip (optional). When set, local_dns_record_enabled=true is also sent. |
controller | string | no | ”default” | Name of the UniFi controller to target. Defaults to "default". |
dry_run | boolean | no | false | Preview the change without applying it. Returns the predicted change set. |