Hey,
I had the good idea to fetch a big list of ip addresses that are known crawlers or such, add them to a npf blocklist to not have crawlers doing their thing....
It all looked very good, added this to cron had it run for a few days. (realize now that i dont think i did a: service npf reload, but just the npfctl command below...
Then today had to reboot, for other things, and it would not boot.
It was stuck at the Enabling NPF stage...machine going crazy ... (heavy load)
#!/bin/sh
fetch -o /tmp/ipsum.txt https://
raw.githubusercontent.com/stamparm/ipsum/refs/heads/master/ipsum.txt
grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' /tmp/ipsum.txt | doas tee /etc/npf_blocklist
npfctl table "blocklist" flush
Booted into single user and moved away the npf_blocklist file, then it rebooted fine.
Its otherwise a very simple npf.conf
$ cat /etc/npf.conf
$ext_if = { inet4(re0) }
$int_if = { inet4(tap0) }
table <blocklist> type ipset file "/etc/npf_blocklist"
table <limited> type lpm
$services_tcp = { domain, 5900, 5901, 5902, 5903, 5904, 5905, 9022, 9080, 9443 }
$services_udp = { domain, ntp }
$localnet = { 192.168.6.0/24 }
alg "icmp"
# These NAT rules will dynamically select the interface address(es).
map $ext_if dynamic 192.168.6.0/24 -> ifaddrs($ext_if)
map $ext_if dynamic proto tcp 192.168.6.2 port 22 <- ifaddrs($ext_if) port 9022
map $ext_if dynamic proto tcp 192.168.6.2 port 80 <- ifaddrs($ext_if) port 9080
map $ext_if dynamic proto tcp 192.168.6.2 port 443 <- ifaddrs($ext_if) port 9443
procedure "log" {
log: npflog0
}
group "external" on $ext_if {
pass stateful out final all
block in final from <blocklist>
pass stateful in final family inet4 proto tcp to $ext_if port 22 apply "log"
pass stateful in final family inet4 proto tcp to $ext_if port 80 apply "log"
pass stateful in final family inet4 proto tcp to $ext_if port 443 apply "log"
pass stateful in final proto tcp to $ext_if port $services_tcp
pass stateful in final proto udp to $ext_if port $services_udp
}
group "internal" on $int_if {
block in all
block in final from <limited>
pass in final from $localnet
pass out final all
}
group default {
pass final on lo0 all
block all
}
the big npf_blocklist file was about 2mb with ip addresses line by line, about 130k lines.
Is there a known limit somewhere or where do i need to poke to have it handle this blocklist.
Its a base v10.1 Stable install otherwise. (upgrade to v11?)
From the code it does not look like there should be trouble with the number of entries atleast.
https://github.com/NetBSD/src/blob/trunk/sys/net/npf/npf_tableset.c#L496
--- edit ---
on hardware, amd64, alot of ram (5ish year old machine).
Thanks in advance!