Skip to content

create_static_dhcp_lease

Reserve a fixed IP for a client by MAC.

Side effects:

  • Adds a fixed-IP entry on the user object so mac always receives ip from the controller’s DHCP server. The next DHCP renewal for that client picks up the reservation.
  • The IP must fall inside the network’s subnet or the controller will reject the request.
  • Mutates controller state. Use dry_run=True to preview the change without applying.
create_static_dhcp_lease(mac="aa:bb:cc:00:00:01", ip="10.50.0.10", network_id="65f...", name="cameras-nvr")
ParameterTypeRequiredDefaultDescription
macstringyesClient MAC address (e.g. "aa:bb:cc:00:00:01").
ipstringyesIPv4 address to reserve.
network_idstringyes_id of the network/VLAN this client lives on.
namestringno""Friendly display name (optional).
hostnamestringno""DHCP hostname (optional).
controllerstringno”default”Name of the UniFi controller to target. Defaults to "default".
dry_runbooleannofalsePreview the change without applying it. Returns the predicted change set.