Skip to content

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=true and pins fixed_ip on the user record.
  • If local_dns_record is supplied, also sets local_dns_record_enabled=true so 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 use create_static_dhcp_lease instead.
update_static_dhcp_lease(mac="d0:11:e5:03:f6:3a", fixed_ip="192.168.1.50", network_id="6a0...", name="cypher")
ParameterTypeRequiredDefaultDescription
macstringyesClient MAC address (e.g. "d0:11:e5:03:f6:3a").
fixed_ipstringyesIPv4 address to pin. Must be inside the network’s subnet.
network_idstringyes_id of the network/VLAN the IP belongs to.
namestringno""Friendly display name / hostname alias (optional).
local_dns_recordstringno""Local DNS name to resolve to fixed_ip (optional). When set, local_dns_record_enabled=true is also sent.
controllerstringno”default”Name of the UniFi controller to target. Defaults to "default".
dry_runbooleannofalsePreview the change without applying it. Returns the predicted change set.