4 ms·
See, the thing is what if a website is broken due to host files, you can't easily re-enable ads for just this one website you need. A situation we can all imag
by sergiotapia 11y ago
See, the thing is what if a website is broken due to host files, you can't easily re-enable ads for just this one website you need.
A situation we can all imagine ourselves in: You need to check the google analytics for your website/company site. You can't because it's blocked at Host level.
What solution would there be for this use case?
- Scarbutt 11y ago$man mv
- sergiotapia 11y agoYou're suggesting renaming the hosts file to something else temporarily? I guess that would work. How quick does the operating system pick up on this change, do I need to reboot my machine for it to reload the Hosts file?
- singlow 11y agoNo reboot needed. I have updated my hosts file regularly in linux, windows and macosx without needing a reboot. Generally your browser will pick it up quickly as well. It doesn't cache host file entries in the same way as dns lookups so the effect of adding or removing is pretty much instant. I use Chrome mostly, so I am not as sure about other browsers.
- Scarbutt 11y agoNo need to reboot, as soon as you change the hosts file the OS should immediately start to use the new version, the hosts file is the first thing the OS checks when resolving names, this is what enables this approach to work.
- generic_user 11y ago$sudo nscd -i /etc/hosts also $man nscd
- vacri 11y agoIt takes immediate effect. I often have a terminal open and toggle commenting out an entry when testing something. As soon as you save it, it's good to go.
- johnchristopher 11y agoKeep in mind that Firefox has its own DNS cache and that has confused me more than once.
- derFunk 11y agoSoe does Chrome. You can clear the internal cache by visiting chrome://net-internals/#dns
- flashman 11y agoA situation I've found myself in before: asking our devs why the site is broken, only to find it's my overzealous script blocking.
- jakeogh 11y agohttps://github.com/jakeogh/dnsgate https://github.com/jakeogh/dnsgate has a whitelist command for this situation. It's really necessary if you use the block-at-psl[1] config option. [1] strips domains to the top level that the public can register using https://publicsuffix.org/ https://publicsuffix.org/ It also can quickly "dnsgate disable/enable". (dnsmasq only, quick enable/disable for /etc/hosts is not supported yet, patches appreciated)
- blt 11y agouMatrix chrome plugin is working well for me
- laumars 11y agoI've been using the hosts file method for years and have never had an issue with checking Google analytics. I use the "Someone who cares" link. Aside Google sponsored links and the odd ad sponsored link on pseudo-news sites not working (due to them being tracking URLs), I can't see it ever gets in my way. However to answer your question, these days I run dnsmasq on my home server and have my DHCP server assign that as my primary DNS. So every device (phone, laptop, smart TV, etc) gets their ads blocked as well - which is particularly good for my TV as it's bad enough having regular adverts on TV without LG pushing out sponsored content as well. So if there was a rare occasion that I needed to turn off my ad blocking, I'd just change the DNS to 8.8.8.8 (Google DNS) then switch back to my dnsmasq server once i was done (the only complication being that I sometimes need to close and reopen the browser due to that particular application caching the DNS lookup) The nice thing about using dnsmasq is that you can import those hosts files verbatim. Which means your update script can be simple.
- pbhjpbhj 11y agoI used to block various domains that served TV ads for UK Channel 4, but they hosted the client and that not detect ad loading. Seems you could probably truncate the video stream, maybe o using iptables, but their ad-load has reduced so I'm not motivated to try right now.
- laumars 11y agoThe weirdest side effect I've had was with the Sky HD box. If it was connected via ethernet then it wouldn't power up while my ad blocking was enabled. I was able to replicate this behavior by enabling and disabling my ad blocking, so my Sky box was definitely phoning home and failing to start if a specific domain was disabled. The weird thing is it would start up fine on WiFi or if the internet was disconnected completely. So I ended up just connecting it to WiFi as my wife was growing impatient by that point! I did intend to reinvestigate the issue; throw wireshark on a promiscuous NIC and look for what domain Sky was trying to connect to and what data it was sending. I was thinking it might make an interesting article - depending on what I find. But in all honesty I had then forgotten about it until now.
- camillomiller 11y agoIf you're on a Mac I'd suggest Gasmask. It's a lightweight freeware that lets you switch between multiple hosts files right from the menubar. I have a productivity hosts file I switch on everytime I want to block social media, another one for development purposes and a standard one to revert too in case I don't want any hosts overhead and a clean default file. It's extremely useful. https://github.com/2ndalpha/gasmask https://github.com/2ndalpha/gasmask
- shinnok 11y agohttp://shinnok.com/rants/2015/04/05/blocking-ads-and-trackers-using-hosts/ http://shinnok.com/rants/2015/04/05/blocking-ads-and-tracker... I've been using this simple script on OS X for quite some time now. It works like a charm and is using git for that exact reason, to be able to quickly disable/enable and also keep track of exceptions, changes, etc.