# # $Id: pf.conf.39,v 1.2 2006/05/05 09:13:26 raptor Exp $ # # pf.conf.39 - Sample PF/NAT ruleset for OpenBSD 3.9 # Copyright (c) 2006 Marco Ivaldi # # The pf(4) packet filter modifies, drops or passes packets according to # rules or definitions specified in pf.conf(5). This is a sample ruleset # for the configuration of a basic OpenBSD 3.9 stateful packet filter. # # This ruleset is optimized for usage with the authpf(8) authenticating # user shell. The default block-policy is set to drop. # # Tested on OpenBSD 3.9 with 2 NICs, change it to fit your configuration. # ############################################################################### # Macros # # User-defined variables may be defined and used later, simplifying the # configuration file. Macros must be defined before they are referenced. # # available interfaces ext_if= "dc0" int_if= "dc1" # list of networks ext_net= "x.x.x.0/24" int_net= "192.168.0.0/24" # list of hosts fw_ext= "x.x.x.x" priv= "192.168.0.3" ############################################################################### # Tables # # Tables provide a mechanism for increasing the performance and flexibility # of rules with large numbers of source or destination addresses. # table const { 127/8, 10/8, 172.16/12, 192.168/16 } table persist ############################################################################### # Options # # Options tune the behaviour of the packet filtering engine. # set optimization normal set block-policy drop set skip on lo0 ############################################################################### # Traffic Normalization # # Traffic normalization protects internal machines against inconsistencies # in Internet protocols and implementations. # scrub in #scrub out ############################################################################### # Translation # # Translation rules specify how addresses are to be mapped or redirected to # other addresses. # # ftp-proxy anchors nat-anchor "ftp-proxy/*" rdr-anchor "ftp-proxy/*" # ip masquerading nat on $ext_if inet from $int_net -> $fw_ext # ftp-proxy rdr pass on $int_if inet proto tcp to port 21 -> 127.0.0.1 port 8021 # private web server (authpf) rdr on $ext_if inet proto tcp to port 443 -> $priv port 443 ############################################################################### # Packet Filtering # # Stateful and stateless packet filtering provides rule-based blocking or # passing of packets. # # ftp-proxy anchor anchor "ftp-proxy/*" # default policy block in log block out # trusted interfaces pass in quick on $int_if inet pass out quick on $int_if inet # egress filtering block out quick on $ext_if inet from !$ext_net # anti-spoofing block drop in quick on $ext_if inet from # outbound traffic (icmp, udp, tcp) pass out on $ext_if inet proto { icmp, udp, tcp } keep state # inbound traffic (fw) pass in on $ext_if inet proto tcp from any to $fw_ext \ port 2222 flags S/SA keep state # inbound traffic (priv) pass in on $ext_if inet proto tcp from to $priv \ port 443 flags S/SA keep state