Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Jun 2021 20:21:49 +0000
From:      bugzilla-noreply@freebsd.org
To:        pf@FreeBSD.org
Subject:   [Bug 256410] pf: Add pf_default_rules option
Message-ID:  <bug-256410-16861-AS2ONbASf7@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-256410-16861@https.bugs.freebsd.org/bugzilla/>
References:  <bug-256410-16861@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D256410

--- Comment #12 from Thomas Steen Rasmussen / Tykling <thomas@gibfest.dk> -=
--
Proposed updated commit message:=20
-----------------------------------------------------------------------
pf: Support loading default pf ruleset in case of invalid pf.conf using
pf_default_rules_enable, pf_default_rules and pf_default_rules_file.

When no pf rules are loaded pf will pass/allow all traffic, if the kernel is
compiled without PF_DEFAULT_TO_DROP, which is the case in GENERIC.

This commit introduces a "pf default rules" concept to minimise the impact =
if a
typo in pf.conf makes loading the primary firewall ruleset impossible on bo=
ot
or pf restart.

The new code checks the exit code of the $pf_program (pfctl) command when
loading pf.conf inside pf_start() in /etc/rc.d/pf.

After this commit, if the exit code is 1 and pf_default_rules_enable is YES,
then the default rules are loaded. If the file $pf_default_rules_file exists
the rules in it are loaded, otherwise the rules defined in $pf_default_rules
are loaded instead. $pf_default_rules defaults to a single rule: "block drop
log all", $pf_default_rules_file defaults to the path "/etc/pf-default.conf=
".

This commit also introduces new warn() calls when /etc/rc.d/pf fails to load
the pf ruleset in pf_start().

pf_default_rules can include multiple rules, for example to permit traffic =
on a
management interface. Seperate multiple rules with \n:

$ sudo sysrc pf_default_rules
pf_default_rules: block drop log all\npass quick on em0
$

The $pf_default_rules, $pf_default_rules_file and $pf_default_rules_enable
variables are defined in /etc/defaults/rc.conf with the following lines,
preserving the existing functionality (apart from the new log messages):

pf_default_rules_enable=3D"NO"    # fallback to $pf_default_rules if loading
ruleset fails
pf_default_rules=3D"block drop log all"   # block and drop everything if lo=
ading
pf ruleset fails
pf_default_rules_file=3D"/etc/pf-default.conf"    # use this file if it exi=
sts
and loading the primary fails

PR:                     256410
Reported by:            Thomas Steen Rasmussen
Reviewed by:            kp@
Sponsored by:           semaphor.dk
-----------------------------------------------------------------------

:)

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-256410-16861-AS2ONbASf7>