# SECTION 6: Packet Filtering (last-match except quick)
# SECTION 6.1: General configuration rules for all networks and self
pass quick on lo0 from self to self # must be before antispoof -- see pf.conf(5)
antispoof log quick for $all_ifs
pass out quick inet proto icmp from any to any icmp-type echoreq keep state
# SECTION 6.2: Specific policy rules follow
# SECTION 6.2.1: Traffic for self
# must white list "in" traffic to self as well
pass in quick from any to self port ssh keep state
pass out quick from self to any keep state
# SECTION 6.2.2: Traffic for External
pass out quick on $external_if inet proto tcp from any to any flags S/SARF modulate state
pass out quick on $external_if inet proto udp from any to any keep state
# SECTION 6.2.3: Traffic for DMZ
# Primary server on $my_server
pass out quick on $dmz_if inet proto tcp from <trusted_ips> to $my_server flags S/SARF modulate state
pass out quick on $dmz_if inet proto tcp from any to $my_server port 22 flags S/SARF modulate state # ssh
pass out quick on $dmz_if inet proto tcp from any to $my_server port 25 flags S/SARF modulate state # smtp
pass out quick on $dmz_if inet proto udp from any to $my_server port 53 keep state
pass out quick on $dmz_if inet proto tcp from any to $my_server port 53 flags S/SARF modulate state # domain
pass out quick on $dmz_if inet proto tcp from any to $my_server port 80 flags S/SARF modulate state # http
pass out quick on $dmz_if inet proto tcp from any to $my_server port 113 flags S/SARF modulate state # ident
pass out quick on $dmz_if inet proto tcp from any to $my_server port 443 flags S/SARF modulate state # https
pass out quick on $dmz_if inet proto tcp from any to $my_server port 993 flags S/SARF modulate state # imaps
pass out quick on $dmz_if inet proto tcp from any to $my_server port 995 flags S/SARF modulate state # pop3s
block out quick on $dmz_if inet from any to $my_server
# All others (block unless passed above)
block out quick on $dmz_if inet from any to any
# SECTION 6.2.4: Traffic for Private
block out quick on $private_if inet from any to any
# SECTION 6.2.5: Traffic for Wireless
# The wireless trusts everything except external traffic
pass out quick on $wireless_if inet proto tcp from 10.0.0.0/8 to any flags S/SARF modulate state
pass out quick on $wireless_if inet proto udp from 10.0.0.0/8 to any keep state
block out quick on $wireless_if inet from any to any
# SECTION 6.3: More generic rules
# XXX: Why is this? Without these rules, all "pass out keep state" rules seem to break. It's more efficient to use the state table anyway, but why is this?
pass in log quick proto tcp from any to !<self> all flags S/SARF keep state
pass in log quick proto udp from any to !<self> all keep state
pass in log quick proto icmp all keep state
#pass in log quick all # XXX: I'd expect this to work just as well as the rules above
# If it hasn't been passed yet, block
block log quick all