Create a Network-Wide Ad Blocker with a Raspberry Pi

By | 4:29 AM Leave a Comment

Create a Network-Wide Ad Blocker with a Raspberry Pi

You have software to block ads on your computer, but if you want to block ads on all your devices—from your smartphone to your tablets—you’ll need something a little stronger. Enter the Pi-Hole, a Raspberry Pi image that blocks ads of all sorts at the router level.

Some ads are obnoxious, but remember: ads are how sites like us make enough money to run, so unless you want to see all your favorite sites go out of business, we humbly remind you to whitelist the sites you love.

Once you set up the Pi-Hole, ads get blocked before they even get to your computer, smartphone, or any other device on your home network. Besides freeing up your browser from running another extension, this should speed up your browsing and cut down on load times (it should even cut out things like those annoying in-game ads in iOS and Android). This will only work when devices are connected to you home network so if you leave the house, the blocking won’t work anymore, but it’s still useful if you’re not a fan of ads. Luckily, developer Jacob Salmela has a pre-configured Pi image that’s easy to install and set up. With it, your Pi gets set up automatically and you simply need to change a few settings on your devices.

What You’ll Need

Step One: Download and Burn the Pi-Hole Image

The first thing you’ll need to do is download and burn the Pi-Hole image. The image is a version of a Raspberry Pi operating system called Diet Pi, which cuts a lot of junk from Raspbian, and is packed with all the software needed to run the ad blocker. You can follow our guide to make an image here, but here’s the short version.http://ift.tt/1LF7JdY...

Windows

  1. Download the preconfigured Pi-Hole image and unzip the .img file inside.
  2. Download Win32DiskImager and unzip the application (.exe file) inside.
  3. Connect your card reader to your Windows PC and insert your SD card.
  4. Open Win32DiskImager.exe, the application you just downloaded, by double-clicking it. If you’re running Windows 7, 8, or 10, right click on it and choose “Run as Administrator” instead.
  5. If your SD card isn’t automatically detected by the application, click on the drop-down menu at the top right (labeled “Device”) and choose it from the list.
  6. In the image file section of the application, click the little folder icon and choose the Pi-Hole .img file you just downloaded.
  7. Click the Write button and wait for Win32DiskImager to do its thing. When it finishes, you can safely eject your SD card and insert it into your Raspberry Pi.

OS X

  1. Download the preconfigured Pi-Hole image from here and unzip the .img file inside.
  2. Download RPi-sd card builder (be sure to pick the appropriate version for your installed version of OS X) and unzip the application.
  3. Connect your card reader to your Mac (if necessary) and insert your SD card.
  4. Open RPi-sd card builder. You’ll immediately be asked to choose a Pi-Hole image. Choose the .img file you downloaded earlier.
  5. You’ll be asked if your SD card is connected. Since we inserted it earlier, it is, so go ahead and click Continue. You’ll be presented with SD card options. If you only have one inserted, you won’t see anything else in the list and it’ll be checked. If not, just check only the card you want to use and click OK.
  6. Enter your administrator password and click OK.
  7. You’ll be asked if the SD card was ejected. This is supposed to happen, as the application needs to unmount it to perform a direct copy. Double-check that your SD card is no longer available in the Finder. DO NOT remove it from your USB port or card reader. When you’re sure, click Continue.
  8. RPi-sd card builder will finish prepping your SD card. Safely eject it and insert it into your Raspberry Pi.

Step Two: Boot Up and Configure Your Raspberry Pi

Insert your SD card into your Raspberry Pi and connect the keyboard. Connect the Ethernet cable to your Wi-Fi router, then plug in your Raspberry Pi, and wait for it boot.

When you first boot up your Raspberry Pi, it’ll boot and reboot several times. This is normal, so let it happen. For the most part, it’s doing basic setup procedures like expanding the file system and getting the network settings configured. Eventually it will boot up to a login screen.

Log in with the username: root and password: dietpi. Once you do so, your Raspberry Pi will check for and possibly download a set of updates, so wait this out as well. When it’s done, you’ll need to reboot again, then login.

Step Three: Set Up a Static IP Address for Your Pi

Create a Network-Wide Ad Blocker with a Raspberry Pi

After all those reboots, you’ll eventually get to the DietPi Setup screen where you can assign a static IP address. This is necessary so your Pi will always be available at the same address from any of your devices. Here’s what you’ll need to do:

  1. Select Okay at the initial setup screen.
  2. Select Change Wired Network Settings.
  3. Select Change Mode and press Enter to change it to Static.
  4. Select Copy Current Address to Static. Make a note of the IP address listed at the top, you’ll need that in the next step.
  5. Select Apply to save the changes and restart the network.
  6. When that’s complete, select Exit to restart the device one more time.

After the network settings are configured, your Pi will restart again. Next, install the Pi-Hole software (this can take a while, it took about 20-30 minutes for me), then restart one final time. Once it restarts, the ad blocking software will be run automatically, so all you need to do is set up your computers.

Step Four: Point Your Devices to the Raspberry Pi for DNS

Create a Network-Wide Ad Blocker with a Raspberry Pi

Once your Raspberry Pi is running the Pi-Hole software, you’ll still need to route your device traffic through it so ad blocking works. To do this, you’ll need to change your devices’ DNS settings. This way, you devices ping the Pi to block ads as long as they’re all on teh same network. This is pretty simple, but varies depending on your devices and what they’re running.

Windows

  1. Right-click the Start Button and select Network Connections.
  2. Select your Wi-Fi or Ethernet network.
  3. Double-click Internet Protocol Version 4.
  4. Click Use the following DNS server addresses.
  5. Under the Preferred DNS server, enter your Raspberry Pi’s IP address you gathered in step three.

OS X

  1. Open System Preferences.
  2. Click on Network.
  3. Select your Wi-Fi or Ethernet network.
  4. Click on Advanced.
  5. Click the DNS tab.
  6. Click the plus sign and enter your Raspberry Pi’s IP address you gathered in step three.

Android

  1. Open Settings.
  2. Select Wi-Fi.
  3. Long press on your current network and select Modify Network.
  4. Tap Show Advanced Options.
  5. Change the IP Settings to Static.
  6. Enter your Raspberry Pi’s IP address under the DNS field.

iOS

  1. Open Settings.
  2. Select Wi-Fi and tap your home network.
  3. Tap DNS and enter your Raspberry Pi’s IP address.

You can also track how the Pi-Hole is doing at blocking ads by heading to: [RaspberryPiIPaddress]/pihole/index.php

Here, you’ll see stats and additional info.

Whitelist Sites

By default, the Pi-Hole blocks a lot of sites, but you can whitelist your favorite sites, though it’s a little complicated right now. First, you’ll need to head back to your Raspberry Pi. When you boot up the Raspberry Pi and login, you will automatically be at the command line. Here, you can create and edit a text file with the sites you want to not block ads on:

  1. From the Raspberry Pi’s command line, type in cd /etc/pihole/
  2. Type in nano whitelist.txt to open a blank text file.
  3. Type in the URL of any sites you don’t want to block ads on. Press Enter between each entry to put each on a new line. Use both www.site.com and site.com for the sites you don’t want to block.
  4. Press CTRL+X to save and exit.
  5. Restart the Raspberry Pi and the changes will take effect.

Future updates also promise the ability to edit white and black lists from the aforementioned Index screen, so keep an eye on that. For a more in-depth look at creating your own white and black lists, you can follow this guide.


from Lifehacker http://ift.tt/1VrcvjK

0 comments:

Post a Comment