# $FreeBSD: src/etc/pf.conf,v 1.3 2006/01/27 17:16:20 mlaier Exp $ # $OpenBSD: pf.conf,v 1.21 2003/09/02 20:38:44 david Exp $ # # See pf.conf(5) and /usr/share/examples/pf for syntax and examples. # Required order: options, normalization, queueing, translation, filtering. # Macros and tables may be defined and used anywhere. # Note that translation rules are first match while filter rules are last match. # Macros: define common values, so they can be referenced and changed easily. ext_if="xl0" # replace with actual external interface name i.e., dc0 int_if="vr0" # replace with actual internal interface name i.e., dc1 # Tables: similar to macros, but more flexible for many addresses. #table { 10.0.0.0/8, !10.1.0.0/16, 192.168.0.0/24, 192.168.1.18 } # Options: tune the behavior of pf, default values are given. #set timeout { interval 10, frag 30 } #set timeout { tcp.first 120, tcp.opening 30, tcp.established 86400 } #set timeout { tcp.closing 900, tcp.finwait 45, tcp.closed 90 } #set timeout { udp.first 60, udp.single 30, udp.multiple 60 } #set timeout { icmp.first 20, icmp.error 10 } #set timeout { other.first 60, other.single 30, other.multiple 60 } #set timeout { adaptive.start 0, adaptive.end 0 } #set loginterface none #set optimization normal #set require-order yes #set fingerprints "/etc/pf.os" set limit states 25000 set block-policy drop set skip on lo0 # Normalization: reassemble fragments and resolve or reduce traffic ambiguities. scrub in all # Translation: specify how addresses are to be mapped or redirected. # nat: packets going out through $ext_if with source address $internal_net will # get translated as coming from the address of $ext_if, a state is created for # such packets, and incoming packets will be redirected to the internal address. # binat on $ext_if from 10.69.69.30 to any -> AAA.BBB.CCC.30 binat on $ext_if from 10.69.69.60 to any -> AAA.BBB.CCC.60 nat on $ext_if from $int_if:network to any -> ($ext_if) # rdr: packets coming in on $ext_if with destination $external_addr:1234 will # be redirected to 10.1.1.1:5678. A state is created for such packets, and # outgoing packets will be translated as coming from the external address. #rdr on $ext_if proto tcp from any to $external_addr/32 port 1234 -> 10.1.1.1 port 5678 # https to freezer rdr pass on $ext_if proto tcp from any to $ext_if:0 port 21443 -> 10.69.69.21 port 443 # ssh to freezer rdr pass on $ext_if proto tcp from any to $ext_if:0 port 26921 -> 10.69.69.21 port 22 # bittorrent to freezer rdr pass on $ext_if proto {tcp udp} from any to $ext_if:0 port 6881:6899 -> 10.69.69.21 port 6881:6899 rdr pass on $ext_if proto udp from any to $ext_if:0 port 4444 -> 10.69.69.21 port 4444 # ssh to voyeuristic rdr pass on $ext_if proto tcp from any to $ext_if:0 port 26922 -> 10.69.69.22 port 22 # gnutella to voyeuristic rdr pass on $ext_if proto {tcp udp} from any to $ext_if:0 port 3897 -> 10.69.69.22 port 3897 # Filtering: the implicit first two rules are #pass in all #pass out all # block all incoming packets but allow ssh, pass all outgoing tcp and udp # connections and keep state, logging blocked packets. # block log all pass quick on $int_if all # allow all outbound, statefully pass out on $ext_if all # ping & traceroute icmp_types="{ 3 8 11 }" pass in on $ext_if inet proto icmp icmp-type $icmp_types pass in on $ext_if proto udp from any to any port 33434:33625 # munin-node pass in on $ext_if proto tcp from WWW.XXX.YYY.ZZZ to ($ext_if) port 4949 # ssh, http, https to transexual pass in on $ext_if proto tcp from any to 10.69.69.30 port { 22 80 443 } # everything to xiombarg for now pass in on $ext_if from any to 10.69.69.60