So I was asked to write up what I have done in the last day or two. If this has been covered. I apologize.
Purpose: To block ads from all computers on the network at the router using the MVPS Custom Host file.
Requirements:
- You should have the Merlin Firmware with /jffs/ mounted. (I also used some space on an attached flash drive, but with ~7mb of usable space on /jffs, this probably isn't needed.)
- Custom /jffs/scripts/init-start
- Custom /jffs/configs/hosts
- I will assume you know/understand basic linux commands
- I will assume you know/understand what a host file does
Summary: After I have setup this up, the following happens:
- Upon boot, the router creates a CRONjob
- While still booting, the Merlin Firmware copies entries from /jffs/configs/hosts to /etc/hosts
- DNSMasq will read /etc/hosts and block all known ad servers
- At the specified time the cronjob from above will poll mvps.org, and download the newest host file to /jffs/configs/hosts
- When the router reboots, it will pull latest /jffs/configs/hosts to /etc/hosts
Process:
A) Create cronjob at boot
1) In order to create the cronjob, I created /jffs/scripts/init-start, and I have added the following to the file:
This adds a cron job with the following formatting:
cru a <unique id> <"min hour day month week command">
I found it best to use @daily, or @midnight, or @weekly, rather than the stanard time format. I had issues scheduling it if i used the standard cronjob syntax.
After the router reboots, any cronjobs are lost. However since we are placing this 'script' in the init-start file, the Merlin firmware will recreate this cronjob at every reboot.
That is it, however for since the /jffs/configs/hosts file is currently empty, if you want to 'jump start' this process I would also do the following:
This will populate the /jffs/configs/hosts file, and will restart the dnsmasq service, to reload the host file. I would also run the following on your local windows machine:
This will cause your local machine to quary your DNS server (router) rather than using a local cache.
Please understand the effects of this, No not all ads will be blocked, Yes there may be some negitive effects, for example Hulu.com will offten run a 30-60sec black screen if it cant load an ad.
Please feel free to ask any questions, and I am sorry for any babbling above
---------------------------------------
Side note:
You could also add the following to your init-start file
This will restart your DNSMasq service every night at midnight, thereby loading the new host file. However I my router gets rebooted once a month or more, so I am not that worried about it.
Purpose: To block ads from all computers on the network at the router using the MVPS Custom Host file.
Requirements:
- You should have the Merlin Firmware with /jffs/ mounted. (I also used some space on an attached flash drive, but with ~7mb of usable space on /jffs, this probably isn't needed.)
- Custom /jffs/scripts/init-start
- Custom /jffs/configs/hosts
- I will assume you know/understand basic linux commands
- I will assume you know/understand what a host file does
Summary: After I have setup this up, the following happens:
- Upon boot, the router creates a CRONjob
- While still booting, the Merlin Firmware copies entries from /jffs/configs/hosts to /etc/hosts
- DNSMasq will read /etc/hosts and block all known ad servers
- At the specified time the cronjob from above will poll mvps.org, and download the newest host file to /jffs/configs/hosts
- When the router reboots, it will pull latest /jffs/configs/hosts to /etc/hosts
Process:
A) Create cronjob at boot
1) In order to create the cronjob, I created /jffs/scripts/init-start, and I have added the following to the file:
[strike]
#!/bin/sh
cru a 1001 @midnight wget http://winhelp2002.mvps.org/hosts.txt -O /jffs/configs/hosts
[/strike]
PLEASE SEE POST 8 BELOW
This adds a cron job with the following formatting:
cru a <unique id> <"min hour day month week command">
I found it best to use @daily, or @midnight, or @weekly, rather than the stanard time format. I had issues scheduling it if i used the standard cronjob syntax.
After the router reboots, any cronjobs are lost. However since we are placing this 'script' in the init-start file, the Merlin firmware will recreate this cronjob at every reboot.
That is it, however for since the /jffs/configs/hosts file is currently empty, if you want to 'jump start' this process I would also do the following:
This will populate the /jffs/configs/hosts file, and will restart the dnsmasq service, to reload the host file. I would also run the following on your local windows machine:
ipconfig /flushdns
This will cause your local machine to quary your DNS server (router) rather than using a local cache.
Please understand the effects of this, No not all ads will be blocked, Yes there may be some negitive effects, for example Hulu.com will offten run a 30-60sec black screen if it cant load an ad.
Please feel free to ask any questions, and I am sorry for any babbling above
---------------------------------------
Side note:
You could also add the following to your init-start file
#!/bin/sh
cru a 1001 @midnight wget http://winhelp2002.mvps.org/hosts.txt -O /jffs/configs/hosts
sleep 5
killall dnsmasq
dnsmasq
This will restart your DNSMasq service every night at midnight, thereby loading the new host file. However I my router gets rebooted once a month or more, so I am not that worried about it.
Last edited: