Hacker News new | comments | show | ask | jobs | submit login
Raspberry Pi as an Ad Blocking Access Point (adafruit.com)
71 points by jwcooper 1263 days ago | hide | past | web | 37 comments | favorite



I hope that readers understand you don't need a RPi or dnsmasq to accomplish ad blocking. That said, this in my opinion an excellent use of a small form factor computer: as a gateway.

As a side note, what would happen if we put our own private address space "web apps" on our gateway? Voila, the added "web app" functionality that our devices expect, without the need to use third party servers on the public internet that collect personal info.

In any event, if you do not have a Pi, you could just as well use any old i386 computer and any old DNS server software.

I use a gateway like this not to block ads but to detect and, if necessary, stop mobile apps that phone home (and send out payloads of private data). You would be amazed at what some of these apps want to send over the internet for no good reason.

And, rather than use a HOSTS file as a blacklist, I use it as a whitelist by populating it with all the sites I might visit.

For example, using a localhost recursive DNS server, I pre-fetch all IP addresses for all the sites appearing on HN and put them in /etc/hosts. This makes reading articles posted on HN much, much faster than if using an ISP's DNS cache or some public, open resolvers like OpenDNS or Google.

Again, my compliments to the author for a great use of a small form factor general purpose computer.


Nicely written, very clear instructions.

I'm still not sure what I think of adblocking... in some ways it makes sense that I can display what I want on my computer, but on the other hand, advertising on web pages is a legitimate and reasonably sane business idea.

I don't adblock, but I do have flash on 'click to play', which does stop the most egregious and annoying ads.

My guess is, in time, that ad-blocking will simply mean more javascript and html videos (possibly using that clever canvas trick that was demo'd the other day) which are impossible to stop.


Instead of blocking the DNS, you are much better off running an intelligent HTTP proxy that can just filter out the bad stuff. Try installing 'privoxy' - it's available packaged for most Linux distributions. You can then use dnsmasq to push it as the recommended proxy for clients, or set up a few firewall rules to turn it into a transparent proxy.


Of course that won't work for HTTPS sites, which are becoming more prevalent

(PSA: install EFF's HTTPS Everywhere: https://www.eff.org/https-everywhere)


On Debian you just can use these patches/packages[0] to integrate HTTPS Everywhere into Privoxy.

[0]https://github.com/jvasile/freedombox-privoxy‎


For HTTPS, you can always fall back on blocking entire domains by host-header in privoxy. Not very fine-grained, but still useful for some things


Some proxies (e.g. squid) include transparent HTTPS proxying; you just need to generate a certificate and add it to your browser.


Does it work with Chrome's certificate pinning?


Privoxy does indeed support HTTPS


I assume it requires you install a generated certificate?

How does it handle Chrome's certificate pinning?


It really reminds me of how you block ads on a router that allow SSH access (like any router running Tomato, DD-WRT, OpenWRT...).

There are several guides online, like http://www.linksysinfo.org/index.php?threads/all-u-need-ad-b...

Anyway, I have mixed feelings on blocking ads at the router level (or using the RasbPi to block them). Those methods don't allow control, so if you need to disable adblocking for any reason, it's not something you can do just pressing a button.

Also, since it doesn't work on a per-site basis like Adblock Plus, you can't disable it on sites that you want to support and use ads in a non-intrusive way.


The guide does include ways to whitelist sites [1] you'd like to support (and mentions it's a good idea!) and is on a per-site basis. It pulls in an ad list from a popular site [2].

[1] http://learn.adafruit.com/raspberry-pi-as-an-ad-blocking-acc... [2] http://pgl.yoyo.org/adservers


I think he was talking about a way to quickly toggle the ad blocker on/off.


Yea, I didn't write that part out, but it would be fairly easy to write a bash script to turn it on and off (and even a simple web site with a on/off button, as you are running apache in one of the solutions). You could just move the dnsmasq.adlist.conf file out of the dnsmasq.d directory, and then restart dnsmasq.d, and vice versa.


Even better, with a Raspberry Pi, you could build a physical switch to flip to turn ads on/off.


> Also, since it doesn't work on a per-site basis like Adblock Plus, you can't disable it on sites that you want to support and use ads in a non-intrusive way. If the ads are hosted via a third party, it is unfortunately guaranteed invasive even if it's not visually intrusive.


In addition to blocking ads, I suggest anyone implementing this also blocks all websites containing ads.

Why? When you "say goodbye to ads" you're also saying goodbye to the source of income that pays the people who made the website.

No money, means no employees to create the website, means no more website.

Not everything can be open source / free. Nor should it be. People deserve to be able to make a living doing the work they do.


> When you "say goodbye to ads" you're also saying goodbye to the source of income that pays the people who made the website.

No you're not; you're just preemptively indicating your decision to be part of the "free-rider tier" of their system. Most business models aren't built on making money from every customer equally. See free-to-play games, for example: 90% of people pay nothing, 9% of people pay $10 or so, and 1% of people ("whales") pay ridiculous amounts that sustain the business. They don't want the 90% to start paying--they want the 90% to talk about "this great free game they found" to achieve a network-effect that brings more whales to their funnel.

Now, if Firefox and Chrome and IE integrated ad-blockers, they'd be responsible for "saying goodbye to the source of income that pays the people who made the website." But your using an ad-blocker when you weren't in the target demographic for the ads anyway (the target demographic is always at least "is willing to click an ad" and "has money to spend") makes no more difference to the site than your voting in a non-swing state makes to the results of an election.

Keep in mind: if a site really wanted to, it could detect that ads are loaded and displaying before it shows you the content. But nobody asks for this feature; goodwill toward free-riders is a necessary part of doing business.


> your using an ad-blocker when you weren't in the target demographic for the ads anyway ... makes no more difference to the site than your voting in a non-swing state makes to the results of an election.

Good luck creating an ad block software that automatically determines whether or not you are in the 'target demographic' before filtering the ad! (And if you think you're not in the target demographic because you don't spend money, and you don't click on ads, then you have a very limited understanding of the ad business.)

> you're just preemptively indicating your decision to be part of the "free-rider tier" of their system.

This is just a fancy way of saying "I don't click on ads, therefore it's OK to block them." That's a bad argument that reflects very little on the reality of how advertising works.

> Now, if Firefox and Chrome and IE integrated ad-blockers, they'd be responsible for "saying goodbye to the source of income that pays the people who made the website."

You have a good argument here. People who create and promote ad blocking software have a destructive effect on websites. They actively work to reduce the revenue generated by websites, which in turn reduces the budgets for those websites, which lowers quality.

The bottom line is that websites depend on advertisements in order to exist. If you are blocking ads, then you are voting for those websites to not exist.


> if you think you're not in the target demographic because you don't spend money, and you don't click on ads, then you have a very limited understanding of the ad business

No, I understand the ad business perfectly well; that is entirely different from thinking CPM ads make sense on the Internet. They're in inherent conflict with how people use the Internet, and create bad incentives for content publishers (in contrast to CPC ads.)

Websites, due to their interactive, choice-based nature ("what links do I open next", etc.), can be analyzed using game design theory. "Banner blindness" is a well-known problem for CPM advertisers, but at a fundamental level it is one of the principles of game design: a player, with the "algorithm" of a game fully loaded into their mind won't bother to mentally process anything which has no game-mechanical effect. Once you see which part of the website is "the content", your brain enters a mode (in the vi/emacs sense of the term) where anything other than content on the page will be filtered out at a pre-conscious level.


Again, you don't really understand how advertising works.

In fact, you've clicked on an ad today without realizing it.

Few people will admit to clicking on ads. And they will probably honestly believe that they don't click on ads. The best ads work when you don't even realize they are an advertisement. The best ads are a service that benefits you. Hacker News is a prime example: In a sense, it is a giant advertisement for YCombinator. We don't think of it as an ad, because it provides value to us as more than an ad. Here you are, in the middle of an ad.

Most people, when clicking on an ad, don't think about the fact that it's an ad. They click because the ad offered something interesting to them. It is not always even obvious what is an ad, and what is not. The lines get very blurry. For example, 'guest posts' on a blog, sponsored posts, 'paid links', etc. There are many, many various types of advertisements.

But even when ads are obviously ads, such as Google Ads, they aren't necessarily obvious when you are interacting with them. Effective advertisement is transparent. Indeed, there is a blindness to it: You don't even realize it is an ad. Again, think of Hacker News.

> No, I understand the ad business perfectly well; that is entirely different from thinking CPM ads make sense on the Internet.

So, you're saying CPM ads don't make sense, therefore we should block them as a revenue source for websites?

> Once you see which part of the website is "the content", your brain enters a mode (in the vi sense of the term) where anything other than content on the page will be filtered out at a pre-conscious level.

If this is how the world worked, then advertising simply would not be effective. For example, in a print magazine it is generally super easy to differentiate between the ads and the content. And yet, magazines such as the New Yorker continue to make money hands over fist.

On most of my websites, the ads are very easy to differentiate from the content, and yet people still click on that at alarmingly high rates. (Yes, it is alarmingly high, and I'm thankful for it every day!) "Banner blindness" is a nice theory, but the world simply doesn't work that way.

People ignore ads when the ads aren't relevant to them. For general audience websites that have a large amount of CPM advertising, such as Yahoo, this can be a problem. It is a problem they are not addressing very effectively, in my opinion. But the problem is not 'banner blindness', the problem is poorly targeted advertisements. Ad Blockers exist, in my opinion, because of the many scammy/spammy ads that seem to appear in place of well targeted/high quality advertisements. And it IS a problem.


You're ignoring every contextual adjective in each of my sentences. I didn't say that CPM ads don't work; I said that CPM ads don't work on websites. They work in non-interactive media, because you are focused on looking, instead of on interacting. Your brain isn't put into an active searching/hunting/gathering tunnel-vision mode. You aren't thinking "is this paragraph worth tweeting." You're just passively consuming, and so your passive consumption can be paused to deliver a word from our sponsor.

> The best ads work when you don't even realize they are an advertisement.

To me, Reddit's ads are excellent because they are precisely the opposite of that: they are clearly ads, they clearly sell me something, I can clearly tell what it is, it's definitely something I want, and if I click it, I know I'll get it, quickly and cleanly. And because all those things are true, the ads can afford to be subtle and pretty, instead of harsh and eyecatching. Sometimes it's just a link to another subreddit, and what they're "selling" is more (loss-leading) free membership. Sometimes it's something that costs money. It's always something relevant.

And the thing is, CPC ads usually are relevant, because it's very easy to tell as the site-owner when they're "working" on a page, and to split-test different ad-providers to find out whose ads get clicked more (and thereby find out what ads people actually enjoy clicking.) In fact, you have to do this with CPC ads--because irrelevant ads won't get clicked, and so you won't be making any money! This doesn't apply to CPM ads, and so CPM ads are generally irrelevant; there's no feedback loop in place to make them relevant. They're not incentivized to be relevant. And yes, if I could, I'd block them as a "revenue source for websites"--because without the (stupid) option of CPM, advertisers would just switch to offering CPC all the time (it's not like they want to suddenly lose 90% of their placements and go out of business either), and the quality of ads on the internet would improve immesurably.

And, having done that, advertising on the Internet becomes as simple as "Do you click on ads? Here are some ads, then." The incentives of that make everyone -- the user, the site-owner, and the advertiser -- much happier.

(And no, I'm not using "CPM" to also refer to brand-associated sponsorship/PR like HN; that's fine, and works everywhere, because it works gradually instead of needing to hook you away from the content you're consuming. Instead, I'm using CPM to refer specifically to creatives that could be CPC, but aren't. Those, and those only, are what create the misaligned incentives for sites to run horrible ads their users have absolutely no interest in.)


They're not Ads. They're malware distribution and tracking networks. It is unsafe to browse the web without blocking Ads. I would recommend everyone blocks them, for their own security and privacy.

When websites start displaying Ads in a manner that doesn't allow cross site tracking, and in a way that doesn't create massive centralised points of failure for the web, I might start letting them onto my network.


Disallowing 3rd party cookies will end cross-site tracking. (In practice, opting out[1] will pretty much cover you too, but I understand why you might not trust it.)

[1] http://www.networkadvertising.org/choices/


Disallowing 3rd party cookies wont end cross-site tracking. They want to do it so they will find ways to do it. Even if they ignore all of the obvious and underhand methods like exploiting E-Tags and Cache headers, they can always just track clients across sites based on their IP address. Yes, that is not as accurate as using cookies, but it is accurate enough to make more money than they would make by not doing it.


Of course people deserve to be able to make a living doing the work they do.

However, they don't get to dictate my behaviour as part of their business model.

I'll decide what my computer renders to my screen. They don't have to run their business like I want, and I don't have to run my computer screen like they want.


> People deserve to be able to make a living doing the work they do.

Yes, but if they earn their living by trying to trick me into buying something by displaying an animation that I could avoid watching by simply not downloading it, I deserve not to make their living.


If an animation tricks you into buying something, then it must incredibly magical.

I'm imagining the animation somehow inducing you to open your wallet, get out your credit card, type in the credit card number, and your billing address, and then clicking 'Pay Now.'

I want to know how this animation works. PLEASE TELL ME!


The more common scenario is tricking you into clicking the wrong link or even downloading something. Softpedia's download page[1] is a perfect example of this.

[1] http://darkpatterns.org/images/Softpedia-final-470x333.png


I didn't say it works, but yes, the point of commercial advertisement is to trick you into buying things. I'm sure you can think of a less blunt way to say it, but I'm not sure how you could argue with it.


Very interesting. Only flicked through, but please don't run Apache on a Pi; waste of CPU and memory, run nginx or pixelserv (as suggested).


bigoted opinion.

Apache runs fine on the Pi. Memory considerations aren't a concern when you have 512MB of RAM, and CPU difference is neglibible for these small workloads.


Sorry, I disagree. Nginx is a much better web server than Apache.


Could you please elaborate on the tradeoffs?


In short, fewer features (mainly not being able to host arbitrary files) in exchange for less CPU and memory usage.


Reminds me of the first Project I did with my Pi (last year) except I was using Squid and two Ethernet Ports (Apple's USB to Ethernet Adapter is basically plug and play with Linux). I eventually did a Wifi version, very similar to this article. I then developed a basic Web based UI that allowed you to turn it On and Off by clicking a button. The next step was to use the GPIO Pins to hook up a physical switch that you could press to turn it on/off, but never went that far. For a while there I thought about packaging it as a Product and trying a campaign on Kickstarter, but I didn't like the idea of just repackaging someone else’s Hardware and Code and selling it as my own. Eventually someone else did their own version (AdTrap) and was mildly successful. These days I'm still working on Pi projects as a side hobby, got 2 Projects I'm working on right now. Ironically, one of them supports the Advertising Industry (but not in the way one might think), and the other has to do with Content Delivery. The only real challenge I have (and it's a big one) is taking the next step and building something for mass production. Since the Pi is pre-made, I view it as a great platform to build a prototype, but not necessarily a good platform for mass distribution of a product (from a business perspective, production cost too high). For anyone else into it, check out the new GPS chip's they're selling. Awesome possibilities!

Regarding Ad's and Blocking Ad's, I have no remorse building something that gives the consumer a choice to blocks Ad's. While I do agree that Ad's can be a viable and acceptable business model, it is my personal opinion that the Advertising Industry has been abusing consumers for decades. And I find this detrimental to the Industry as a whole. I think it's about time that the consumers had a choice. I find the average (aka normal) user experience of your typical Ad (in any format) to be horrible; The Ad is basically forced on you. I also find that the Advertising Industry has little regard for the consumer's Privacy, which I do not find acceptable (as a consumer). I do think that there are innovative ways to Advertise and create a positive experience, but I don’t think the industry (as a whole) has realized/embraced them yet. It seems to me that the Advertising Industry is stuck on a model developed in the 60's, and has continued to push this old model even while technology evolves. I think it's time for the Advertising Industry to evolve. Hopefully I can test/validate this with one of my next Pi based Projects.


For those of us who don't have a Raspberry Pi there's AdSuck, an ad blocking DNS server from Conformal.

https://opensource.conformal.com/wiki/adsuck




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: