Pi-hole vs. Adblock Settings in FreshTomato

Discussion in 'Tomato Firmware' started by P2q000, Feb 2, 2019.

  1. P2q000

    P2q000 Network Newbie Member

    Hi

    I hate Ads. I already block ads with Adblock Settings in FreshTomato.
    Is there any benefit if I use additionally Pi-hole? Or no need to use Pi-hole because FreshTomato already does it?

    Cheers
     

    Attached Files:

  2. AndreDVJ

    AndreDVJ LI Guru Member

    I don't see further benefit, and you should choose either Pi-hole or built-in Adblock.

    From my understanding, both use the same method. The backbone is a blocklist for Dnsmasq.

    The client software will make a query to the DNS server on the network, and if a domain is found on the blocklist, it'll be blocked (i.e. won't go through WAN).

    The difference in the end (again from my understanding), is that Pi-hole is an appliance with plenty of configuration options, while what's offered in Tomato is pretty much barebones.

    I personally use this script instead, because of pixelserv (though I adapted to use pixelserv-tls - can't see benefits though).
     
  3. The Master

    The Master Network Guru Member

    Hello AndreDVJ,
    is it possible that you write a little how to with the Script AND the pixelserv-tls.
    Or maybe somebody could update the Build in AdBlocker with the better script :) *dreaming*
     
  4. rgnldo

    rgnldo Networkin' Nut Member

    The DNS blocking solution is an improvisation without the least security quality. It's like @AndreDVJ, they're old dragons. I have adapted a more organized solution from Adblock Pixelserv-tls.
    Code:
    #!/bin/bash
    # Address to send ads to. This could possibily be removed, but may be useful for 
    debugging purposes?
    
    destinationIP="192.168.1.3" # IP Pixelserv-tls
    permlist='/jffs/pattern.txt'
    outlist='/jffs/blocklist.txt'
    finalist='/jffs/domain.txt'
    tempoutlist="$outlist.tmp"
    
    echo "Remove old entries..."
    [ -f /jffs/blocklist.txt.tmp ] && rm -f /jffs/blocklist.txt.tmp
    
    echo "Download yoyo ad list..."
    curl -s -d mimetype=plaintext -d hostformat=unixhosts http://pgl.yoyo.org/adservers/serverlist.php? | sort > $tempoutlist
    echo "Download winhelp2002 ad list..."
    curl -s http://winhelp2002.mvps.org/hosts.txt | grep -v "#" | grep -v "127.0.0.1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | sort >> $tempoutlist
    echo "Download Zeustracker ad list..."
    curl -s https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download Adblock-nocoin ad list..."
    curl -s https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/hosts.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download Adway ad list..."
    curl -s https://adaway.org/hosts.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download malwaredomainlist ad list..."
    curl -s http://www.malwaredomainlist.com/hostslist/hosts.txt | grep -v "#" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $3}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download adblock.gjtech ad list..."
    curl -s http://adblock.gjtech.net/?format=unix-hosts | grep -v "#" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download Disconnect simple_tracking ad lista..."
    curl -s https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt | grep -v "#" | sed '/^$/d' | sed 's/\ /\\ /g' | grep -v '^\\' | grep -v '\\$' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download Disconnect simple_ad ad list...."
    curl -s https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download Someonewhocares ad list..."
    curl -s http://someonewhocares.org/hosts/hosts | grep -v "#" | sed '/^$/d' | sed 's/\ /\\ /g' | grep -v '^\\' | grep -v '\\$' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download hosts-file ad list..."
    curl -s http://hosts-file.net/ad_servers.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download add.2o7Net ad list..."
    curl -s https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.2o7Net/hosts | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download Badd-Boyz-Hosts ad list..."
    curl -s https://raw.githubusercontent.com/mitchellkrogza/Badd-Boyz-Hosts/master/hosts | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download KADhosts ad list..."
    curl -s https://raw.githubusercontent.com/azet12/KADhosts/master/KADhosts.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download Ransomwaretracker ad list..."
    curl -s https://ransomwaretracker.abuse.ch/downloads/RW_DOMBL.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download CoinBlocker ad list..."
    curl -s https://zerodot1.gitlab.io/CoinBlockerLists/hosts_browser | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download Immortal_domains ad lista..."
    curl -s http://mirror1.malwaredomains.com/files/immortal_domains.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download Piwik ad list..."
    curl -s https://raw.githubusercontent.com/piwik/referrer-spam-blacklist/master/spammers.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download Mitchellkrogza ad list..."
    curl -s https://raw.githubusercontent.com/mitchellkrogza/The-Big-List-of-Hacked-Malware-Web-Sites/master/.dev-tools/output/domains/ACTIVE/list | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    #echo "Download Lightswitch05 ad list..."
    #curl -s https://raw.githubusercontent.com/lightswitch05/hosts/master/ads-and-tracking-extended.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    echo "Download WindowsSpyBlocker ad list..."
    curl -s https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt | grep -v "#" | grep -v "::1" | sed '/^$/d' | sed 's/\ /\\ /g' | awk '{print $2}' | grep -v '^\\' | grep -v '\\$' | sort >> $tempoutlist
    
    echo "Removing duplicate formatting in the domains list..."
    
    cat $tempoutlist | sed $'s/\r$//' | sed '/thisisiafakedomain123\.com/d;/www\.anotherfakedomain123\.com/d' | sort -u | sed '/^$/d' | awk -v "IP=$destinationIP" '{sub(/\r$/,""); print IP" "$0}' > $outlist
    
    echo "Edit whitelist domains..."
    
    fgrep -vf $permlist $outlist > $finalist
    
    # Count how many domains/whitelists were added so it can be displayed to the user
    
    numberOfAdsBlocked=$(cat $finalist | wc -l | sed 's/^[ \t]*//')
    echo "$numberOfAdsBlocked domains blockers."
    
    echo "Removing temporary files..."
    
    rm $tempoutlist
    
    echo "Reload servers..."
    /opt/etc/init.d/S80pixelserv-tls restart
    service dnsmasq restart
    
     
    Last edited: Feb 5, 2019
  5. AndreDVJ

    AndreDVJ LI Guru Member

    Well I'll provide what I use: https://pastebin.com/ryaUTJvt

    The main differences are that I use pixelserv-tls and logger from Entware to mute logging. Anything else is cosmetics.
     
    rgnldo likes this.
  6. rgnldo

    rgnldo Networkin' Nut Member

    I use Pixelserv-tls from @kvic. I have the report too. Be curious about the Adblock report. I just do not understand your script @AndreDVJ

    I intend to take advantage of the @Kvic binary and get my adblock's gui, which is in /jffs/scripts
    [​IMG]
     
  7. AndreDVJ

    AndreDVJ LI Guru Member

    It's essentially my personal modification of this one: https://www.linksysinfo.org/index.php?threads/script-adblock-not-so-lean.72290/

    That script from jerrm is essentially run and forget, but it's a very complex one. Even I don't understand completely (actually I only took time to understand what I wanted to change).

    If I have any issues, is with Dnsmasq acting up, which I need to run sort of a watchdog among my "housekeeping" scripts to restart adblock, in case of domains that's supposed to be blocked are no longer resolved to pixelserv's IP address:

    Code:
    checkadblock() {
            if ps | grep -v grep | grep pixelserv > /dev/null; then
                PIXELSERV_IP=$(netstat -lpn | grep pixelserv | awk '{print $4}' | sed "s/\:.*//" | sort -u)
                HOSTNAME=$(cat /var/lib/adblock/blocklist | grep "address=/" | grep -v "\.\/" | tail -1 | sed -r "s/address=\///" | sed -r "s/\/$PIXELSERV_IP//")
                if ! /usr/bin/nslookup $HOSTNAME | grep $PIXELSERV_IP > /dev/null; then
                    logger -t "checkwan[$$]" "Dnsmasq is not resolving hostnames from /var/lib/adblock/blocklist to pixelserv's IP address. Restarting Adblock..."
                    /opt/bin/adblock.sh restart
                fi
            fi
    }
    About the GUI, it has a way to integrate with TomatoGUI, but I never bothered with looking into adapting to AT GUI (because I run and forget, I don't want to keep managing my routers anymore).
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice