What's new

I can't block ADs with MVPS Host File

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

decedion

Occasional Visitor
I have followed the guide in Blocking ADs with MVPS Host File but it doesn't work for me.
I have done the "Improve Your Web Surfing Speed with OpenDNS" how-to too.
And then I have added:
Code:
wget -qO- http://winhelp2002.mvps.org/hosts.txt | grep -w ^0.0.0.0 | sed $'s/\r$//' | sort -u >> /etc/hosts

The wan-script is this:
Code:
#!/bin/sh

# Wait up to 15 seconds to make sure /opt partition is mounted
i=0
while [ $i -le 15 ]
do
    if [ -d /opt/tmp ]
    then
        break
    fi
    sleep 1
    i=`expr $i + 1`
done

# Now resolve DNS name for NTP server
ntp_name=$(nvram get ntp_server0)
grep "$ntp_name" /etc/hosts > /dev/null 2>&1 || \
for ip in $(/opt/sbin/dnscrypt-proxy-hostip $ntp_name)
do
    echo $ip $ntp_name >>  /etc/hosts
done

wget -qO- http://winhelp2002.mvps.org/hosts.txt | grep -w ^0.0.0.0 | sed $'s/\r$//' | sort -u >> /etc/hosts

# and restart NTP client to eliminate 4-5 mins delay
killall ntp && sleep 1
service restart_ntpc

But it only works in router! :confused:
I have tested with this url.
In router:
Code:
# ping -c 3 fr.a2dfp.net
PING fr.a2dfp.net (0.0.0.0): 56 data bytes
64 bytes from 127.0.0.1: seq=0 ttl=64 time=0.396 ms
64 bytes from 127.0.0.1: seq=1 ttl=64 time=0.255 ms
64 bytes from 127.0.0.1: seq=2 ttl=64 time=0.243 ms

--- fr.a2dfp.net ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.243/0.298/0.396 ms

In my PC:
Code:
$ ping -c 3 fr.a2dfp.net
PING fr.a2dfp.net (85.116.37.142) 56(84) bytes of data.
64 bytes from 85.116.37.142: icmp_seq=1 ttl=51 time=48.5 ms
64 bytes from 85.116.37.142: icmp_seq=2 ttl=52 time=42.9 ms
64 bytes from 85.116.37.142: icmp_seq=3 ttl=52 time=44.4 ms

--- fr.a2dfp.net ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 10197ms
rtt min/avg/max/mdev = 42.953/45.320/48.585/2.391 ms

The dig's output:
Code:
$ dig fr.a2dfp.net

; <<>> DiG 9.9.3-rpz2+rl.13214.22-P2-Ubuntu-1:9.9.3.dfsg.P2-4ubuntu1.1 <<>> fr.a2dfp.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 24073
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;fr.a2dfp.net.			IN	A

;; ANSWER SECTION:
fr.a2dfp.net.		103	IN	A	85.116.37.142

;; Query time: 0 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Fri Mar 07 21:49:29 CET 2014
;; MSG SIZE  rcvd: 46
:confused: :confused:
Any idea? Thanks
 
# and restart NTP client to eliminate 4-5 mins delay
killall ntp && sleep 1
service restart_ntpc

You should probably restart dnsmasq as well as your updating the hosts file.
Try:
Code:
killall ntp && sleep 1
service restart_ntpc
service restart_dnsmasq
 
The problem is that dnsmasq doesn't resolve de hostnames. It's dnscrypt-proxy. Is it incompatible this with ads block with host file?
 
It works when I test it. What are your first lines of the /etc/hosts file after a reboot? Can you post this including some of the blocked hosts part (the part starting with 0.0.0.0)
 
Is it incompatible this with ads block with host file?
After further testing, NO it is not compatible with this script.
You delegate resolving to OpenDNS with this:
Code:
echo "no-resolv" > /jffs/configs/dnsmasq.conf.add 
echo "server=127.0.0.1#65053" >> /jffs/configs/dnsmasq.conf.add
I have no further help for you with your solution.
You could however set your Router's DNS settings to OpenDNS and then add the winhelp hosts file or go with my solution I mentioned in a previous post.
 
You could do the "Advanced" Method of you're adventerous...
AdBlocking with combined hosts file

Ok, I have disabled "Improve Your Web Surfing Speed with OpenDNS" and I use the standard dnsmasq.
And I've simplified the "advanced method". The result is this:

/jffs/configs/dnsmasq.conf.add
Code:
address=/0.0.0.0/0.0.0.0
addn-hosts=/jffs/hosts.adblock

/jffs/scripts/wan-start
Code:
#!/bin/sh

# Wait up to 15 seconds to make sure /opt partition is mounted
i=0
while [ $i -le 15 ]
do
    if [ -d /opt/tmp ]
    then
        break
    fi
    sleep 1
    i=`expr $i + 1`
done

# Now resolve DNS name for NTP server
ntp_name=$(nvram get ntp_server0)
grep "$ntp_name" /etc/hosts > /dev/null 2>&1 || \
for ip in $(/opt/sbin/dnscrypt-proxy-hostip $ntp_name)
do
    echo $ip $ntp_name >>  /etc/hosts
done

# Create hosts file with URLs to block
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$//' | sort -u >> /jffs/hosts.adblock

# and restart NTP client to eliminate 4-5 mins delay
killall ntp && sleep 1
service restart_ntpc
service restart_dnsmasq

Now it works. :)
Thanks.
 
Very good, thank you.
Altough this appends to /jffs/hosts.adblock and the file grows after every reboot. Change ">>" to ">" and all is well.

Code:
# Create hosts file with URLs to block 
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$//' | sort -u > /jffs/hosts.adblock
 
Last edited:

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top