Articles

One line in pf.conf

JailOps needs a single anchor line in the host's pf.conf and takes care of the rest of the firewall for jails itself. Where to put the line, the two options it needs, and what to leave alone.

The line

One anchor, once.

The host's /etc/pf.conf is yours. JailOps asks for one line in it and never edits the rest:

/etc/pf.conf
# your own options and scrub, then
anchor "jailops/*"
# your own filter rules

jailops-setup adds it for you and says so. By hand, it is the one line above, loaded with pfctl -nf /etc/pf.conf && pfctl -f /etc/pf.conf.

What lives below it

A tree of anchors.

Under jailops/ there is one anchor for each network (the address translation), one for each project (the rules every jail of the project must obey) and one for each jail (its own policies). They are loaded and replaced as a whole, checked before they are loaded, and read back afterwards. Your own rules are never touched, and a jail's anchor disappears with the jail.

You never write a rule for a jail in pf.conf: you write a policy for it with JailOps, and ask the firewall what a connection would do before you trust it.

Two options

Both at the top of the file.

/etc/pf.conf
# a jail's traffic crosses the host twice; judge it on both links
set state-policy if-bound
# normalise packets
scrub in all fragment reassemble
  • set state-policy if-bound makes the firewall look at a connection on every link it crosses, so the rules of the jail it is going to see it too. jailops doctor fails when it is missing and jails exist.
  • scrub is yours because the right value depends on your uplink. jailops doctor warns when the loaded rules have none.

Reloading safely

Do not cut your own ssh session.

Check the file first and load it with pfctl -f, which keeps the connections that are open. Do not use service pf restart or flush the states on a machine you are logged into over ssh: it drops your session.

A quick pass rule that comes before the anchor line passes its traffic for good, so the jail's policies never see it. Put the anchor line before broad quick rules; jailops doctor warns about the ones that are in the way.

More articles

Try it on one server.

Try the console from the screenshots, install on a clean FreeBSD 15.1 machine, or add JailOps to a host you already run.