For Tomato Firmware users:
1) Goto Administration>Scheduler. In the 'Custom 1' box, setup a time you want the router to update the hostfile (preferably once per week. I use Sunday at 4am). Check Enabled, select time and days.
2) Paste the following into the 'command box':
Code:
xyz=allowlist;hij=adblock.tmp;abc=dnsmasq_adblock.conf;tip=192.168.1.1;wget -q -O /tmp/$abc 'http://pgl.yoyo.org/adservers/serverlist.php?hostformat=dnsmasq&showintro=0&mimetype=plaintext';[ -f /tmp/$xyz ] && (cat /tmp/$abc | grep -v -f /tmp/$xyz>>/tmp/$hij; mv -f /tmp/$hij /tmp/$abc);[ $? -eq 0 -a `grep ^address= /tmp/$abc|wc -l` -gt 0 ] && (logger -t adblock -p 5 Server download OK;cat /tmp/$abc|sed 's/127.0.0.1/'$tip'/g'>/etc/$abc;[ ! -s /cifs1 ] && mv -f /tmp/$abc /cifs1/$abc.bak || rm /tmp/$abc;[ -h /etc/dnsmasq.custom ] && service dnsmasq restart) || (logger -t adblock -p 4 Server download failed;[ ! -s /etc/$abc -a -s /cifs1/$abc.bak ] && (logger -t adblock -p 5 Data recovered from backup;cat /cifs1/$abc.bak|sed 's/127.0.0.1/'$tip'/g'>/etc/$abc;[ -h /etc/dnsmasq.custom ] && service dnsmasq restart));unset xyz hij abc tip
3) Click 'Save' at the bottom of the page.
4) Now goto Administration>Scripts. Click on the 'Init' tab if it's not already selected, and paste the following code into it and click 'Save'. NOTE: You can add as many 'echo' lines as you like to remove those hostnames from the blocked hostname list. I added Google Analytics because it stalls a lot of pages from loading if they use it.
Code:
echo "google-analytics">/tmp/allowlist
echo "ssl.google-analytics.com">>/tmp/allowlist
[ ! -f /tmp/dnsmasq.chk ] && (ln -s /etc/dnsmasq_adblock.conf /etc/dnsmasq.custom;touch /tmp/dnsmasq.chk)
5) Click on the 'WAN Up' tab at the top. Paste the following code into it, and click 'Save':
Code:
[ ! -f /etc/dnsmasq_adblock.conf ] && eval `nvram get sch_c1_cmd`
ps | grep [p]ixelserv
if [ $? == 1 ]; then
wget -P /var http://pixelserv.webs.com/pixelserv
chmod +x /var/pixelserv
/var/pixelserv
fi
6) Goto 'Administration>Admin Access' and change 'Local Access' to HTTPS only (so the pixelserv server can run on port 80) and enter a port to run the router webserver on - I used 8080. Click 'Save' at the bottom.
7) Reboot router and if all went all, advertisements will be blocked on 99% of all websites and will be replaced with a 1x1 pixel transparent image - no red X's or boxes where the ads would normally be located.
I believe that's all the steps. At least all that I can remember from setting it up. If anyone tries this and it does/doesn't work, be sure to let me know. One thing to note is I just made the webs account to host the pixelserv - not sure how reliable they are, but I think it should be ok. The pixelserv binary is downloaded everytime the router is rebooted and is only 10kb.