Dev.to Security ๐Ÿ” Cybersecurity ๐Ÿ‘ 0 ๐Ÿ“– 17 min read

A Default-Deny NAT Firewall on OpenBSD pf, Managed with Terraform

pf is the best firewall I have worked with: one readable file, atomic reloads, NAT and queueing in the same language as the filter rules. What it lacks is an API. Every tool that wants to change a pf firewall ends up tem

pf is the best firewall I have worked with: one readable file, atomic reloads, NAT and queueing in the same language as the filter rules. What it lacks is an API. Every tool that wants to change a pf firewall ends up templating pf.conf, copying it over SSH and hoping pfctl -f likes it.

I wrote pfapid to fix that: a small REST API for pf that runs on the firewall itself, with a Terraform provider on top. This post builds a complete NAT firewall with it: a default-deny base, outbound NAT, a port forward to a DMZ web server, a blocklist and QoS on the uplink.

What pfapid manages, and what it doesn't

pfapid splits the firewall into two owners:

Part Owned by Lives in
Defaults, block all, antispoof, management access You, by hand or config management /etc/pf.conf
Filter and NAT rules, per unit of work Terraform via pfapid Anchors api/<name>
Contents of tables such as <blocklist> Terraform via pfapid Tables declared in pf.conf
HFSC queues and the rules that classify into them Terraform via pfapid The api-qos anchor and a queue include

The base ruleset is the part you can't afford to get wrong, so the API can't touch it. Whatever Terraform does, the block and management rules in pf.conf come first.

Why not just template pf.conf?

  • terraform plan asks pf. The provider sends the rules to the firewall, where pfapid runs pfctl -n on them. A rule pf would refuse fails the plan, not the apply, and the plan shows the exact lines pf will load.
  • Commit-confirm. Every change is loaded, then rolled back by the firewall itself unless the provider confirms it within confirm_timeout. If an apply cuts off the path between Terraform and the firewall, the change undoes itself.
  • Drift detection. Someone runs pfctl by hand at 3 a.m.? The next plan warns, and the next apply puts the rules back.
  • Small blast radius. pfapid runs privilege-separated: the HTTPS side runs as _pfapid under pledge("stdio inet"), and only a tiny root process runs pfctl. Clients authenticate with mTLS and are scoped to anchors and tables. There is no raw pf.conf passthrough: rules are typed objects, rendered and checked before pf sees them.

When to use it

  • Use it when firewall rules belong to the same change as the thing they protect: a new service, a Kubernetes cluster, a customer network. They get reviewed and planned together.
  • Skip it for a firewall nobody changes, or one with a single admin who is happy with vi /etc/pf.conf. A text file with good comments is hard to beat.

The network

                 internet
                     |
               wan  vio0   203.0.113.2/24, 2001:db8:1::2/64   (egress)
          +----------------------+
 mgmt     |                      |  lan  vio1   10.0.10.1/24, 2001:db8:10::1/64
 vio3 ----+   OpenBSD + pfapid   +-------------  office clients, VoIP phones
 192.168. |                      |
 100.1/24 |                      |  dmz  vio2   10.0.20.1/24, 2001:db8:20::1/64
          +----------------------+-------------  web server 10.0.20.10, 2001:db8:20::10

The rules use interface groups (wan, lan, dmz, mgmt), never device names. When you replace a NIC or move a network to a VLAN, you add the new interface to the group and no rule changes:

# /etc/hostname.vio0 and friends: one "group" line each
echo 'group wan' >> /etc/hostname.vio0
ifconfig vio0 group wan

What we want:

From To What
lan internet Everything, IPv4 behind NAT, IPv6 routed
dmz internet DNS, NTP and HTTPS only (updates)
internet, lan web server TCP 80 and 443; IPv4 through a port forward on the wan address
<blocklist> anything Nothing
mgmt network firewall SSH and the pfapid API
Everything else Dropped and logged

Step 1: Install pfapid

pfapid ships as signed release archives for OpenBSD amd64 and arm64. Check the signature before you install it:

# on a workstation with gpg
v=$(curl -s https://api.github.com/repos/pderuiter/pfapid/releases/latest |
    sed -n 's/.*"tag_name": *"v\([^"]*\)".*/\1/p')
base=https://github.com/pderuiter/pfapid/releases/download/v$v
curl -sSLO $base/pfapid_${v}_openbsd_amd64.tar.gz
curl -sSLO $base/pfapid_${v}_SHA256SUMS -O $base/pfapid_${v}_SHA256SUMS.sig
curl -sSL https://raw.githubusercontent.com/pderuiter/pfapid/main/scripts/release-signing-key.asc | gpg --import
gpg --verify pfapid_${v}_SHA256SUMS.sig pfapid_${v}_SHA256SUMS
shasum -a 256 --ignore-missing -c pfapid_${v}_SHA256SUMS

gpg must report a good signature from key 10A2F1058821D55C61E45C7EE97C02FEE2F51B23. Then on the firewall, as root:

tar xzf pfapid_*_openbsd_amd64.tar.gz
useradd -s /sbin/nologin -d /var/empty -L daemon -c "pfapid network process" _pfapid
install -o root -g wheel -m 0555 pfapid /usr/local/sbin/pfapid
install -o root -g wheel -m 0555 deploy/rc.d/pfapid /etc/rc.d/pfapid
install -d -o root -g wheel -m 0700 /etc/pfapid /var/db/pfapid
install -d -o root -g wheel -m 0755 /etc/pf.anchors/api
for f in api.conf api-queues.conf api-qos.conf; do
    [ -f /etc/pf.anchors/$f ] || install -o root -g wheel -m 0600 /dev/null /etc/pf.anchors/$f
done

The three empty files must exist before pf.conf includes them; pfapid fills them later.

pfapid has a built-in CA, so you don't need a PKI to get started. Create the CA and the server certificate, then a client certificate for Terraform:

pfapid pki init -dns fw.example.net -ip 192.168.100.1
pfapid pki issue -name tf-firewall -out /root/tf-firewall   # writes tf-firewall.crt and .key

Copy /root/tf-firewall.crt, /root/tf-firewall.key and the CA certificate (/etc/pfapid/pki/ca.crt) to the machine that runs Terraform, and delete the key from the firewall. A company CA, Vault or SPIFFE IDs work too; see CERTIFICATES.md.

Step 2: The default-deny base ruleset

This file is yours. It holds everything that must hold no matter what the API does:

# /etc/pf.conf: default-deny base ruleset for a pfapid-managed NAT firewall.
#
#   wan   vio0 (egress)  203.0.113.2/24, 2001:db8:1::2/64
#   lan   vio1           10.0.10.1/24,   2001:db8:10::1/64
#   dmz   vio2           10.0.20.1/24,   2001:db8:20::1/64
#   mgmt  vio3           192.168.100.1/24
admin_nets = "192.168.100.0/24"

set skip on lo
set block-policy drop
set loginterface egress

# Tables whose contents pfapid manages: declared empty, with persist,
# so a reload of this file keeps what Terraform put in them.
table <dmz_web> persist
table <blocklist> persist

# Default deny: nothing passes, in or out, unless a rule says so.
block log all

# Packets on lan or dmz must come from that network.
antispoof quick for { lan dmz }

# Management first, and quick: nothing in the API anchors can take it away.
pass in quick on mgmt proto tcp from $admin_nets to (mgmt) port { 22 8443 }

# IPv6 breaks without these: neighbour discovery and path MTU discovery.
pass quick inet6 proto icmp6 icmp6-type { unreach toobig timex paramprob \
    routersol routeradv neighbrsol neighbradv }

# The firewall offers no services to the inside networks.
block in quick on { lan dmz } to self

# The firewall's own traffic (DNS, NTP, syspatch).
pass out quick on egress from (egress)

# pfapid: QoS classification, then the API anchors.
include "/etc/pf.anchors/api-queues.conf"
anchor "api-qos"
load anchor "api-qos" from "/etc/pf.anchors/api-qos.conf"
anchor "api/*"
include "/etc/pf.anchors/api.conf"

Block by block:

  • block log all is the default-deny. pf uses the last matching rule, so every pass further down (and in the anchors) can open a hole, but nothing is open by default. It applies in both directions, which matters for forwarded traffic later.
  • antispoof drops packets on lan or dmz with a source address that doesn't belong there.
  • Management comes before the anchors and is quick: pf stops evaluating on the first quick match, so no anchor can override it. pfapid also refuses the mgmt group in any API rule.
  • ICMPv6 for neighbour discovery and path MTU. Without it, IPv6 breaks in slow, confusing ways. pfapid won't let the API block these either.
  • block in quick on { lan dmz } to self keeps the inside networks away from the firewall's own addresses, including the API. If the firewall runs DNS or DHCP for the LAN, add a pass in quick for exactly that above this line.
  • The pfapid hooks: the queue include and the api-qos anchor come before anchor "api/*", so traffic is classified before an API rule passes it. api.conf is generated by pfapid with one load anchor line per anchor, so the anchors survive a reboot.

Check the file, then load it with a way back. I locked myself out of my lab firewall while writing this post: my workstation wasn't in admin_nets. A background job that restores the old file after 90 seconds unless I cancel it brought the firewall back on its own:

pfctl -nf /etc/pf.conf.new            # syntax check, loads nothing
cp -p /etc/pf.conf /etc/pf.conf.good
install -m 0600 /etc/pf.conf.new /etc/pf.conf
rm -f /tmp/pf-keep
( sleep 90; [ -f /tmp/pf-keep ] || { cp -p /etc/pf.conf.good /etc/pf.conf; pfctl -f /etc/pf.conf; } ) &
pfctl -f /etc/pf.conf
# from a NEW ssh session: it works, keep it
touch /tmp/pf-keep

The test has to be a new connection: existing SSH sessions keep their state and survive a rule change that would lock out the next login.

Step 3: Tell pfapid what it may touch

/etc/pfapid.json (mode 0600, root) lists the interface groups, tables and queue devices the API may use, and which client may do what:

{
  "listen": "192.168.100.1:8443",
  "tls": {
    "cert": "/etc/pfapid/pki/server.crt",
    "key": "/etc/pfapid/pki/server.key",
    "client_cas": { "pfapid": "/etc/pfapid/pki/ca.crt" }
  },
  "confirm_timeout": "60s",
  "policy": {
    "interfaces": ["wan", "lan", "dmz"],
    "tables": ["dmz_web", "blocklist"],
    "queue_interfaces": ["vio0"],
    "internal_nets": ["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "fd00::/8"]
  },
  "clients": [
    { "name": "tf-firewall", "ca": "pfapid", "anchors": ["*"], "tables": ["dmz_web", "blocklist"], "qos": true }
  ]
}
  • interfaces are the groups rules may name. mgmt is refused here and in every rule.
  • tables must also be declared in pf.conf, empty and with persist.
  • queue_interfaces are physical devices: pf can't hang a queue on a group.
  • internal_nets: pfapid refuses NAT between two of these networks, a common mistake that hides where traffic really comes from. NAT from the LAN to the internet is fine.
  • clients: tf-firewall (the certificate's CN) may manage every anchor, these two tables and QoS. A team that only owns its own service would get "anchors": ["webshop-*"] and nothing else.

Start it:

pfapid -f /etc/pfapid.json -n       # checks the configuration and certificates
rcctl enable pfapid
rcctl start pfapid

Step 4: The Terraform provider

terraform {
  required_providers {
    pf = {
      source  = "pderuiter/pf"
      version = "~> 0.1"
    }
  }
}

# Endpoint and certificates come from the environment:
#   PFAPID_ENDPOINT, PFAPID_CA_CERT, PFAPID_CLIENT_CERT, PFAPID_CLIENT_KEY
provider "pf" {}
export PFAPID_ENDPOINT=https://192.168.100.1:8443
export PFAPID_CA_CERT=$HOME/.pfapid/ca.crt
export PFAPID_CLIENT_CERT=$HOME/.pfapid/tf-firewall.crt
export PFAPID_CLIENT_KEY=$HOME/.pfapid/tf-firewall.key
terraform init

The provider is signed with the same key as the pfapid releases; terraform init checks that for you.

Step 5: Tables

Tables are lists of addresses that rules refer to as <name>. Changing a table never reloads a rule, so it's the cheap way to add a web server or block a network. A table can hold IPv4 and IPv6 entries side by side:

# The web servers in the DMZ. pf rules reference <dmz_web>; changing the
# entries never reloads a rule.
resource "pf_table" "dmz_web" {
  name    = "dmz_web"
  entries = ["10.0.20.10/32", "2001:db8:20::10/128"]
}

# Sources we never want to hear from.
resource "pf_table" "blocklist" {
  name    = "blocklist"
  entries = ["198.51.100.0/24", "2001:db8:bad::/48"]
}

Step 6: Filtering and outbound NAT

Each pf_anchor is one anchor, api/<name>, and its rules are loaded as a whole: pf is order-sensitive, so a ruleset is one atomic unit, never rule by rule. Split anchors along ownership: whoever owns the DMZ web server owns dmz-web.

# Anchor api/egress: the inside networks out to the internet.
locals {
  lan4 = "10.0.10.0/24"
  lan6 = "2001:db8:10::/64"
  dmz4 = "10.0.20.0/24"
}

resource "pf_anchor" "egress" {
  name = "egress"
  rules = [
    # LAN clients may start anything; the out rule below decides where.
    {
      action    = "pass"
      direction = "in"
      interface = "lan"
      family    = "inet"
      from      = { prefixes = [local.lan4] }
      label     = "lan-in"
    },
    {
      action    = "pass"
      direction = "in"
      interface = "lan"
      family    = "inet6"
      from      = { prefixes = [local.lan6] }
      label     = "lan-in"
    },
    # DMZ servers only get DNS, NTP and HTTPS (updates) out.
    {
      action    = "pass"
      direction = "in"
      interface = "dmz"
      family    = "inet"
      protocol  = "udp"
      from      = { prefixes = [local.dmz4] }
      to        = { ports = [{ from = 53 }, { from = 123 }] }
      label     = "dmz-out"
    },
    {
      action    = "pass"
      direction = "in"
      interface = "dmz"
      family    = "inet"
      protocol  = "tcp"
      from      = { prefixes = [local.dmz4] }
      to        = { ports = [{ from = 443 }] }
      label     = "dmz-out"
    },
    # Out to the internet: IPv4 is translated to the wan address...
    {
      action    = "pass"
      direction = "out"
      interface = "wan"
      family    = "inet"
      from      = { prefixes = [local.lan4, local.dmz4] }
      nat       = { kind = "nat-to", interface = "wan" }
      label     = "nat-out"
    },
    # ...IPv6 is routed as is.
    {
      action    = "pass"
      direction = "out"
      interface = "wan"
      family    = "inet6"
      from      = { prefixes = [local.lan6] }
      label     = "v6-out"
    },
  ]
}

Things worth knowing:

  • Every rule names one family. pfapid refuses a rule that mixes IPv4 and IPv6: pfctl would silently turn it into two rules, and what's loaded would no longer match what you wrote. Tables are the way to cover both.
  • Forwarded traffic is filtered twice. A packet from the LAN to the internet goes in on lan and out on wan, and with block all both directions need a pass. The lan-in rule allows everything in, but the out rules decide where it can go: only out on wan. A LAN client trying to reach the DMZ gets in on lan and is then dropped going out on dmz, unless a rule there allows it (the next anchor does, for the web ports).
  • NAT sits on the out rule. nat = { kind = "nat-to", interface = "wan" } renders as nat-to (wan:0): the first address of wan, re-read when it changes, so this works with DHCP on the uplink too.
  • IPv6 isn't translated. The LAN has a routed prefix, so the IPv6 rule just passes it.

Step 7: Port forwarding to the DMZ

# Anchor api/dmz-web: publish the web server.
locals {
  web_ports = [{ from = 80 }, { from = 443 }]
}

resource "pf_anchor" "dmz_web" {
  name = "dmz-web"
  rules = [
    # IPv4: redirect the wan address to the server (port forward).
    {
      action    = "pass"
      direction = "in"
      interface = "wan"
      family    = "inet"
      protocol  = "tcp"
      to        = { interface = "wan", ports = local.web_ports }
      nat       = { kind = "rdr-to", address = "10.0.20.10/32" }
      label     = "web-rdr"
    },
    # IPv6: the server has a public address, so just let it through.
    {
      action    = "pass"
      direction = "in"
      interface = "wan"
      family    = "inet6"
      protocol  = "tcp"
      to        = { table = pf_table.dmz_web.name, ports = local.web_ports }
      label     = "web-in"
    },
    # Forwarded traffic is filtered twice: in on wan (or lan), and out on
    # dmz. Without these the redirect above goes nowhere.
    {
      action    = "pass"
      direction = "out"
      interface = "dmz"
      family    = "inet"
      protocol  = "tcp"
      to        = { table = pf_table.dmz_web.name, ports = local.web_ports }
      label     = "web-out"
    },
    {
      action    = "pass"
      direction = "out"
      interface = "dmz"
      family    = "inet6"
      protocol  = "tcp"
      to        = { table = pf_table.dmz_web.name, ports = local.web_ports }
      label     = "web-out"
    },
  ]
}

The rdr-to rule changes the destination of connections to the wan address on port 80 or 443 to 10.0.20.10. The same pass rule creates the state, so there is no separate redirect-then-filter step to keep in sync. The redirected packet then leaves on dmz, and the web-out rules let it through: forget those and the port forward silently goes nowhere. Those same rules let LAN clients reach the web server directly.

For IPv6 the server has its own address, so there is nothing to translate: pass it in on wan and out on dmz.

Step 8: The blocklist

# Anchor api/blocklist. A quick block ends evaluation, so these win over
# any pass rule in another anchor.
resource "pf_anchor" "blocklist" {
  name = "blocklist"
  rules = [
    for family in ["inet", "inet6"] : {
      action    = "block"
      direction = "in"
      quick     = true
      log       = true
      interface = "wan"
      family    = family
      from      = { table = pf_table.blocklist.name }
      label     = "blocklist"
    }
  ]
}

quick ends evaluation on a match, so these blocks win over every pass rule in every anchor, whatever order pf evaluates the anchors in. log sends the dropped packets to pflog0.

Feed the table from wherever your threat data lives: a variable, a file, or a data source. Updating it is a table replace on the firewall, not a ruleset reload.

Step 9: QoS on the uplink

An upload that fills the uplink makes everything else on the line feel slow: VoIP breaks up, SSH lags, and downloads crawl because their ACKs queue behind the upload. HFSC queues fix that by sharing the uplink by rule:

# QoS for a 100 Mbit/s uplink. Queues hang off a physical device (not a
# group), so the root names the device behind wan.
variable "uplink" {
  type    = string
  default = "vio0"
}

resource "pf_qos" "uplink" {
  queues = [
    { name = "uplink", interface = var.uplink, bandwidth = "100M", max = "100M" },
    { name = "std", parent = "uplink", bandwidth = "60M", default = true, flows = 1024 },
    { name = "voip", parent = "uplink", bandwidth = "10M", min = "10M" },
    { name = "interactive", parent = "uplink", bandwidth = "10M", min = "5M" },
    { name = "bulk", parent = "uplink", bandwidth = "20M", max = "40M" },
  ]

  rules = [
    # Classify where the state is created: in on lan or dmz. pf queues the
    # packets of that connection when they leave wan. Match rules run in
    # order and the last one that matches decides, so general rules first.
    #
    # All TCP from the LAN: data in std, bare ACKs in interactive. A full
    # uplink then can't hold back the ACKs that keep downloads going.
    {
      direction = "in"
      interface = "lan"
      family    = "inet"
      protocol  = "tcp"
      queue     = { name = "std", priority = "interactive" }
      label     = "qos-acks"
    },
    {
      direction = "in"
      interface = "lan"
      family    = "inet"
      protocol  = "tcp"
      to        = { ports = [{ from = 22 }] }
      queue     = { name = "interactive" }
      label     = "qos-ssh"
    },
    {
      direction = "in"
      interface = "lan"
      family    = "inet"
      protocol  = "udp"
      to        = { ports = [{ from = 5060, to = 5061 }, { from = 10000, to = 20000 }] }
      queue     = { name = "voip" }
      prio      = { normal = 6 }
      label     = "qos-voip"
    },
    # Offsite backups from the DMZ: capped, and last in line.
    {
      direction = "in"
      interface = "dmz"
      family    = "inet"
      protocol  = "tcp"
      to        = { ports = [{ from = 873 }] }
      queue     = { name = "bulk" }
      prio      = { normal = 1 }
      label     = "qos-backup"
    },
  ]
}

How it fits together:

  • Queues shape what leaves an interface. These queues sit on the wan device, so they shape uploads. To shape downloads, put a second tree on the LAN device.
  • The parent caps the total at 100M with max; set it slightly below your real upload speed so the queue builds here, where pf controls it, not in the modem. Children share it by bandwidth, min is a guarantee, max a hard cap. pfapid refuses children that add up to more than their parent; pfctl would accept that.
  • std is the default and an FQ-CoDel queue (flows = 1024): it keeps one heavy flow from adding latency to all the others.
  • Classify where the connection starts. The rules match in on lan (or dmz); pf stores the queue in the connection's state and uses it when its packets leave wan. Keep that habit: a match out on wan rule never sees the replies to connections opened from the internet, such as the web server's responses.
  • Two queues in one rule: queue = { name = "std", priority = "interactive" } puts data in std and bare TCP ACKs in interactive. That one line is what keeps downloads fast during a big upload.
  • prio is pf's simple 0โ€“7 priority on interfaces without HFSC queues, such as lan here: VoIP towards the phones goes first too.
  • QoS rules can only classify. They're match rules with no pass, block or NAT, so QoS can never change what the firewall lets through. That's also why it's a separate permission ("qos": true).

Step 10: Plan and apply

terraform plan

Each anchor's plan includes pf_rules: the rules exactly as pf will load them, as pfctl -nv on the firewall printed them. This is what the plan showed in my lab (the QoS root was on vio1 there):

pf_anchor.dmz_web:
  "pass in on wan inet proto tcp from any to (wan) port = 80 flags S/SA label \"web-rdr\" rdr-to 10.0.20.10",
  "pass in on wan inet proto tcp from any to (wan) port = 443 flags S/SA label \"web-rdr\" rdr-to 10.0.20.10",
  "pass in on wan inet6 proto tcp from any to <dmz_web> port = 80 flags S/SA label \"web-in\"",
  ...
pf_anchor.egress:
  "pass out on wan inet from 10.0.10.0/24 to any flags S/SA label \"nat-out\" nat-to (wan:0) round-robin",
  "pass out on wan inet from 10.0.20.0/24 to any flags S/SA label \"nat-out\" nat-to (wan:0) round-robin",
  ...
pf_qos.uplink:
  "queue uplink on vio1 bandwidth 100M, max 100M",
  "queue std parent uplink flows 1024 bandwidth 60M default",
  ...
  "match in on lan inet proto tcp all set (queue(std, interactive)) label \"qos-acks\"",

Lists become one line per port and per prefix, and pf adds its defaults (flags S/SA, round-robin). You see that before anything changes, not after.

terraform apply
pf_table.dmz_web: Creation complete after 0s [id=dmz_web]
pf_table.blocklist: Creation complete after 0s [id=blocklist]
pf_anchor.egress: Creation complete after 0s [id=egress]
pf_qos.uplink: Creation complete after 0s [id=qos]
pf_anchor.dmz_web: Creation complete after 0s [id=dmz-web]
pf_anchor.blocklist: Creation complete after 0s [id=blocklist]

Apply complete! Resources: 6 added, 0 changed, 0 destroyed.

Each change was loaded, confirmed by the provider over the same connection, and only then written to pfapid's state. A second terraform plan reports no changes.

Step 11: Check it on the firewall

pfctl -sA                    # anchors: api, api/blocklist, api/dmz-web, api/egress, api-qos
pfctl -a api/egress -vsr     # an anchor's rules, with counters
pfctl -t blocklist -T show   # table contents
pfctl -vsq                   # queues, with packets and drops
tcpdump -n -e -ttt -i pflog0 # what the default-deny and the blocklist drop, live

The guardrails in action

Drift. I flushed an anchor by hand with pfctl -a api/dmz-web -F rules. The next plan:

Warning: pf anchor api/dmz-web differs from its committed rules

The rules loaded in pf were changed outside pfapid. The next apply loads the
configured rules again.
Expected:
  pass in on wan inet proto tcp from any to (wan) port = 80 flags S/SA label "web-rdr" rdr-to 10.0.20.10
  ...
Plan: 0 to add, 1 to change, 0 to destroy.

terraform apply loaded the rules again.

The management interface. A rule that opens RDP on mgmt fails at plan time:

Error: Rules rejected by the firewall

pfapid: 400 invalid: rule 0: invalid: interface "mgmt" is not allowed

A rule pf won't take. pfapid runs pfctl -n during the plan, so a rule pf would refuse fails terraform plan, with pf's own error message, before anything is loaded.

Limits worth knowing

  • One firewall, one provider block. For an HA pair, configure two providers (with alias) and apply the same modules to both; pfsync keeps the states in sync, not the rules.
  • self is expanded when pf.conf loads. If the firewall's addresses change, reload the base ruleset.
  • No hairpin NAT. LAN clients reach the web server on its DMZ address, not on the public one. Use split DNS.
  • Queues are bit rates, not percentages: pf doesn't support percentages in HFSC yet.

Everything in this post was planned and applied with provider v0.1.0 and pfapid v0.1.2 on an OpenBSD 7.9 lab VM, and the pf output shown is what pf loaded there. The code, the design notes and the pf behaviour pfapid relies on are on GitHub: pfapid and terraform-provider-pf. Issues and pull requests are welcome.

Originally published on A DevOps Blog.

๐Ÿ“ฐ Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.