Re: pf firewall config file help needed please
- From: Greg Hennessy <me@xxxxxxxxxxx>
- Date: Thu, 25 May 2006 17:02:17 +0100
On Thu, 25 May 2006 14:11:57 GMT, Mike Scott
<usenet.10@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I've been trying out pf for the first time, and simply /cannot/ get this
right.
The (non-ideal) situation is a fbsd (6.1) m/c acting as wan
gateway/router and mail server for two lan segments. The goal is to
prevent all clients on the lans from accessing smtp, pop and imap ports
except on the gateway box, which will handle all mail for them. The
rule setup I have is (leaving out the obvious macros and other clutter)
...
nat on $IF_WAN from $IF_LAN_WIRED:network to any -> ($IF_WAN)
nat on $IF_WAN from $IF_LAN_WLESS:network to any -> ($IF_WAN)
I try to avoid the use of 'any' in rules. It's not good practice.
Create a table of valid source addresses and change the nat rule to
something like
nat on $IF_WAN from <ValidSource> to !<ValidSource> -> ($IF_WAN)
only use the () notation if IF_WAN has a dynamic address.
...
Your 1st packet filtering rule should always be
block log all
It's easier to open holes in a default block policy than to close holes in
a default open one.
I would also set the following options in the appropriate part of pf.conf
set skip on lo0
and
set block-policy return
so your internal applications are politely told to go forth and multiply.
block in log quick on $IF_LAN_WIRED proto tcp from any to any port
{smtp, pop3, imap}
block in log quick on $IF_LAN_WLESS proto tcp from any to any port
{smtp, pop3, imap}
These become unnecessary with a default block policy.
pass out log quick on $IF_WAN proto tcp from ($IF_WAN) to any port
{smtp, pop3, imap} flags S/SA modulate state
...
This doesn't have the desired effect though - requests always match the
'pass' rule and the block rules never match.
Assuming you're allowing access to those services hosted on the gateway
box, the rule should be something along the lines of...
pass in log quick on {$Lan1, $Lan2} $TCP from <ValidSource> to
<TableofValidDests> port $ValidServices $KSF
where the macros $TCP and $KSF are defined as....
TCP="inet proto tcp"
KSF="keep state flags S/A"
modulating state to connect to services on your own network is a bit
pointless.
This was never that hard with ipf; I assume I'm missing something
glaringly obvious here - can anyone put me straight please?
Having travelled that journey with the release of OpenBSD 3.3, you're not
in kansas anymore :-) with pf.
Direction is everthing with pf, when doing nat or rdr, you have to code
explicit ingress and egress rules on ingress and egress interfaces if you
want logging.
Once you get used to it, a pf policy will be about half the size of the
equivalent ipf one.
greg
--
Every Villian Is Lemons
.
- Follow-Ups:
- Re: pf firewall config file help needed please
- From: Mike Scott
- Re: pf firewall config file help needed please
- From: dfeustel
- Re: pf firewall config file help needed please
- References:
- pf firewall config file help needed please
- From: Mike Scott
- pf firewall config file help needed please
- Prev by Date: Re: HyperThreading: Only cpu0 is used...
- Next by Date: Re: HyperThreading: Only cpu0 is used...
- Previous by thread: pf firewall config file help needed please
- Next by thread: Re: pf firewall config file help needed please
- Index(es):
Relevant Pages
|