Skip to content

Unbound - Werbeblocker

Linux
  • Den Unbound DNS-Server kann man auch prima als Werbeblocker benutzen.

    Screenshot_20190729-201229.png

    /usr/bin/wget -N https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
    /usr/bin/wget -N https://download.dnscrypt.info/blacklists/domains/mybase.txt
    /usr/bin/wget -N https://raw.githubusercontent.com/anudeepND/whitelist/master/domains/whitelist.txt
    cat hosts | grep '^0\.0\.0\.0' | awk '{print $2}' > block
    sed '/#/d; /*/d; /^$/d; /^\./d' mybase.txt > mybase
    cat block mybase | sort -u > merged
    touch /home/heat/mywhitelist
    cat whitelist.txt /home/heat/mywhitelist | sort -u > whitelist
    comm -23 merged whitelist > merged_corr
    awk '{print "local-zone: \""$1"\" refuse"}' merged_corr > /etc/unbound/unbound.conf.d/blocklist.conf
    

    Das Script ist leicht angepasst.

    Quelle des Scriptes: https://www.wilderssecurity.com/threads/adblocking-with-unbound.406346/

    Aktuell auf dem Server in der Testphase 🙂

    Links

  • Als Script

    #!/bin/bash
    ###############################################################################$
    #
    ###############################################################################$
    cd /Verzeichnis
    /usr/bin/wget -N https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
    /usr/bin/wget -N https://download.dnscrypt.info/blacklists/domains/mybase.txt
    /usr/bin/wget -N https://raw.githubusercontent.com/anudeepND/whitelist/master/domains/whitelist.txt
    cat hosts | grep '^0\.0\.0\.0' | awk '{print $2}' > block
    sed '/#/d; /*/d; /^$/d; /^\./d' mybase.txt > mybase
    cat block mybase | sort -u > merged
    touch /root/blocklist/mywhitelist
    cat whitelist.txt /root/blocklist/mywhitelist | sort -u > whitelist
    comm -23 merged whitelist > merged_corr
    awk '{print "local-zone: \""$1"\" refuse"}' merged_corr > /etc/unbound/unbound.conf.d/blocklist.conf
    sed -i '1s/.*$/server:\n&/g' /etc/unbound/unbound.conf.d/blocklist.conf
    service unbound restart