Hello there. I've completed setting my mail server up. Just for the sake of security and connection stability, I tried to implement PF firewall as well, for my services.
Before I proceed and move my mail server into production, could someone please take a quick look at my pf.conf file and give me feedback and suggestions, -in case any-?
Thank you!
Before I proceed and move my mail server into production, could someone please take a quick look at my pf.conf file and give me feedback and suggestions, -in case any-?
Thank you!
Code:
ext_if="vio0"
icmp_types = "{ echoreq, unreach, timex }"
# RFC 4890: Recommendations for Filtering ICMPv6 Messages in Firewalls
icmp6_types = "{ echoreq, unreach, timex, toobig, paramprob, neighbrsol }"
table <whitelist> persist file "/var/pf/whitelist.txt"
table <pfbadhost> persist file "/var/pf/badhost.txt"
set ruleset-optimization basic
set optimization normal
set limit { states 200000, frags 200000, src-nodes 100000, table-entries 350000 }
set reassemble yes
set block-policy drop
set loginterface $ext_if
set skip on lo
match in all scrub (no-df random-id)
antispoof for $ext_if
block drop in log quick on $ext_if from <pfbadhost>
block return in log all
pass quick inet proto icmp icmp-type $icmp_types max-pkt-rate 100/10
pass quick proto ipv6-icmp from any to any max-pkt-rate 100/10
# Whitelist
pass quick from <whitelist> to any flags any keep state
# allow SSH (2222), SMTP, POP3, IMAP and Rspamd stuff
pass in quick on $ext_if proto tcp from any to port { 2222, smtp, submission, smtps, imap, imaps, pop3, pop3s, www, https, 11335 }
# I only want my server and daemons able to resolve domains, hostnames over the Internet and have an up-to-date time.. So do I really need this?
pass out quick on $ext_if proto udp from any to port { ntp, domain }
# outbound traffic
pass out quick on $ext_if proto tcp from any to any
pass out quick on $ext_if proto udp from any to any