Hi everyone,
First post here so bare with me.
This builds on thelonelycoder's script for host based domain blocking. The main difference is a customizable HTML or 1x1 transparent GIF file will resolve and replace the blocked section of the page, instead of a 404-type message. This is essentially emulating pixelserv if you use a GIF file.
Prerequisites:
- Merlin's latest firmware
- Entware installed
- USB drive formatted to EXT2 (I used EASEUS Partition Master for Windows)
- Running thelonelycoder's script
For these instructions, I'm going to use 192.168.0.1 as my router's IP address. Replace with your router's IP as necessary.
FIRST STEP: Freeing port 80 on the router
1. Login to the your router via web browser
2. Go to Administration > System
- Enabled SSH > Checked to Yes (if not already done)
- Authentication Method > Change to HTTPS
- HTTPS Lan port > 8443
3. Click Apply
4. Verify you are able to login to your router by going to https://192.168.0.1:8443
5. Depending on the browser, it will give you a security warning, simply bypass or add the address to the exceptions list. There's also a possibility that you will get a long message that the IP/port has changed and will not let you login. Do not panic. Firefox or Chrome has enabled offline cache, you can simply turn that off (just do a search) or use Internet Explorer.
SECOND STEP: Modifying the hosts.clean file to route to 192.168.0.1
1. Login to the route via WinSCP > browse to /jffs/configs/ > right-click, edit dnsmasq.conf.add with changes:
remove this line as modifying it doesn't do anything:
and ensure this shows as the first line:
click the save icon
2. Browse to /jffs/scripts/ > right-click, edit post-mount file > copy and paste the code below:
click the save icon
3. In the same directory > right -click, edit update-hosts.sh file > copy and paste the code below:
click the save icon
THIRD STEP: Install and configure Lighttpd
1. Login to the router via PuTTY and enter the following commands:
2. Login to the router via WinSCP > browse to /opt/etc/lighttpd/ > right-click, edit lighttpd.conf with changes:
between the parenthesis of server.modules, add "mod_redirect" so it looks like:
change server.port from 81 to 80
comment out server.bind by adding # in front
change server.document-root path to /mnt/sda1 where sda1 is the name of your USB stick
modify line to:
add new line:
click the save icon
3. Optional: the url.redirect is essentially a regex that redirects any blocked URL to /index.html. Once it reaches /index.html, it will stop redirecting. You can change index.html to blank.gif (for example) by replacing all instances of index with blank and all instance of html with gif for the url.redirect line only.
4. Browse to /mnt/sda1/ and upload a simple index.html or blank.gif file. Ensure this file matches entries on lighttpd.conf
5. Go back to PuTTY and type reboot or click Reboot button from the browser.
6. Use a device connected to the router via WiFi or LAN port and browse to adchimp dot com and see if it redirects to your index.html or blank.gif file.
DONE!
First post here so bare with me.
This builds on thelonelycoder's script for host based domain blocking. The main difference is a customizable HTML or 1x1 transparent GIF file will resolve and replace the blocked section of the page, instead of a 404-type message. This is essentially emulating pixelserv if you use a GIF file.
Prerequisites:
- Merlin's latest firmware
- Entware installed
- USB drive formatted to EXT2 (I used EASEUS Partition Master for Windows)
- Running thelonelycoder's script
For these instructions, I'm going to use 192.168.0.1 as my router's IP address. Replace with your router's IP as necessary.
FIRST STEP: Freeing port 80 on the router
1. Login to the your router via web browser
2. Go to Administration > System
- Enabled SSH > Checked to Yes (if not already done)
- Authentication Method > Change to HTTPS
- HTTPS Lan port > 8443
3. Click Apply
4. Verify you are able to login to your router by going to https://192.168.0.1:8443
5. Depending on the browser, it will give you a security warning, simply bypass or add the address to the exceptions list. There's also a possibility that you will get a long message that the IP/port has changed and will not let you login. Do not panic. Firefox or Chrome has enabled offline cache, you can simply turn that off (just do a search) or use Internet Explorer.
SECOND STEP: Modifying the hosts.clean file to route to 192.168.0.1
1. Login to the route via WinSCP > browse to /jffs/configs/ > right-click, edit dnsmasq.conf.add with changes:
remove this line as modifying it doesn't do anything:
Code:
address=/0.0.0.0/0.0.0.0
Code:
addn-hosts=/tmp/mnt/sda1/hosts.clean
2. Browse to /jffs/scripts/ > right-click, edit post-mount file > copy and paste the code below:
Code:
#!/bin/sh
if [ $1 = "/tmp/mnt/SD2" ]
then
ln -sf $1/entware /tmp/opt
fi
sleep 12
wget -qO- "http://winhelp2002.mvps.org/hosts.txt" "http://someonewhocares.org/hosts/zero/hosts" "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&startdate[day]=&startdate[month]=&startdate[year]=&mimetype=plaintext&useip=0.0.0.0" | grep -w ^0.0.0.0 | sed $'s/\r$//;s/0.0.0.0/192.168.0.1/' | sort -u > /tmp/mnt/sda1/hosts.clean
sleep 5
service restart_dnsmasq
click the save icon
3. In the same directory > right -click, edit update-hosts.sh file > copy and paste the code below:
Code:
#!/bin/sh
wget -qO- "http://winhelp2002.mvps.org/hosts.txt" "http://someonewhocares.org/hosts/zero/hosts" "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&startdate[day]=&startdate[month]=&startdate[year]=&mimetype=plaintext&useip=0.0.0.0" | grep -w ^0.0.0.0 | sed $'s/\r$//;s/0.0.0.0/192.168.0.1/' | sort -u > /tmp/mnt/sda1/hosts.clean
sleep 5
service restart_dnsmasq
click the save icon
THIRD STEP: Install and configure Lighttpd
1. Login to the router via PuTTY and enter the following commands:
Code:
opkg install lighttpd
opkg install lighttpd-mod-redirect
/opt/etc/init.d/lighttpd stop
2. Login to the router via WinSCP > browse to /opt/etc/lighttpd/ > right-click, edit lighttpd.conf with changes:
between the parenthesis of server.modules, add "mod_redirect" so it looks like:
Code:
server.modules = ( "mod_redirect" )
Code:
server.port = 80
Code:
#server.bind = "0.0.0.0"
Code:
server.document-root = "/mnt/sda1"
Code:
index-file.names = ( "index.html" )
Code:
url.redirect = ( "^(.*?)(?<!\/index\.html)$" => "/index.html" )
3. Optional: the url.redirect is essentially a regex that redirects any blocked URL to /index.html. Once it reaches /index.html, it will stop redirecting. You can change index.html to blank.gif (for example) by replacing all instances of index with blank and all instance of html with gif for the url.redirect line only.
Code:
url.redirect = ( "^(.*?)(?<!\/blank\.gif)$" => "/blank.gif" )
4. Browse to /mnt/sda1/ and upload a simple index.html or blank.gif file. Ensure this file matches entries on lighttpd.conf
5. Go back to PuTTY and type reboot or click Reboot button from the browser.
6. Use a device connected to the router via WiFi or LAN port and browse to adchimp dot com and see if it redirects to your index.html or blank.gif file.
DONE!
Last edited: