Good afternoon... I've got a FreeBSD environment running 13.1-RELEASE and 16 GB RAM... I'm attempting to implement some geo-ip blocking which involves having some fairly large tables I'm trying to load into PF... I've got everything working for the most part, but PF won't load on start, and I feel like it's because the options aren't being processed properly when FreeBSD boots and loads PF. Across my tables I have around 1.5 million IP address records to load in. Initially I hit some limits, so I tuned and am able to load things manually. The pfctl man page says I must define MACROS, then TABLES, then OPTIONS, and so on. So naturally, I do that, and load my macros, then the tables, following by setting the options:
When FreeBSD boots, rules are not loaded. If I run pfctl -f /etc/pf.conf, I get the following:
This confused me, as I already set my table-entries value properly (as well as tuned kern.maxdsiz and net.pf.request_maxcount accordingly). So then I said what if I load the options first, then load the rules, and this worked fine:
The options don't appear to be getting set prior to loading the tables. I attempted to move the OPTIONS above the table definitions but the behavior didn't change. At the moment, I'm a little stuck how to configure this such that the PF rules load properly at boot time.
Any advice would be great, thanks!
Code:
##########
# MACROS #
##########
ext_if="ena0"
# ADDR1 PUBLIC / PRIVATE PORTS - HOST
external_addr1="1.2.3.4"
public_ports_tcp_addr1="{ 443 }"
##########
# TABLES #
##########
table <blocklist_europe1> persist file "/usr/local/etc/pf_lists/pf_blocklist_europe1"
table <blocklist_europe2> persist file "/usr/local/etc/pf_lists/pf_blocklist_europe2"
table <blocklist_europe3> persist file "/usr/local/etc/pf_lists/pf_blocklist_europe3"
table <blocklist_europe4> persist file "/usr/local/etc/pf_lists/pf_blocklist_europe4"
table <blocklist_europe5> persist file "/usr/local/etc/pf_lists/pf_blocklist_europe5"
table <blocklist_europe6> persist file "/usr/local/etc/pf_lists/pf_blocklist_europe6"
table <blocklist_europe7> persist file "/usr/local/etc/pf_lists/pf_blocklist_europe7"
table <blocklist_europe8> persist file "/usr/local/etc/pf_lists/pf_blocklist_europe8"
table <blocklist_europe9> persist file "/usr/local/etc/pf_lists/pf_blocklist_europe9"
###########
# OPTIONS #
###########
set limit table-entries 2000000
set limit frags 10000
set limit states 25000
When FreeBSD boots, rules are not loaded. If I run pfctl -f /etc/pf.conf, I get the following:
Code:
/etc/pf.conf:24: cannot define table blocklist_europe1: Cannot allocate memory
/etc/pf.conf:25: cannot define table blocklist_europe2: Cannot allocate memory
/etc/pf.conf:26: cannot define table blocklist_europe3: Cannot allocate memory
/etc/pf.conf:27: cannot define table blocklist_europe4: Cannot allocate memory
/etc/pf.conf:28: cannot define table blocklist_europe5: Cannot allocate memory
/etc/pf.conf:29: cannot define table blocklist_europe6: Cannot allocate memory
/etc/pf.conf:30: cannot define table blocklist_europe7: Cannot allocate memory
/etc/pf.conf:31: cannot define table blocklist_europe8: Cannot allocate memory
/etc/pf.conf:32: cannot define table blocklist_europe9: Cannot allocate memory
pfctl: Syntax error in config file: pf rules not loaded
This confused me, as I already set my table-entries value properly (as well as tuned kern.maxdsiz and net.pf.request_maxcount accordingly). So then I said what if I load the options first, then load the rules, and this worked fine:
Code:
root@host ~ # pfctl -Of /etc/pf.conf
root@host ~ # pfctl -f /etc/pf.conf
root@host ~ # pfctl -sa
FILTER RULES:
scrub in all fragment reassemble
pass in quick on ...
pass in quick on ...
pass in quick on ...
block drop in quick from <blocklist_europe1> to any
block drop in quick from <blocklist_europe2> to any
block drop in quick from <blocklist_europe3> to any
block drop in quick from <blocklist_europe4> to any
block drop in quick from <blocklist_europe5> to any
block drop in quick from <blocklist_europe6> to any
block drop in quick from <blocklist_europe7> to any
block drop in quick from <blocklist_europe8> to any
block drop in quick from <blocklist_europe9> to any
...
The options don't appear to be getting set prior to loading the tables. I attempted to move the OPTIONS above the table definitions but the behavior didn't change. At the moment, I'm a little stuck how to configure this such that the PF rules load properly at boot time.
Any advice would be great, thanks!