pf.conf 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. ext_if="vtnet0"
  2. extnet=$ext_if:network
  3. tcp_services="{ www, https }"
  4. icmp_types="echoreq"
  5. jail_net="192.168.0.1/24"
  6. jail_git="192.168.0.25/24"
  7. jail_git6="fd00::25/24"
  8. jail_net6="fd00::/8"
  9. table <martians> const { 127.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, \
  10. 10.0.0.0/8, 169.254.0.0/16, 192.0.2.0/24, \
  11. 0.0.0.0/8, 240.0.0.0/4 }
  12. table <copains> const { }
  13. set loginterface $ext_if
  14. set skip on lo0
  15. set skip on lo1
  16. set block-policy drop
  17. scrub in on $ext_if all fragment reassemble
  18. scrub on $ext_if all reassemble tcp
  19. nat on $ext_if inet from $jail_net to any -> $ext_if:0
  20. nat on $ext_if inet6 from $jail_net6 to any -> $ext_if:0
  21. rdr pass on $ext_if proto tcp from any to ($ext_if) port 9022 -> jail_git port 22
  22. rdr pass on $ext_if proto tcp from any to ($ext_if) port 9418 -> jail_git port 9418
  23. block in all
  24. pass out all
  25. block drop quick from <sshforce>
  26. block drop in quick on $ext_if from <martians> to any
  27. block drop out quick on $ext_if from any to <martians>
  28. antispoof quick for { lo0 lo1 $ext_if }
  29. pass quick from <copains> to any
  30. anchor "blacklistd/*" in on $ext_if
  31. pass log proto tcp from any to $extnet port 79
  32. pass proto tcp from any to $extnet port $tcp_services \
  33. flags S/SA keep state
  34. # Restrictive Brute force SSH
  35. pass quick proto tcp from any to $extnet port ssh \
  36. flags S/SA keep state \
  37. (max-src-conn 15, max-src-conn-rate 5/3, \
  38. overload <sshforce> flush global)
  39. pass in inet proto icmp all icmp-type $icmp_types
  40. pass in inet6 proto icmp6 all