firebaugh
November 20th, 2002, 13:53
I've been using OpenBSD and ipf for a few years now and this is my first setup using pf. I've put this together from a variety of resources and as the subject states I'm looking for feedback.
Here's my pf.conf.
################################
#
# macros and other options
# ################################
##############
# interfaces #
##############
ext_if="xl0"
int_if="fxp0"
loop="lo0"
###########
# subnets #
###########
royalst="192.xxx.xxx.0/24"
# private & reserved addressing taken from rfc1918, rfc3330, and arin.net whois searches
private="{ 0.0.0.0/8, 1.0.0.0/8, 2.0.0.0/8, 5.0.0.0/8, 10.0.0.0/8, 23.0.0.0/8, 27.0.0.0/8, 31.0.0.0/8,
36.0.0.0/8, 37.0.0.0/8, 39.0.0.0/8, 41.0.0.0/8, 42.0.0.0/8, 58.0.0.0/8, 59.0.0.0/8, 60.0.0.0/8,
70.0.0.0/7, 72.0.0.0/5, 82.0.0.0/7, 84.0.0.0/6, 88.0.0.0/5, 96.0.0.0/4, 112.0.0.0/5, 120.0.0.0/6,
124.0.0.0/7, 126.0.0.0/8, 127.0.0.0/8, 128.0.0.0/16, 128.66.0.0/16, 169.0.0.0/7, 169.254.0.0/16,
172.16.0.0/12, 191.255.0.0/16, 192.0.0.0/16, 192.88.99.0/24, 192.168.0.0/16, 197.0.0.0/8,
198.18.0.0/15, 201.0.0.0/8, 222.0.0.0/7, 224.0.0.0/4, 240.0.0.0/4, 255.255.255.255/32 }"
#########
# hosts #
#########
admin="68.xxx.xxx.xxx"
sentry="192.xxx.xxx.250"
websvr="192.xxx.xxx.2"
mailsvr="192.xxx.xxx.5"
extip_250="63.xxx.xxx.250"
extip_251="63.xxx.xxx.251"
extip_252="63.xxx.xxx.252"
extip_253="63.xxx.xxx.253"
extip_254="63.xxx.xxx.254"
##########
# groups #
##########
sql_users="{ 68.xxx.xxx.11, 63.xxx.xxx.0/24, 68.xxx.xxx.65, 208.xxx.xxx.65 }"
###########
# options #
###########
# set timeout tcp.established 3600
# set timeout { tcp.opening 30, tcp.closing 900 }
set logininterface xl0
set limit { states 20000, frags 20000 }
#############
# normalize #
#############
scrub in on $ext_if all fragment reassemble
scrub out on $ext_if all fragment reassemble
################################
#
# network address translation
# ################################
nat on $ext_if from $royalst to any -> $ext_if
#############
# ftp-proxy #
#############
rdr on $int_if proto tcp from any to any port 21 -> $loop port 8021
#########
# binat #
#########
# MS's fubar'd excuse for a VPN protocal requires this
binat on $ext_if proto gre from $mailsvr to any -> $extip_251
#############
# redirects #
#############
# extip_250
rdr on $ext_if proto tcp from any to $extip_250 port ssh -> $mailsvr port ssh
rdr on $ext_if proto udp from any to $extip_250 port domain -> $mailsvr port domain
rdr on $ext_if proto tcp from any to $extip_250 port http -> $websvr port http
rdr on $ext_if proto { tcp, udp } from any to $extip_250 port ms-sql-s -> $websvr port ms-sql-s
rdr on $ext_if proto { tcp, udp } from any to $extip_250 port ms-sql-m -> $websvr port ms-sql-m
rdr on $ext_if proto tcp from $admin to $extip_250 port pcanywheredata -> $websvr port pcanywheredata
rdr on $ext_if proto udp from $admin to $extip_250 port pcanywherestat -> $websvr port pcanywherestat
# extip_251
rdr on $ext_if proto tcp from any to $extip_251 port smtp -> $mailsvr port smtp
rdr on $ext_if proto tcp from any to $extip_251 port http -> $mailsvr port http
rdr on $ext_if proto tcp from any to $extip_251 port imap -> $mailsvr port imap
rdr on $ext_if proto tcp from any to $extip_251 port pptp -> $mailsvr port pptp
rdr on $ext_if proto tcp from $admin to $extip_251 port pcanywheredata -> $websvr port pcanywheredata
rdr on $ext_if proto udp from $admin to $extip_251 port pcanywherestat -> $websvr port pcanywherestat
################################
#
# packet filter
#
################################
# the implicit first two rules are
# pass in all
pass out all
block in all
# block out all
############
# loopback #
############
pass in quick on $loop all
pass out quick on $loop all
######################
# external interface #
######################
# block out on $ext_if
block in quick on $ext_if from $private to any
block out quick on $ext_if from any to $private
pass out on $ext_if inet proto tcp all modulate state
pass out on $ext_if inet proto udp all keep state
pass out on $ext_if inet proto icmp all keep state
pass in quick on $ext_if proto gre from $any to $mailsvr keep state
pass in quick on $ext_if proto tcp from $any to $mailsvr port 0 flags S/SA keep state
pass in quick on $ext_if proto tcp from $admin to $sentry port ssh flags S/SA keep state
pass in quick on $ext_if proto tcp from any to $sentry port smtp flags S/SA keep state
pass in quick on $ext_if proto udp from any to $mailsvr port domain keep state
pass in quick on $ext_if proto tcp from any to $websvr port http flags S/SA keep state
pass in quick on $ext_if proto tcp from any to $mailsvr port http flags S/SA keep state
pass in quick on $ext_if proto tcp from any to $sentry port imap flags S/SA keep state
pass in quick on $ext_if proto tcp from $any to $mailsvr port pptp flags S/SA keep state
pass in log quick on $ext_if proto tcp from $sql_users to $websvr port ms-sql-s flags S/SA keep state
pass in log quick on $ext_if proto udp from $sql_users to $websvr port ms-sql-s keep state
pass in log quick on $ext_if proto tcp from $sql_users to $websvr port ms-sql-m flags S/SA keep state
pass in log quick on $ext_if proto udp from $sql_users to $websvr port ms-sql-m keep state
######################
# internal interface #
######################
pass in quick on $int_if proto { tcp, udp, icmp } from $royalst to any keep state
Here's my pf.conf.
################################
#
# macros and other options
# ################################
##############
# interfaces #
##############
ext_if="xl0"
int_if="fxp0"
loop="lo0"
###########
# subnets #
###########
royalst="192.xxx.xxx.0/24"
# private & reserved addressing taken from rfc1918, rfc3330, and arin.net whois searches
private="{ 0.0.0.0/8, 1.0.0.0/8, 2.0.0.0/8, 5.0.0.0/8, 10.0.0.0/8, 23.0.0.0/8, 27.0.0.0/8, 31.0.0.0/8,
36.0.0.0/8, 37.0.0.0/8, 39.0.0.0/8, 41.0.0.0/8, 42.0.0.0/8, 58.0.0.0/8, 59.0.0.0/8, 60.0.0.0/8,
70.0.0.0/7, 72.0.0.0/5, 82.0.0.0/7, 84.0.0.0/6, 88.0.0.0/5, 96.0.0.0/4, 112.0.0.0/5, 120.0.0.0/6,
124.0.0.0/7, 126.0.0.0/8, 127.0.0.0/8, 128.0.0.0/16, 128.66.0.0/16, 169.0.0.0/7, 169.254.0.0/16,
172.16.0.0/12, 191.255.0.0/16, 192.0.0.0/16, 192.88.99.0/24, 192.168.0.0/16, 197.0.0.0/8,
198.18.0.0/15, 201.0.0.0/8, 222.0.0.0/7, 224.0.0.0/4, 240.0.0.0/4, 255.255.255.255/32 }"
#########
# hosts #
#########
admin="68.xxx.xxx.xxx"
sentry="192.xxx.xxx.250"
websvr="192.xxx.xxx.2"
mailsvr="192.xxx.xxx.5"
extip_250="63.xxx.xxx.250"
extip_251="63.xxx.xxx.251"
extip_252="63.xxx.xxx.252"
extip_253="63.xxx.xxx.253"
extip_254="63.xxx.xxx.254"
##########
# groups #
##########
sql_users="{ 68.xxx.xxx.11, 63.xxx.xxx.0/24, 68.xxx.xxx.65, 208.xxx.xxx.65 }"
###########
# options #
###########
# set timeout tcp.established 3600
# set timeout { tcp.opening 30, tcp.closing 900 }
set logininterface xl0
set limit { states 20000, frags 20000 }
#############
# normalize #
#############
scrub in on $ext_if all fragment reassemble
scrub out on $ext_if all fragment reassemble
################################
#
# network address translation
# ################################
nat on $ext_if from $royalst to any -> $ext_if
#############
# ftp-proxy #
#############
rdr on $int_if proto tcp from any to any port 21 -> $loop port 8021
#########
# binat #
#########
# MS's fubar'd excuse for a VPN protocal requires this
binat on $ext_if proto gre from $mailsvr to any -> $extip_251
#############
# redirects #
#############
# extip_250
rdr on $ext_if proto tcp from any to $extip_250 port ssh -> $mailsvr port ssh
rdr on $ext_if proto udp from any to $extip_250 port domain -> $mailsvr port domain
rdr on $ext_if proto tcp from any to $extip_250 port http -> $websvr port http
rdr on $ext_if proto { tcp, udp } from any to $extip_250 port ms-sql-s -> $websvr port ms-sql-s
rdr on $ext_if proto { tcp, udp } from any to $extip_250 port ms-sql-m -> $websvr port ms-sql-m
rdr on $ext_if proto tcp from $admin to $extip_250 port pcanywheredata -> $websvr port pcanywheredata
rdr on $ext_if proto udp from $admin to $extip_250 port pcanywherestat -> $websvr port pcanywherestat
# extip_251
rdr on $ext_if proto tcp from any to $extip_251 port smtp -> $mailsvr port smtp
rdr on $ext_if proto tcp from any to $extip_251 port http -> $mailsvr port http
rdr on $ext_if proto tcp from any to $extip_251 port imap -> $mailsvr port imap
rdr on $ext_if proto tcp from any to $extip_251 port pptp -> $mailsvr port pptp
rdr on $ext_if proto tcp from $admin to $extip_251 port pcanywheredata -> $websvr port pcanywheredata
rdr on $ext_if proto udp from $admin to $extip_251 port pcanywherestat -> $websvr port pcanywherestat
################################
#
# packet filter
#
################################
# the implicit first two rules are
# pass in all
pass out all
block in all
# block out all
############
# loopback #
############
pass in quick on $loop all
pass out quick on $loop all
######################
# external interface #
######################
# block out on $ext_if
block in quick on $ext_if from $private to any
block out quick on $ext_if from any to $private
pass out on $ext_if inet proto tcp all modulate state
pass out on $ext_if inet proto udp all keep state
pass out on $ext_if inet proto icmp all keep state
pass in quick on $ext_if proto gre from $any to $mailsvr keep state
pass in quick on $ext_if proto tcp from $any to $mailsvr port 0 flags S/SA keep state
pass in quick on $ext_if proto tcp from $admin to $sentry port ssh flags S/SA keep state
pass in quick on $ext_if proto tcp from any to $sentry port smtp flags S/SA keep state
pass in quick on $ext_if proto udp from any to $mailsvr port domain keep state
pass in quick on $ext_if proto tcp from any to $websvr port http flags S/SA keep state
pass in quick on $ext_if proto tcp from any to $mailsvr port http flags S/SA keep state
pass in quick on $ext_if proto tcp from any to $sentry port imap flags S/SA keep state
pass in quick on $ext_if proto tcp from $any to $mailsvr port pptp flags S/SA keep state
pass in log quick on $ext_if proto tcp from $sql_users to $websvr port ms-sql-s flags S/SA keep state
pass in log quick on $ext_if proto udp from $sql_users to $websvr port ms-sql-s keep state
pass in log quick on $ext_if proto tcp from $sql_users to $websvr port ms-sql-m flags S/SA keep state
pass in log quick on $ext_if proto udp from $sql_users to $websvr port ms-sql-m keep state
######################
# internal interface #
######################
pass in quick on $int_if proto { tcp, udp, icmp } from $royalst to any keep state