This How-To guide demonstrates how to use the Packet Filter firewall to block IP addresses using a blacklist file, similar to how PeerBlock works on Windows. Compared to Netfilter, Packet Filter offers better performance and more flexibility for customizing your firewall rules.
We can download list from www.iblocklist.com. For example download the PrimaryThreats here. We need to unzip and format the file to make it work with Packet Filter.
root# wget "URLtomyremotelist" -O list.zip
root# unzip file.zip
root# cut -d ":" -f2 list.txt | grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" > blocklist.tmp
root# sed -i 's/-/:/' blocklist.tmp
root# for i in $(cat blocklist.tmp); do echo "$i"; ipcalc -r "$i"| grep "/" >> blocklist; done
root# cp blocklist /etc/blocklist
#sets the maximum number of entries allowed in PF table.
set limit table-entries 1000000
table <blocklist> persist file "/etc/blocklist"
pass out on $wan
pass in quick on $lan inet proto tcp from 192.168.1.10 to any port { 80, 443 }
block quick log (all, to pflog0) on any from <blocklist> to 192.168.1.10
block quick log (all, to pflog1) on any from 192.168.1.10 to <blocklist>
Contact :