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")
Parameter Type Required Default Description
mac string yes Client MAC address (e.g. "aa:bb:cc:00:00:01").
ip string yes IPv4 address to reserve.
network_id string yes _id of the network/VLAN this client lives on.
name string no “” Friendly display name (optional).
hostname string no “” DHCP hostname (optional).
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.