# $OpenBSD: pf.conf,v 1.54 2014/08/23 05:49:42 deraadt Exp $
#
# See pf.conf(5) and /etc/examples/pf.conf
# increase default state limit from 10'000 states on busy systems
set limit states 100000
# Block all Netbios service. 137=name, 138=datagram, 139=session
# Block MS/Windows hosts2 name server requests 81
# 445=microsoft-ds 135=DCE endpoint resolution
# 1900=UPnP 3544=Teredo
bad_ports = "{ 81 135 137:139 445 1900 3544 }"
table <mobile-home> persist file "/etc/mobile-home.conf"
table <internet> persist const { arbeit:network lan:network haus:network gast:network smarthome:network }
dumont = "192.168.93.2"
mail = "192.168.21.20"
mail_ports = "{ imap imaps submission }"
table <martians> const { 10.0.0.0/8 100.64.0.0/10 127.0.0.0/8 169.254.0.0/16 172.16.0.0/12 \
192.0.0.0/24 192.0.2.0/24 192.88.99.0/24 192.168.0.0/16 198.18.0.0/15 \
198.51.100.0/24 203.0.113.0/24 224.0.0.22 240.0.0.0/4 255.255.255.255/32 \
::/128 ::/96 ::1/128 ::ffff:0:0/96 100::/64 2001:10::/28 2001:2::/48 \
2001:db8::/32 3ffe::/16 fec0::/10 fc00::/7 }
table <local> persist const { lan:0:network arbeit:0:network haus:0:network smarthome:0:network }
table <teredo> const { 192.168.21.67 }
table <leased> persist
table <abandoned> persist
table <changed> persist
set reassemble yes
set block-policy return
set loginterface egress
set skip on { enc0 tun }
set limit table-entries 400000
match in all scrub (no-df random-id)
pass log quick on lo0
pass log quick on lo40
block log
block in quick log on ! em1 from { urpf-failed }
block in quick log on ! em1 from { no-route }
block in quick proto {tcp,udp} to port $bad_ports
# ICMP
pass quick inet6 proto icmp6
# DHCPv6
pass in on em1 inet6 proto udp from fe80::/10 port dhcpv6-client to fe80::/10 port dhcpv6-server no state label DHCPv6
pass in on em1 inet6 proto udp from fe80::/10 port dhcpv6-server to fe80::/10 port dhcpv6-client no state label DHCPv6
anchor "arbeit" on rdomain 40 {
block log
pass in log proto udp to vlan40 port 53 rdr-to 192.168.21.1 rtable 0 keep state (floating)
pass in log quick proto tcp to vlan40 port 53 rdr-to 192.168.21.1 rtable 0
pass in log proto tcp to vlan40 port 80 rdr-to 192.168.21.1 rtable 0
pass in log proto tcp to vlan40 port 443 rdr-to 192.168.21.1 rtable 0 keep state (floating)
pass out log
# pass in log to !vlan40 nat-to (egress) rtable 0
match out log to vlan40:network nat-to 192.168.21.1 rtable 0
match out log to !vlan40:network nat-to (egress) static-port rtable 0
match log proto udp to port 53
match log proto udp from port 53
}
match log proto udp to port 53
match log proto udp from port 53
pass out quick log to vlan40:network nat-to vlan40 rtable 40
#
# IN
#
# Lan:network
pass in on lan
# Mobile Home
pass in on grid from <mobile-home> label MOBILE-WOPR
# SSH
pass in log proto tcp to port ssh label SSH
# DNS
pass in log on !egress proto { tcp udp } to (self) port domain label DNS
pass in log proto { tcp udp } to (self) port domain label DNS
# mDNS
pass in on lan proto udp to lan:network port mdns label mDNS
# NTP
pass in on !egress proto udp to (self) port ntp label NTP
# DHCP
pass in on !em1 proto udp from port bootpc to port bootps label DHCP
pass in on em1 proto udp from port bootps to port bootpc label DHCP-DG
# HTTP
pass in on lan proto tcp to lan port { http https } label HTTP
# LDAP
pass in on lan proto tcp to lan port ldaps label LDAP
# MQTT
pass in on lan inet proto tcp to lan port { 1883 8883 } label MQTT
pass in on smarthome inet proto tcp to smarthome port { 1883 8883 } label MQTT
#
# Forwarding
#
pass in log on !egress to !(self) label ROUTING
#
# Redirects
#
match out to 192.168.10.0/24 nat-to 192.168.10.211
match out on smarthome nat-to smarthome
#
# OUT
#
pass out log ! received-on any
pass out log proto {icmp icmp6} ! received-on any
pass out on { grid haus smarthome } received-on lan label LAN-OUT
pass out on lan proto tcp from $dumont to $mail port $mail_ports label DUMONT-MAIL
pass out on lan from <mobile-home>
# -> INTERNET
pass out log on egress to !<martians>
#pass out log quick on egress from (self) to vlan40:network nat-to 192.168.40.1 rtable 40
pass out log on egress from (self) label SELF
pass out log on egress from lan:network label LAN
pass out on egress received-on arbeit label ARBEIT
pass out on egress received-on gast label GAST
pass out on egress received-on haus label HAUS
pass out on egress received-on smarthome label SMARTHOME
pass out log on egress tagged VLAN40 label V40
match out log on egress inet to ! vlan40:network nat-to (egress)
match out on egress inet6 from fc00::/7 nat-to (egress)