wiki:openbsd:pf
**This is an old revision of the document!**
PF
- pf.conf
##################################################################################################
# GLOBAL
##################################################################################################
block in quick on ISP proto tcp to port {9200,8080} label "Block Spammer on port $dstport"
##################################################################################################
# QUEUE
##################################################################################################
queue rootq on em0 bandwidth 1G #, max 250M qlimit 300
queue ssh parent rootq bandwidth 900M #900K, min 50K burst 1M for 200ms qlimit 50
queue vpn parent rootq bandwidth 900M # qlimit 100
queue admin parent rootq bandwidth 900M # qlimit 100
queue main parent rootq bandwidth 200M min 10M max 200M
queue def parent main bandwidth 150M default
queue rtp parent main bandwidth 350K, min 350K burst 700K for 200ms qlimit 50
queue nzb parent main bandwidth 200M qlimit 50
queue pri parent main bandwidth 900K, min 50K burst 1M for 200ms qlimit 50
queue dns parent main bandwidth 100K, min 10K burst 200K for 1000ms qlimit 50
queue guests parent main bandwidth 100M
queue ack parent main bandwidth 2M
queue bulk parent main bandwidth 160M default
##################################################################################################
match proto {ospf} set queue rtp set prio 6 label "Set proto $proto to prio 6"
match proto {tcp} to port {bgp} set queue rtp set prio 6 label "Set port $dstport to prio 6"
match proto {esp} set queue rtp set prio 6 label "Set proto $proto to prio 6"
match proto {udp} to port {isakmp,ipsec-nat-t} set queue vpn set prio 6 label "Set port $dstport to prio 6"
match proto {tcp} to port {http,https} set queue (bulk,ack) set prio (3, 6) label "Set port $dstport to prio 3,6"
match proto {tcp} to port {ssh} set queue ssh set tos lowdelay set prio 6 label "Set port $dstport to prio 6"
match proto {udp} to port {domain} set queue dns set prio 6 label "Set port $dstport to prio 6"
match proto {tcp} to port {563} set queue nzb set prio 4 label "Set port $dstport to prio 4"
#match proto {tcp,udp,igmp} from <guests> set queue guests set prio 2 label "Set $srcaddr to $dstaddr to prio 2"
match from <admin> set queue admin set prio 6 label "Set $srcaddr to $dstaddr to prio 6"
##################################################################################################
# GLOBAL OPTIONS
##################################################################################################
#set debug info
set skip on lo
set loginterface egress
set skip on lo0
set skip on enc0
#set optimization conservative
#set ruleset-optimization basic
##################################################################################################
# TABLES
##################################################################################################
table <attacker> persist
table <tor> persist file "/etc/pf_tables/pf.tor"
table <ransom> persist file "/etc/pf_tables/pf.ransom"
table <malware> persist file "/etc/pf_tables/pf.malware"
table <adhosts> persist file "/etc/pf_tables/pf.adhosts"
table <country> persist file "/etc/pf_tables/pf.country"
##################################################################################################
table <firewall> const { self }
table <GC-MV> persist file "/etc/pf_tables/pf.GC-MV"
table <GC-TG> persist file "/etc/pf_tables/pf.GC-TG"
table <GC-SB> persist file "/etc/pf_tables/pf.GC-SB"
table <HP> persist file "/etc/pf_tables/pf.HP"
table <GC> persist file "/etc/pf_tables/pf.GC"
table <RZ-FW> persist file "/etc/pf_tables/pf.RZ-FW"
table <RZ-CORE> persist file "/etc/pf_tables/pf.CORE"
table <openvpn> persist file "/etc/pf_tables/pf.openvpn"
table <RZ> persist file "/etc/pf_tables/pf.RZ"
table <NSAS> persist file "/etc/pf_tables/pf.nsas"
table <NSAS-INT> persist file "/etc/pf_tables/pf.nsas-int"
table <NSAS-VM> { 10.192.1.0/24 }
table <ADMIN> persist file "/etc/pf_tables/pf.admin"
table <VPN> persist file "/etc/pf_tables/pf.vpn"
table <NET> persist file "/etc/pf_tables/pf.net"
table <SWISSBIT> persist file "/etc/pf_tables/pf.swissbit"
table <COMPROMISED> persist file "/etc/pf_tables/pf.compromised"
table <FIREHOL> persist file "/etc/pf_tables/pf.firehol"
table <shadon> persist file "/etc/pf_tables/pf.shadon"
##################################################################################################
# BLOCK
##################################################################################################
block drop in quick log from <tor> label "Block TOR"
block drop in quick log on ISP from <shadon> label "Block SHADON"
block drop quick log from <ransom> label "Block RANSOM"
block drop quick log to <ransom> label "Block RANSOM"
block drop quick log to <adhosts> label "Block ADWARE"
block drop in quick log on ISP from <COMPROMISED> label "Block COMPROMISED"
block drop in quick log on ISP from <FIREHOL> label "Block FIREHOL"
block drop in quick log from <country> label "Block COUNTRY's"
block drop in quick log from <attacker> label "Block ATTACKER's"
block drop in log label "Block UNDEFINED"
##################################################################################################
match out scrub (no-df random-id reassemble tcp) label "Normalize Traffic"
#match out all scrub (no-df random-id tcp max-mss 1500 ) label "scrub all"
##################################################################################################
# PASS quick
##################################################################################################
include "/etc/pf.conf.local"
##################################################################################################
# INCLUDE
##################################################################################################
include "/etc/pf/icmp.conf"
include "/etc/pf/ssh.conf"
include "/etc/pf/relay.conf"
include "/etc/pf/routing.conf"
##################################################################################################
# PASS
##################################################################################################
pass from { <NSAS-INT> <ADMIN> } keep state set prio (2, 5) label "Pass from $srcaddr"
pass on CORE label "Pass on $if"
pass on LAN label "Pass on $if"
pass on VPN label "Pass on $if"
##################################################################################################
# FIREWALL SELF
##################################################################################################
pass out all label "Pass out"
##################################################################################################
# NAT
##################################################################################################
match out on ISP inet nat-to (ISP:0) label "NAT from $srcaddr to $dstaddr"
##################################################################################################
Kill a session
Add a host to a table
pfctl -t NO_INTERNET -T add ${IP}
/dokuwiki/data/attic/wiki/openbsd/pf.1683528688.txt.gz · Last modified: 2023/05/08 06:51 by michel