Der Anwendungsfall: Eine Linux/Iptables Firewall hinter dem Provider-Router und Pihole um Werbung zu filtern. Da kann man DoH brauchen wie ein Loch im Knie...
Klar, die Listen die jetzt jemand, den man nicht kennt, auf Github veröffentlicht mögen fehlerhaft und/oder unvollständig sein und wer will kann immer noch einen bisher unbekannten Server manuell konfigurieren. Aber fürs erste geht das mal.
Getestet unter Debian und Ubuntu. Benötigte Pakete:
#!/bin/bash
# create blacklist ipset to block dns over https requests
# run frequently (daily/weekly) using cron
#
# list is from https://github.com/oneoffdallas/dohservers
# you may also use https://github.com/curl/curl/wiki/DNS-over-HTTPS
# but the scrape script needs some modification to provide a usable list of hosts
#
# dj0Nz 07/2020
ipset -q create doh hash:ip
ipset flush doh
output=/tmp/doh.list
if [ -f $output ]; then
rm $output
fi
wget -q https://raw.githubusercontent.com/oneoffdallas/dohservers/master/iplist.txt -O $output
sed -i 's/#.*$//;/^$/d' $output
while read -r line
do
ipset -q add doh $line
done < $output
# additional:
ipset -q add doh 1.1.1.1
ipset -q add doh 1.0.0.1
ipset -q add doh 1.1.1.2
ipset -q add doh 1.0.0.2
ipset -q add doh 1.1.1.3
ipset -q add doh 1.0.0.3
Und der notwendige Abschnitt aus ferm.conf:
# Block DoH to known public servers
mod set set doh dst proto tcp dport 443 {
LOG log-prefix "[Firewall] DoH Block: ";
REJECT;
}
Praktische Anwendung siehe rpf. Generell zum Thema ferm und ipset hab ich hier eine Anleitung.