Zones
The zone-based firewall groups networks into zones, and policies apply between zones. Custom zones are FirewallZone resources; the built-in ones are constants.
Create a zone
Section titled “Create a zone”import * as UnifiNetwork from "@alchemy-unifi/network";import * as Effect from "effect/Effect";
export const zones = Effect.gen(function* () { const lab = yield* UnifiNetwork.FirewallZone("lab-zone", { name: "Lab" }); return { lab };});Put a network in it
Section titled “Put a network in it”Set the zone on the network. The zone doesn’t list its networks, so the two resources never disagree.
import * as UnifiNetwork from "@alchemy-unifi/network";import * as Effect from "effect/Effect";
export const zones = Effect.gen(function* () { const lab = yield* UnifiNetwork.FirewallZone("lab-zone", { name: "Lab" }); yield* UnifiNetwork.Network("lab", { management: "GATEWAY", name: "Lab", vlanId: 50, enabled: true, cellularBackupEnabled: false, internetAccessEnabled: true, isolationEnabled: false, zone: lab, ipv4Configuration: { autoScaleEnabled: false, hostIpAddress: "192.168.50.1", prefixLength: 24 }, });});Use a built-in zone
Section titled “Use a built-in zone”FirewallZone.INTERNAL, EXTERNAL, GATEWAY, VPN, HOTSPOT and DMZ go anywhere a zone does. Deleting a custom zone moves its networks to Internal.