# # $Id: pf.conf.39.dmz,v 1.4 2006/05/05 09:13:26 raptor Exp $ # # pf.conf.39.dmz - 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 meant to work on a stateful firewall with a bridged DMZ # network configured on the third NIC. To create and activate a bridge # between the external and the dmz interface, use the following commands: # # $ ifconfig dc0 up # $ ifconfig dc2 up # $ ifconfig bridge0 create # $ brconfig add dc0 add dc2 up # # For further information, see bridge(4), brconfig(8), and bridgename.if(5). # # Tested on OpenBSD 3.9 with 3 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" dmz_if= "dc2" # 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" mail_dmz= "x.x.x.2" web_dmz= "x.x.x.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 # reverse ftp-proxy (/usr/sbin/ftp-proxy -R x.x.x.3 -p 8022) #rdr pass on $ext_if inet proto tcp to port 21 -> 127.0.0.1 port 8022 ############################################################################### # 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 # dmz interface pass in quick on $dmz_if inet #pass out quick on $dmz_if route-to lo0 inet proto tcp to port 8022 pass out quick on $dmz_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 (fw + int_net) pass out on $ext_if inet proto { icmp, udp, tcp } from $fw_ext \ keep state # outbound traffic (dmz) pass out on $ext_if inet proto { udp, tcp } from !$fw_ext \ to port 53 keep state # inbound traffic (fw) pass in on $ext_if inet proto tcp to $fw_ext \ port 2222 flags S/SA keep state # inbound traffic (mail) pass in on $ext_if inet proto tcp to $mail_dmz \ port { 25, 53, 110 } flags S/SA keep state pass in on $ext_if inet proto udp to $mail_dmz port 53 keep state # inbound traffic (web) pass in on $ext_if inet proto tcp to $web_dmz \ port { 21, 53, 80, 443 } flags S/SA keep state pass in on $ext_if inet proto udp to $web_dmz port 53 keep state # remote administration (authpf) pass in on $ext_if inet proto tcp from \ to { $mail_dmz, $web_dmz } port 22 flags S/SA keep state