this is what i did
block quote
First File: /etc/firewall.user (Make a copy of the file before editing)
Add this 2 lines:
iptables -t nat -I PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53
iptables -t nat -I PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53
block quote end
Add these lines to the bottom of the file away from everything else if you have anything already in there
4)
phuque99 wrote:
block quote
Add the following line into /etc/config/dhcp, under the section "config dnsmasq":
block quote end
(modified to make it permanent on reboot)
list addnhosts '/etc/block.hosts'
5)Create the file /etc/adblock.sh and copy and paste this into it (modified version of phuque99's script)
#Script to grab and sort a list of adservers and malware
#Delete the old block.hosts to make room for the updates
rm -f /etc/block.hosts
#Download and process the files needed to make the lists
wget -qO-
http://www.mvps.org/winhelp2002/hosts.txt|grep "^127.0.0.1" > /tmp/block.build.list
wget -qO-
http://www.malwaredomainlist.com/hostsl ... s.txt|grep "^127.0.0.1" >> /tmp/block.build.list
wget -qO-
http://updates.it-mate.co.uk/hphosts/ad ... s.asp|grep "^127.0.0.1" >> /tmp/block.build.list
#Sort the lists
sort /tmp/block.build.list|uniq -u >/tmp/block.sorted
#Remove the carriage return ^M on windows created files
sed -e 's/\r//g' /tmp/block.sorted > /etc/block.hosts
#Delete files used to build list to free up the limited space
rm -f /tmp/block.sorted
rm -f /tmp/block.build.list
#Restart dnsmasq
/etc/init.d/dnsmasq restart
exit 0
This script automates the whole process and if you read the remarks you'll see how it works. It also tidies up after itself to save space. If you wish
to add more host file sources the format is:
wget -qO- <http: online source here minus the <> >|grep "^127.0.0.1" >> /tmp/block.build.list
6) From the command line type
chmod +x /etc/adblock.sh
7) To generate the file for the first time and make sure you have no errors type in
sh /etc/adblock.sh
If you find errors make sure you've copied and pasted everything correctly and so on.
8) Two ways to schedule this so I'm going to show the easy way from luci:
a) Go to System>Scheduled Tasks.
b)Copy and paste the following into it then click on Submit on the bottom
00 4 * * 0,3 sh /etc/adblock.sh
This automates the updates of your block.hosts to be run by cron every Sunday and Wednesday at 4am which should be plenty enough for most needs.
I used winSCP to edit my files and i put the cron rule in cron root