3 ms·
> One can achieve this locally, on a laptop/desktop, using https://github.com/StevenBlack/hosts https://github.com/StevenBlack/hosts I use this with DD-WRT to
by stordoff 10y ago
> One can achieve this locally, on a laptop/desktop, using https://github.com/StevenBlack/hosts https://github.com/StevenBlack/hosts
I use this with DD-WRT to get network-wide filtering. It's not perfect (only updates on router boot), but good enough for me.
Additional DNSMasq options:
addn-hosts=/tmp/ad-hosts
no-resolv
strict-order
server=8.8.8.8
server=8.8.4.4
Startup script:
wget -qO /tmp/ad-hosts-v4 https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
H_MERGE=/tmp/ad-hosts
H_ORIG=/tmp/ad-hosts-v4
sort $H_ORIG | uniq | grep "^0" >> $H_MERGE
sort $H_ORIG | uniq | grep "^0" | sed "s/0\.0\.0\.0/::/g" >> $H_MERGE
stopservice dnsmasq && startservice dnsmasq
- jsingleton 10y agoNetwork-wide is the way to go. Hosts files can be tricky to set up on phones and tablets. I run dnsmasq on a pi as my ISP router is pretty limited. You can't even change the DNS servers, so the pi has to do DHCP too. I use it to block other things like fixed banner overlays. With caching you can get it to work when you go off WiFi too [0]. Not sure I'd use Google's DNS servers though. Your ISP's are probably better for both speed and privacy. You can test the speed with an old Google project called namebench [1]. [0] https://unop.uk/block-bbc-breaking-news-on-all-devices https://unop.uk/block-bbc-breaking-news-on-all-devices [1] https://code.google.com/archive/p/namebench https://code.google.com/archive/p/namebench
- stordoff 10y ago> Not sure I'd use Google's DNS servers though. Your ISP's are probably better for both speed and privacy. You can test the speed with an old Google project called namebench [1]. Unfortunately my ISP's (Sky, UK) DNS servers aren't particularly reliable. My devices are behind the DD-WRT router that forces its own DNS settings (other servers are intercepted), but the rest of the family connects directly to the ISP router[1]. Multiple times I've been browsing the Internet without issue, but other people have been unable to use the Internet. Changing their device to use Google's DNS server resolved the issue. [1] Been meaning to merge the two for a while, but haven't got around to it yet
- oliwarner 10y agoUrgh why do people have to be so POSIX about things. Here is the content of my /etc/cron.daily/adblock file: #!/bin/bash wget -qO- https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts \ | sort -u \ | awk '/^0/ {print;print ":: " $2}' \ > /tmp/ad-hosts service dnsmasq reload I know cycles are cheap but that doesn't mean we should be spaffing them up the wall when we can do things cheaper. This avoids double-processing the downloaded content. dnsmasq config as above.
- neurostimulant 10y agoHow is the performance of dns lookup when using dnsmasq? Is it faster than putting them on /etc/hosts? I tried putting the blocked domains in the /etc/hosts file, but the performance is terrible. It significantly increased dns lookup time on my i5 laptop (that was before I upgraded my laptop with ssd though), so I ended up configuring my own ad blocking dns server on a cheap Scaleway vps instead and never have any issue with long dns lookup anymore.