Turning a Raspi into AdBlock

pi

There’s nothing quite as annoying as seeing bandwidth wasted on unimpressive flash animations, irrelevant ads, and animated GIFs. The bad news is these ads are the sole source of income for a lot of your favorite websites – Hackaday included. The good news is you can turn these ads off with a Raspberry Pi, a WiFi adapter, and a little bit of fun in the terminal.

This build creates a wireless access point with a WiFi adapter plugged in to a Raspberry Pi. With an Ethernet cable plugged in, this effectively turns the Raspi into a wireless router.

To configure the software to block ads, it’s a simple matter of installing dnsmasq from the command line and making sure all the ads on your favorite webpages time out. This means a fairly big hit on the performance of your new DIY router, but with the installation of Pixelserv you can host a 1-pixel transparent GIF image that replaces all the ads and renders them invisible.

It’s a great project if you don’t like watching ads on your PS3, XBox, tablet, or other non-PC Internetting device. If people stealing your wireless connection is a problem, it shouldn’t be hard to make every image upside down or blurry for those rogue WiFi pirates.

Comments

  1. jwrm22 says:

    For my browser (FF) I’ts still best to use an addon. For any other non-PC devices its a great hack. Also nice to read about the different block possibilities.

  2. stranger says:

    Or just do it on the router that can run dd-wrt, openwrt, tomato, etc.

  3. Squid Man says:

    This is what I started doing back in 2000 with Squid.

  4. kerimil says:

    Most of people who visit hackaday use add blocking software. That’s certainly well above average for entire population.

  5. If you’re looking for an ad blocker for when you browse websites, it’s probably best to just use a browser add-on.

  6. Kevin Keith says:

    I suppose it’s funny to see a website which depends on ads for revenue, give instructions on how to eliminate it. Then again, as the article mentioned, my problem is wostly with nonsense like flash ads, or obnoxious seizure inducing flashing ones (both of which you guys are thankfully bereft of).

    • static says:

      Not any funnier or ironic than opening the Google’s Chrome browser to see that the ad block plus icon was still on the address bar, and still working. Disabled for hackaday in the browsers I use most.

    • voxnulla says:

      The fact that HaD is willing to post this material shows that HaD is still relevant. I block everything and the kitchen sink on principle. If site revenue would depend on 100% of the viewing audience being exposed to ads, then logically the ads would cater to the lowest common denominator and following suit so would the content.I mean, How many commercial media outlets do you know that provide unbiased quality whilst depending on advertising income?
      Ad driven content loses quality every time.
      This article shows that HaD is still content driven which is a good and rare thing.

  7. vonskippy says:

    If HaD (and any other site for that matter) would CONTROL their advertisements, I wouldn’t block them. Instead, sites farm out their ad engine to the lowest bidder highest payer and then their viewers (the people they should care about) get blasted with at best stupid ads and at worst malware. Is it any wonder smart people do their best to block such crap? Give me targeted, well behaved, clearly presented, pre-screened, 110% malware/crapware/slimeware free ad’s, and watch your click thru rate skyrocket.

    • ColdTurkey says:

      Thing is, you’re into a routine with it now as well as always expecting adverts to be shite. SO, if sites were to control their ad’s you wouldn’t know about it because you’re already blocking them. Catch 22.

      Basically if you already adblock it doesn’t matter how ‘nice’ the adverts are, you’ll still block them.

      • kaidenshi says:

        Not necessarily. I use Adblock on Firefox, and I whitelist sites that I read regularly, as long as they don’t carry annoying ads. HaD is one of them, as well as OSNews, and the few webcomics I read. On Slashdot I have excellent karma and the option from them to turn off ads, but I leave them on. CowboyNeal has to eat, after all.

        • ColdTurkey says:

          Ah, fellow /. reader! I wasn’t saying that that’s how everyone looks at advertising, just vonskippy seems a little angry at sites not controlling their ads and incites “whitewash all ads” type behaviour to deal with it. Personally I do let ads for sites I read regularly through (although while we’re mentioning it Slashdot normally give me the option to remove them for positive contribution), but there are some sites where the adverts are just too aggressive (pop-ups, ones that grey out the screen until closed, video ads) and they do get the blacklist treatment.

          CowboyNeal is still alive? I thought that’s what we’ve been eating the whole time!

      • AnubisTTP says:

        This seems like a good time to point out that Adblock has a setting designed to deal with this situation called “Allow Non Intrusive Ads”, which is checked by default. Basically, websites that don’t have animated or inline ads can request to be put on a whitelist, and then they will show up for people running Adblock as long as the user has not gone into the settings and unchecked the checkbox. (Nobody ever does, it appears… I don’t think most people even realize it is there.)

        Extrapolating the new, different future problems created when the primary income source for most websites is being controlled by a small number of unaccountable whitelist operators is left as an exercise for the reader.

      • fesili says:

        Odd that adblockers would not work if the ads were served up by hackaday.com directly. If they did then huge chunks of content would go missing.

        That is all people really want. Tasteful ads, serverd up by the domain they are going to. Why should someone trust that an ad being loaded by another site that loads flash from another, javascript from another, and so on isn’t saturated with malware at worst and annoyance at best?

        • Mental2k says:

          Not really, adblocking is just doing a bit of grep on the URL for each item. It’d be very, very easy, in fact I could do it now with a right-click, to filter out ads as long as their URLs were distinguishable from the content.

          A site could bypass it if they wanted to be s00per-smart by randomising all URLs. Tho you can still just disable images. Or use Javascript to serve up ads + content. Like most things there’s ways and means. I think turning it into an arms race tho would piss off readers of sites that go out of their way to ignore their choice and preferences.

          • Greenaum says:

            Sorry, I’m not Mental2K, I just nicked his name for an amusing joke in another thread. Sorry dude. Sorry!

    • We’re working on that.

  8. Chris C. says:

    I don’t block ads. Most are easily ignorable, impact on my bandwidth is minimal, and websites are entitled to a little income for using them. But I can still think of instances in which it would be handy to block specific websites. Will try this with a spare Pogoplug soon.

    It’s a bit of irony that the picture for this post is a particularly gaudy animated GIF, though. :)

  9. Hirudinea says:

    The redirection at the end of the intro sounds fun, just redirect wifi scammers to either disney and hard core gay porn, and if the scammer keeps using your internet MOVE!

    • cornelius says:

      I’ve done my own version of upside-down ternet (a forever work in progress). it’ll randomly: swap out the image for an image of my choosing, mess the image up, or insert rick into gif (from what i remember, that wasn’t working too well). additionally, if it’s a *.swf file, rick will perform a ‘solo’ (it’s uh… creepy when the page uses multiple flash mulitple times in a website). If i ever figure it (running and writing the script), i’d like to get an ICAP server running to allow me to mess with the text content – insert messages, cgnahe ltteer oedrr, etc… :P. Of course the logical thing to do is encrypt your wifi.

      • Obitoo says:

        Much more fun not to encrypt it though; I use a dhcp whitelist to give ‘guests’ a squid proxy which redirects all http to cute kittens. (it used to be goatse but my other half complained she couldn’t look the neighbours in the face)

        Completely insecure of course, but really if the police want to plant kiddie porn on my server then WPA isn’t gonna stop them it’s just a lot harder to convince the layman it wasn’t me.

  10. frogsiedoodle says:

    I use my pi as a dnsmasq server (dns not dhcp) to block ads on my iPad. Blocks most ads but not all nowhere near as good as Adblock plus.

  11. markus aho says:

    I have upside-down ap using raspi and chinese 3$ wifi-usb and squid3

    • markus aho says:

      I was also thinking of making it share free black-n-white internet for apartments near me, but didnt yet do it as i had problems locating where to start writing my scripts

  12. mike says:

    you can also do it without using the pi as a router
    just set your dns server to the pi address, and use the normal wifi

  13. cornelius says:

    i really like the idea of a central adblocking ‘server’. I admit that I do it myself (with the additon of site that commonly, supposedly, transmit malware). I haven’t done enough digging, but a whitelisting (allow ads to show on certain websites, like hackaday, but block all ads when viewing site ?????.com) feature would be great. im not sure how well rasberry pi would handle squid + ???. dansguardian and squidguard have whitelisting capabilities, but not sure if they would do what i’m looking for – not a blanket any ads being hosted on ads.google.com (or similar). I’m sure an ICAP server would work and allow for a multitude of other possiblitiies. I also don’t know how those would work with SSL connections.

  14. o says:

    This doesn’t really work on HTTPS sites.

  15. For the particularly evil… you can use this to replace all images with your own ads :3

  16. PodexPerfectusSum says:

    I run Privoxy on a dedicated server. Much more control over ad filtering.

  17. 0x4368726973 says:

    I might have to do something like this to go with HSMM-MESH. I can’t legally pass advertisements over that and keep it legal under 47CFR97

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 94,586 other followers