# PF configuration for Central de Vendas Informatica LTDA.
# admin@centralinf.com.br
### macros ###
ext_if = "xl0"
int_if = "re0"
int_odin = "192.168.1.134"
ext_odin = "201.12.35.52"
int_saint = "192.168.1.53"
ext_saint = "201.12.35.54"
range_saint = "200.230.207.0/24"
priv_nets = "{ 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 }"
priv_users = "{ 192.168.1.120, 192.168.1.121, 192.168.1.122, 192.168.1.123 }"
### options ###
set block-policy return
set loginterface $ext_if
set skip on lo
### scrub ###
scrub all no-df fragment reassemble random-id
### nat ###
# nat for all network.
nat on $ext_if from $int_if:network to any -> $ext_if:0
nat-anchor "ftp-proxy/*"
# binat for odin.
binat on $ext_if from $int_odin to any -> $ext_odin
# binat for saint.
binat on $ext_if from $int_saint to $range_saint -> $ext_saint
### redirects ###
# ftp-proxy.
rdr-anchor "ftp-proxy/*"
rdr pass on $int_if proto tcp to port ftp -> 127.0.0.1 port 8021
# transparent proxy.
rdr on $int_if proto tcp from any to any port { 80, 443 } -> 127.0.0.1 port 3128
### filter rules ###
# block everything.
block all
# allow all traffic on $int_if.
pass quick on $int_if
# antispoof and ftp-proxy anchor.
antispoof quick for { lo, $int_if }
anchor "ftp-proxy/*"
# block privileged nets.
block drop in quick on $ext_if from $priv_nets to any
block drop out quick on $ext_if from any to $priv_nets
# block msn.
block drop quick inet proto tcp from any to any port 1863
# allow msn to priv_users ;).
pass out on $ext_if inet proto tcp from $priv_users to any \
port 1863 modulate state flags S/SA
# allow ping.
pass in quick inet proto icmp all icmp-type echoreq keep state
# allow vpn (1723) and tun interfaces.
pass in quick on $ext_if inet proto tcp from any to ($ext_if) \
port 1723 modulate state flags S/SA
pass in quick on $ext_if inet proto gre from any to ($ext_if) \
keep state
pass quick on tun
# allow ssh from internal network.
pass in quick on $int_if inet proto tcp from any to \
any port ssh flags S/SA keep state
# allow all tcp, udp and icmp pass out.
pass out quick on $ext_if inet proto tcp all modulate state flags S/SA
pass out quick on $ext_if inet proto { udp, icmp } all keep state