unbound-control -c /var/unbound/unbound.conf reload
Then: Type crontab -e, press Enter and go to the end of the file (you may have to hit the "End" key on the last line) Press a Press ENTER Type: 0 23 * * * (/usr/share/blocklist/getlist.sh) > /dev/null Press ESC, then : and finally wq!
ee /root/adblockscript
#!/usr/local/bin/bash#Erstelle Temp Dateintmp1="$(mktemp)"tmp2="$(mktemp)"tmp3="$(mktemp)"tmp4="$(mktemp)"tmp5="$(mktemp)"tmp6="$(mktemp)"tmp7="$(mktemp)"file="/var/unbound/adblocklist.conf"# Download Blocklist{ \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/block/master/ultimate/formats/domains.txt; \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/block/master/extensions/xtreme/formats/domains.txt; \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/block/master/extensions/regional/formats/domains.txt; \} > $tmp1# Download Whitelist{ \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/unblock/master/basic/formats/domains.txt; \ cat /root/whitelist; \} > $tmp4# Saeubere die Blocklistensed -i '' -e '/\//d;/:/d;/(/d;/|/d;/\[/d;/\]/d;/#/d;/^$/d;/[\]/d' $tmp1cat $tmp1 | tr -d '\r' >> $tmp2sed -i '' -e 's/ *$//' $tmp2 && sort -uf $tmp2 |tee |uniq -i > $tmp3sed -i '' -e '/^$/d' $tmp3rm $tmp1 $tmp2# Saeubere die Whitelistsed -i '' -e '/\//d;/:/d;/(/d;/|/d;/\[/d;/\]/d;/#/d;/^$/d;/[\]/d' $tmp4cat $tmp4 | tr -d '\r' >> $tmp5sed -i '' -e 's/ *$//' $tmp5 && sort -uf $tmp5 |tee |uniq -i > $tmp6sed -i '' -e '/^$/d' $tmp6rm $tmp4 $tmp5# Fuege Blocklist und Whitelist zusammencomm -23 $tmp3 $tmp6 > $tmp7rm $tmp3 $tmp6sed -i '' -e '/^$/d' $tmp7awk '$0="local-zone: \""$0"\" static"' $tmp7 > $filerm $tmp7if [ "$1" == info ]; then domains=$(awk '!/^#/ && !/^$/{c++}END{print c}' $file | awk '{ len=length($0); res=""; for (i=0;i<=len;i++) { res=substr($0,len-i+1,1) res; if (i > 0 && i < len && i % 3 == 0) { res = "," res } }; print res }') echo "Anzahl zu Blockender Domains = $domains"fi# Aendere Benutzer und Gruppechown unbound:unbound $file# Starte Unbound neupluginctl dnsexit 0
echo '# Domains nach dieser Zeile einfuegen. Diese Zeile nichr loeschen!' > /root/whitelist
ee /usr/local/opnsense/service/conf/actions.d/actions_AdBlock.conf
[reload]command:/root/adblockscriptparameter:type:scriptmessage:Update AdBlocklist and load themdescription:Update AdBlocklist and load them
configctl configd restart
pkg lock -y pkgpkg install bash wgetpkg unlock -y pkg
chmod +x /root/adblockscript
./adblockscript info
curl https://raw.githubusercontent.com/EnergizedProtection/block/master/blu/formats/unbound.conf -o /var/unbound/ad-blacklist.conf
Sinnce https://energized.pro started to publish Unbound-readable blocklists, we should simplify our tutorial to something like this:1. add include: /var/unbound/ad-blacklist.conf into Custom options of Unbound2. Create Ad-blacklist-refresh.sh in /var/unbound with:curl https://raw.githubusercontent.com/EnergizedProtection/block/master/blu/formats/unbound.conf -o /var/unbound/ad-blacklist.conf3. insert a regular execution of this script into crontabThere are multiple levels of compiled lists by energized.pro team - just pick the right strength, let Unbound use it and enjoy ad-free browsing.
#!/usr/local/bin/bash#Erstelle Temp Dateintmp1="$(mktemp)"tmp2="$(mktemp)"tmp3="$(mktemp)"tmp4="$(mktemp)"tmp5="$(mktemp)"tmp6="$(mktemp)"tmp7="$(mktemp)"file="/var/unbound/adblocklist.conf"filebackup="/var/unbound/adblocklist.bck"# Download Blocklist{ \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/block/master/ultimate/formats/domains.txt; \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/block/master/extensions/xtreme/formats/domains.txt; \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/block/master/extensions/regional/formats/domains.txt; \} > $tmp1# Download Whitelist{ \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/unblock/master/basic/formats/domains.txt; \ cat /root/whitelist; \} > $tmp4# Saeubere die Blocklistensed -i '' -e '/\//d;/:/d;/(/d;/|/d;/\[/d;/\]/d;/#/d;/^$/d;/[\]/d' $tmp1cat $tmp1 | tr -d '\r' >> $tmp2sed -i '' -e 's/ *$//' $tmp2 && sort -uf $tmp2 |tee |uniq -i > $tmp3sed -i '' -e '/^$/d' $tmp3rm $tmp1 $tmp2# Saeubere die Whitelistsed -i '' -e '/\//d;/:/d;/(/d;/|/d;/\[/d;/\]/d;/#/d;/^$/d;/[\]/d' $tmp4cat $tmp4 | tr -d '\r' >> $tmp5sed -i '' -e 's/ *$//' $tmp5 && sort -uf $tmp5 |tee |uniq -i > $tmp6sed -i '' -e '/^$/d' $tmp6rm $tmp4 $tmp5# Backup der alten Blocklistif [ -f $file ]; then mv $file $filebackupfi# Fuege Blocklist und Whitelist zusammencomm -23 $tmp3 $tmp6 > $tmp7rm $tmp3 $tmp6sed -i '' -e '/^$/d' $tmp7awk '$0="local-zone: \""$0"\" static"' $tmp7 > $file# Check Unbound Configif ! unbound-checkconf /var/unbound/unbound.conf; then rm $file echo Nutze alte Blockliste mv $filebackup $fileelse# echo Config ist Okey rm $filebackupfiif [ "$1" == info ]; then domains=$(awk '!/^#/ && !/^$/{c++}END{print c}' $file | awk '{ len=length($0); res=""; for (i=0;i<=len;i++) { res=substr($0,len-i+1,1) res; if (i > 0 && i < len && i % 3 == 0) { res = "," res } }; print res }') echo "Anzahl zu Blockender Domains = $domains"fi# Aendere Benutzer und Gruppechown unbound:unbound $file# Starte Unbound neupluginctl dnsexit 0
server:local-zone: "0--ass-cinema-newsp.da.ru" staticlocal-zone: "0--bondage.dk" staticlocal-zone: "0--fightingshaving.da.ru" staticlocal-zone: "0--foodwarez.da.ru" static
if you do not add server: to the start of the first line of .conf file unbound will not start.I only could start Unbound with that: example:Code: [Select]server:local-zone: "0--ass-cinema-newsp.da.ru" staticlocal-zone: "0--bondage.dk" staticlocal-zone: "0--fightingshaving.da.ru" staticlocal-zone: "0--foodwarez.da.ru" staticCheers and thanks for your work and scripts, Working like a charm.
#!/usr/local/bin/bash#Erstelle Temp Dateintmp1="$(mktemp)"tmp2="$(mktemp)"tmp3="$(mktemp)"tmp4="$(mktemp)"tmp5="$(mktemp)"tmp6="$(mktemp)"tmp7="$(mktemp)"file="/var/unbound/adblocklist.conf"filebackup="/var/unbound/adblocklist.bck"whitelist="/root/whitelist"blacklist="/root/blacklist"# Backup der alten Blocklistif [ -f $file ]; then mv $file $filebackupfiif ! [ -f $whitelist ]; then touch $whitelist echo '# Domains nach dieser Zeile einfuegen. Diese Zeile nichr loeschen!' > $whitelistfiif ! [ -f $blacklist ]; then touch $blacklist echo '# Domains nach dieser Zeile einfuegen. Diese Zeile nichr loeschen!' > $blacklistfi# Pruefe Custom White and Blacklist# Download Blocklist{ \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/block/master/ultimate/formats/domains.txt; \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/block/master/extensions/xtreme/formats/domains.txt; \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/block/master/extensions/regional/formats/domains.txt; \ cat $blacklist; \} > $tmp1# Download Whitelist{ \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/unblock/master/basic/formats/domains.txt; \ cat $whitelist; \} > $tmp4# Saeubere die Blocklistensed -i '' -e '/\//d;/:/d;/(/d;/|/d;/\[/d;/\]/d;/#/d;/^$/d;/[\]/d' $tmp1cat $tmp1 | tr -d '\r' >> $tmp2sed -i '' -e 's/ *$//' $tmp2 && sort -uf $tmp2 |tee |uniq -i > $tmp3sed -i '' -e '/^$/d' $tmp3rm $tmp1 $tmp2# Saeubere die Whitelistsed -i '' -e '/\//d;/:/d;/(/d;/|/d;/\[/d;/\]/d;/#/d;/^$/d;/[\]/d' $tmp4cat $tmp4 | tr -d '\r' >> $tmp5sed -i '' -e 's/ *$//' $tmp5 && sort -uf $tmp5 |tee |uniq -i > $tmp6sed -i '' -e '/^$/d' $tmp6rm $tmp4 $tmp5# Fuege Blocklist und Whitelist zusammencomm -23 $tmp3 $tmp6 > $tmp7rm $tmp3 $tmp6sed -i '' -e '/^$/d' $tmp7awk '$0="local-zone: \""$0"\" static"' $tmp7 > $file# Check Unbound Configif ! unbound-checkconf /var/unbound/unbound.conf; then rm $file echo Nutze alte Blockliste mv $filebackup $file exit 1else# echo Config ist Okey if ! grep -cq "include: $file" /var/unbound/unbound.conf; then echo Please add "include: $file" to your custom Unbound settings. rm $filebackup fifiif [ "$1" == info ]; then domains=$(awk '!/^#/ && !/^$/{c++}END{print c}' $file | awk '{ len=length($0); res=""; for (i=0;i<=len;i++) { res=substr($0,len-i+1,1) res; if (i > 0 && i < len && i % 3 == 0) { res = "," res } }; print res }') echo "Anzahl zu Blockender Domains = $domains"fi# Aendere Benutzer und Gruppechown unbound:unbound $file# Starte Unbound neupluginctl dns
[1580222648] unbound-checkconf[27733:0] error: cannot parse name queda212..duckdns.org[1580222648] unbound-checkconf[27733:0] error: bad zone name queda212..duckdns.org static[1580222648] unbound-checkconf[27733:0] fatal error: failed local-zone, local-data configuration
#!/usr/local/bin/basholdtmp="$(find /tmp -type f -name 'tmp.*' | wc -l)" if [ $oldtmp -gt 0 ]; then echo Found $oldtmp old tmp-files. echo Delete the old Files find /tmp -type f -name 'tmp.*' -exec rm -f {} \; fi#Erstelle Temp Dateintmp1="$(mktemp)"tmp2="$(mktemp)"tmp3="$(mktemp)"tmp4="$(mktemp)"tmp5="$(mktemp)"tmp6="$(mktemp)"tmp7="$(mktemp)"file="/var/unbound/adblocklist.conf"filebackup="/var/unbound/adblocklist.bck"whitelist="/root/whitelist"blacklist="/root/blacklist"actionfile="/usr/local/opnsense/service/conf/actions.d/actions_AdBlock.conf"# Backup der alten Blocklistif [ -f $file ]; then mv $file $filebackupelse touch $filebackup echo '# Empty File' > $filebackupfi# Pruefe Custom White and Blacklistif ! [ -f $whitelist ]; then touch $whitelist echo '# Domains nach dieser Zeile einfuegen. Diese Zeile nicht loeschen!' > $whitelistfiif ! [ -f $blacklist ]; then touch $blacklist echo '# Domains nach dieser Zeile einfuegen. Diese Zeile nicht loeschen!' > $blacklistfi# Pruefe und Erstelle Actionfile fuer Cronif ! [ -f $actionfile ]; then touch $actionfile printf "[reload]\ncommand:/root/adblockscript\nparameter:\ntype:script\nmessage:Update AdBlocklist and load them\ndescription:Update AdBlocklist and load them" >> $actionfile service configd restart echo 'Now you can configure the Cron Job via Web Interface'fi# Download Blocklist{ \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/block/master/ultimate/formats/domains.txt; \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/block/master/extensions/xtreme/formats/domains.txt; \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/block/master/extensions/regional/formats/domains.txt; \ cat $blacklist; \} > $tmp1# Download Whitelist{ \ wget -qO- https://raw.githubusercontent.com/EnergizedProtection/unblock/master/basic/formats/domains.txt; \ cat $whitelist; \} > $tmp4# Saeubere die Blocklistensed -i '' -e '/\//d;/:/d;/(/d;/|/d;/\[/d;/\]/d;/#/d;/^$/d;/[\]/d' $tmp1cat $tmp1 | sed -r 's/\.+/\./' | tr -d '\r' >> $tmp2sed -i '' -e 's/ *$//' $tmp2 && sort -uf $tmp2 |tee |uniq -i > $tmp3sed -i '' -e '/^$/d' $tmp3rm $tmp1 $tmp2# Saeubere die Whitelistsed -i '' -e '/\//d;/:/d;/(/d;/|/d;/\[/d;/\]/d;/#/d;/^$/d;/[\]/d' $tmp4cat $tmp4 | sed -r 's/\.+/\./' | tr -d '\r' >> $tmp5sed -i '' -e 's/ *$//' $tmp5 && sort -uf $tmp5 |tee |uniq -i > $tmp6sed -i '' -e '/^$/d' $tmp6rm $tmp4 $tmp5# Fuege Blocklist und Whitelist zusammencomm -23 $tmp3 $tmp6 > $tmp7rm $tmp3 $tmp6sed -i '' -e '/^$/d' $tmp7awk '$0="local-zone: \""$0"\" static"' $tmp7 > $filerm $tmp7# Check Unbound Configif ! unbound-checkconf /var/unbound/unbound.conf; then rm $file echo Nutze alte Blockliste mv $filebackup $file exit 1else# echo Config ist Okey if ! grep -cq "include: $file" /var/unbound/unbound.conf; then echo Please add "include: $file" to your custom Unbound settings. fi rm $filebackupfiif [ "$1" == info ]; then domains=$(awk '!/^#/ && !/^$/{c++}END{print c}' $file | awk '{ len=length($0); res=""; for (i=0;i<=len;i++) { res=substr($0,len-i+1,1) res; if (i > 0 && i < len && i % 3 == 0) { res = "," res } }; print res }') echo "Anzahl zu Blockender Domains = $domains"fi# Aendere Benutzer und Gruppechown unbound:unbound $file# Starte Unbound neupluginctl dnsexit 0
Is this tutorial sill valid?I've just installed the unbound-plus plugin and selected which block list use. Did I go wrong?
Is there a way to have a dashboard and a detailed log to have an idea on what's been blocked?