create_firewall_policy
Creates a new firewall policy on a UniFi site, defining source and destination zones with optional traffic filters for precise traffic control.
Instructions
Create a new firewall policy on a site.
host: console name, ID, or composite ID (MAC:numericId format). site: site name or ID. policy: required fields (all validated locally — a missing field raises ValueError naming it — and all verified against the live controller):
name (str)
enabled (bool)
action: {'type': 'ALLOW'|'DENY'|'REJECT', 'allowReturnTraffic': bool}
source: {'zoneId': str}
destination: {'zoneId': str}
ipProtocolScope: {'ipVersion': 'IPV4'|'IPV6'|'BOTH'}
loggingEnabled (bool) Note: there is NO 'index' field; use set_firewall_policy_ordering to manage rule order. Get zone IDs from list_firewall_zones_proxy. trafficFilter (optional; may appear on source and/or destination) narrows the match beyond the zone pair. Set trafficFilter.type plus the ONE matching nested object:
IP_ADDRESS -> ipAddressFilter.items[] (IP addresses / CIDRs)
NETWORK -> networkFilter.networkIds[] (network UUIDs)
PORT -> portFilter.items[] (ports / port ranges)
MAC_ADDRESS -> macAddressFilter.macAddresses[] (client MAC addresses) The controller may also support further types (e.g. region/identity-based); list_firewall_policies only reveals the types already in use on a site, so an unlisted type is not evidence it is unsupported. PORT-FILTER PLACEMENT FOOTGUN: a portFilter under source.trafficFilter filters SOURCE ports, which for outbound flows are ephemeral (random high ports) -> the rule silently matches nothing. A destination-port rule MUST use destination.trafficFilter with type PORT, never a source portFilter. (create/update_firewall_policy log a runtime warning when a source PORT filter is combined with an any-destination ALLOW.)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| host | Yes | ||
| site | Yes | ||
| policy | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||