fido
August 7th, 2002, 16:58
I thought I'd post my pf.conf rules, to see what others think of them. I'd appreciate pointers, if I'm doing something stupid.
The machine has 2 ethernet cards and acts as a NAT for a few internal machines, and has running visible ssh, web and mail services. I don't really want anything else externally visible or accessible. Except for the Unreal Tournament server I run for a few friends, of course. (I enable UT access in nat.conf, only when I want it available.)
Anyway, here's my pf.conf:
# External ethernet interface, from "ifconfig -a":
ext_if = "xl1"
# Default pf rules, made explicit:
pass in all
pass out all
# Don't filter any loopback interface traffic:
pass in quick on lo0 all
pass out quick on lo0 all
# Clean up any wierd external packets:
scrub in on $ext_if all
# Now filter stuff.
# *** TCP ***
# Stop everything inbound, then open up the ports we want seen:
block return-rst in on $ext_if proto tcp from any to any
pass in quick on $ext_if proto tcp from any to any \
port { ssh, smtp, http, pop3 } keep state
# Keep state on outgoing TCP connections:
pass out quick on $ext_if proto tcp from any to any keep state
# *** UDP ***
# Stop everything inbound. We want no externally visible UDP ports:
block return-icmp in on $ext_if proto udp from any to any
# Keep state for desired outbound UDP connections:
pass out quick on $ext_if proto udp from any to any \
port { domain, ntp } keep state
# Ok, allow UT access (enabled/disabled through nat.conf):
pass in quick on $ext_if proto udp from any to any port { 7777, 7778 }
The machine has 2 ethernet cards and acts as a NAT for a few internal machines, and has running visible ssh, web and mail services. I don't really want anything else externally visible or accessible. Except for the Unreal Tournament server I run for a few friends, of course. (I enable UT access in nat.conf, only when I want it available.)
Anyway, here's my pf.conf:
# External ethernet interface, from "ifconfig -a":
ext_if = "xl1"
# Default pf rules, made explicit:
pass in all
pass out all
# Don't filter any loopback interface traffic:
pass in quick on lo0 all
pass out quick on lo0 all
# Clean up any wierd external packets:
scrub in on $ext_if all
# Now filter stuff.
# *** TCP ***
# Stop everything inbound, then open up the ports we want seen:
block return-rst in on $ext_if proto tcp from any to any
pass in quick on $ext_if proto tcp from any to any \
port { ssh, smtp, http, pop3 } keep state
# Keep state on outgoing TCP connections:
pass out quick on $ext_if proto tcp from any to any keep state
# *** UDP ***
# Stop everything inbound. We want no externally visible UDP ports:
block return-icmp in on $ext_if proto udp from any to any
# Keep state for desired outbound UDP connections:
pass out quick on $ext_if proto udp from any to any \
port { domain, ntp } keep state
# Ok, allow UT access (enabled/disabled through nat.conf):
pass in quick on $ext_if proto udp from any to any port { 7777, 7778 }