Thank you for suggesting this great list. I have been using Gerd’s IP blocklist for a year since July 2023. It is a very well thought out and you can see how much effort he put into this repository. The blocklists are organized in such a meticulous way I haven’t seen anywhere else. He puts to shame even many so called security vendors
# rpz-config add urlhaus https://urlhaus.abuse.ch/downloads/rpz/
unbound: info: rpz: add config file "urlhaus.rpz.conf"
changed ownership of '/etc/unbound/zonefiles/urlhaus.rpz' from root:root to nobody:nobody
mode of '/etc/unbound/zonefiles/urlhaus.rpz' retained as 0644 (rw-r--r--)
unbound: rpz: running "unbound-control reload"
ok
# rpz-metrics 3
name hits active lines hits/line% last update
---------------/usr/sbin/rpz-metrics: line 111: 100 * theHits / theLines : division by 0 (error token is "theLines ")
--------------
======= ========
Totals --> 0 0
Looking through the unbound log, it looks like it is working as intended:
these domains or on the Threatfox or Urlhaus block lists
info: rpz: applied [threatfox] mail.08rococoephemeral.buzz. rpz-nxdomain 127.0. 0.1@33908 mail.08rococoephemeral.buzz. A IN
unbound: [7750:0] info: rpz: applied [threatfox] mail.08rococoephemeral.buzz. rpz-nxdomain 127.0. 0.1@33908 mail.08rococoephemeral.buzz. AAAA IN
unbound: [7750:0] info: rpz: applied [threatfox] mail.08rococoephemeral.buzz. rpz-nxdomain 127.0. 0.1@33821 mail.08rococoephemeral.buzz. A IN
unbound: [7750:0] error: SERVFAIL <06melliineffable.buzz. A IN>: exceeded the maximum number of s ends
I can send you the lines that changed. Or the entire /usr/sbin/rpz-metrics file. Let me know what is better for you.
I do not have the full rpz-n-n.ipfire build yet (it is still building!)
Here is the entire /usr/sbin/rpz-metrics file:
#!/bin/bash
###############################################################################
# #
# IPFire.org - A linux based firewall #
# Copyright (C) 2024 IPFire Team <info@ipfire.org> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
###############################################################################
# v19 on 2024-07-30
############### Main ###############
weeks="${1:-2}" # default to two message logs
sortBy="${2:-name}" # by name or by hits
# get the list of message logs for N weeks
messageLogs=$( find /var/log/messages* -type f |
/usr/bin/sort --version-sort |
head -"${weeks}" )
# get the list of RPZ names & counts from the message log(s)
rpzNameCount=$( for logf in ${messageLogs} ; do
/usr/bin/zgrep --text --extended-regexp 'info: rpz: applied.* A IN$' "${logf}" |
/usr/bin/awk '$10 ~ /\[\w*]/ { print $10 }' ;
done | /usr/bin/sort | /usr/bin/uniq --count )
# flip results and remove brackets `[` and `]`
rpzNameCount=$( /bin/echo "${rpzNameCount}" |
/usr/bin/awk '{ print $2, $1 }' |
/bin/sed --regexp-extended 's|^\[(.*)\]|\1|' )
# grab only names
rpzNames=$( /bin/echo "${rpzNameCount}" | /usr/bin/awk '{ print $1 }' )
# get list of RPZ files
rpzFileList=$( /bin/find /etc/unbound/zonefiles -type f -iname "*.rpz" )
# get basename of those files
rpzBaseNames=$( /bin/echo "${rpzFileList}" |
/bin/sed 's|/etc/unbound/zonefiles/||g ; s|\.rpz||g ;' )
# add to rpzNames
rpzNames="${rpzNames}"$'\n'"${rpzBaseNames}"
# drop duplicate names
rpzNames=$( echo "${rpzNames}" | /usr/bin/sort --unique )
# get line count for each RPZ
lineCount=$( /bin/echo "${rpzFileList}" | /usr/bin/xargs wc -l )
# get comment line count and blank line count for each RPZ
commentCount=$( /bin/echo "${rpzFileList}" |
/usr/bin/xargs /bin/grep --count -e "^$" -e "^;" )
# get modified date each RPZ
modDateList=$( /bin/echo "${rpzFileList}" | xargs stat -c '%.10y %n' )
ucListAuthZones=$( /usr/sbin/unbound-control list_auth_zones )
# get width of RPZ names
pWidth=$( /bin/echo "${rpzNames}" | /usr/bin/awk '{ print $1" " }' | wc -L )
pFormat="%-${pWidth}s %-8s %-8s %-8s %10s %12s\n"
# print title line
printf "${pFormat}" "name" "hits" "active" "lines" "hits/line%" "last update"
printf -- "--------------"
theResults=""
totalLines=0
totalHits=0
while read -r theName
do
printf -- "-" # pretend progress bar
# get hit count
theHits="0"
if output=$( /bin/grep "^${theName}\s" <<< "${rpzNameCount}" ) ; then
theHits=$( /bin/echo "${output}" |
/usr/bin/awk '{ print $2 }' )
totalHits=$(( totalHits + theHits ))
fi
# is this RPZ list active?
theActive="disabled"
if /bin/grep --quiet "^${theName}\.rpz" <<< "${ucListAuthZones}"
then
theActive="enabled"
fi
# get line count then subtract comment count and blank line count
# from total line count
theLines="n/a"
hitsPerLine="0"
if output=$( /bin/grep --fixed-strings "/${theName}.rpz" <<< "${lineCount}" ) ; then
theLines=$( /bin/echo "${output}" | /usr/bin/awk '{ print $1 }' )
totalLines=$(( totalLines + theLines ))
if [[ "${theLines}" -gt 2 ]] ; then
hitsPerLine=$(( 100 * theHits / theLines ))
fi
fi
# get modification date
theModDate="n/a"
if output=$( /bin/grep --fixed-strings "/${theName}.rpz" <<< "${modDateList}" ) ; then
theModDate=$( /bin/echo "${output}" | /usr/bin/awk '{ print $1 }' )
fi
# add to results list
theResults+="${theName} ${theHits} ${theActive} ${theLines} ${hitsPerLine} ${theModDate}"$'\n'
done <<< "${rpzNames}"
case "${sortBy}" in
names|name) sortArg=(-k3,3r -k1,1) ;; # sort by "active" then by "name"
hits|hit) sortArg=(-k3,3r -k2,2nr -k1,1) ;; # sort by "active" then by "hits" then by "name"
lines|line) sortArg=(-k3,3r -k4,4nr -k1,1) ;; # sort by "active" then by "lines" then by "name"
esac
printf -- "--------------\n"
# remove blank lines, sort, print as columns
/bin/echo "${theResults}" |
/usr/bin/awk '!/^[[:space:]]*$/' |
/usr/bin/sort "${sortArg[@]}" |
/usr/bin/awk --assign=width="${pWidth}" \
'{ printf "%-*s %-8s %-8s %-8s %10s %12s\n", width, $1, $2, $3, $4, $5, $6 }'
printf "${pFormat}" "" "=======" "" "========" "" ""
printf "${pFormat}" "Totals -->" "${totalHits}" "" "${totalLines}" "" ""
exit
Hi @jon ,
I downloaded JonMurphy:RPZ.pdf (1.1 MB) and tried to open the GIT Hub links toward RPZ scrips (section Usage in the above PDF): none seems to be valid anymore.
Access the IPFire device via SSH (or serial console).
I am not sure of your setup so you may want to copy your existing conf files to a backup location. Do a backup of the files located in the /etc/unbound/local.d directory and place them somewhere safe (just incase).
Copy the rpz-1.0.0-1.ipfire file to the /opt/pakfire/tmp/ directory. (Speak up if you need assistance with this!)
Then:
# go to this directory:
cd /opt/pakfire/tmp/
# uncompress the file:
tar xvf rpz-1.0.0-1.ipfire
# check to make sure there are files there:
ls -l /opt/pakfire/tmp
# copy this one file to a new location
cp -v ROOTFILES /opt/pakfire/db/rootfiles/rpz
# run the install
NAME=rpz ./install.sh
PS - please post comments in the Community post. Michael is looking for feedback for RPZ. Feel free to post in this thread.
#load DOH.rpz list from above post
rpz-config add BlockDOH_jpgpi250 https://raw.githubusercontent.com/jpgpi250/piholemanual/master/DOH.rpz
unbound: info: rpz: add config file "BlockDOH_jpgpi250.rpz.conf"
unbound: rpz: running "unbound-control reload"
ok
#Then test one of the DOH servers from that DOH.rpz list
nslookup 2.dnscrypt-cert.browser.yandex.net
Server: 127.0.0.1
Address: 127.0.0.1#53
** server can't find 2.dnscrypt-cert.browser.yandex.net: NXDOMAIN
I’m using @jon’s work now for weeks. No real problems ( which couldn’t solved by jon or myself )
I think the concept of DNS block lists is effective in times of more and more HTTPS URLs. HTTPS is not manageable by the proxy without doing MITM steps.
Therefore PiHole and similiar got more and more importance. RPZ in unbound does the same job and unbound is part of IPFire, yet.
Remark for the careful, which fear about stability:
The RPZ feature is added by some easy config lines in unbound.conf.
A deletion of these lines and unbound-control reload stops it.
RPZ uses mechanisms for name resolution already active in unbound.
I think the DOH servers have a FQDN of doh.opendns.com, f.e.
This FQDN is blocked. opendns.com is the FQDN of the opendns product. This should be accessible, if you want get information about the service.