Earlier this week, I turned on my new Samsung “smart TV” and was greeted with a notification that I needed to accept “new terms and conditions”, and that I would “be sent targeted ads” [i.e. they’re collecting your data and selling it (you)]. Not only that, but if I declined, “certain smart features of the TV may no longer work”. After “declining”, none of my apps worked. Say what now? You mean to tell me you’re going to neuter the TV I paid for if I don’t agree to being pimped out? Bad move, Samsung. This has obviously ruffled a lot of feathers, and rightly so. There is a “mega thread” on Reddit that goes into great detail about it.
Imagine watching Netflix and having an ad or “commercial” pop up thanks to your smart TV? Yeah no. What’s likely occurring is that Samsung is subsidizing the cost of their TV’s with the revenue generated by their advertisements. The fact I just bought a mid-upper range 40″ Samsung 4K smart TV for only $275, which just a few years ago would’ve cost over $1,000, is not lost on me. A clever idea on paper, but horrible in practice, and whichever executive signed off on that idea should be reassigned to the toaster division.
While I don’t like the idea of what Samsung is doing at all, I can either disconnected my TV from my local network and break all the handy smart TV functionality like Netflix, Amazon Prime Video, Youtube, etc. or “deal with it”. For now, I’ve chosen to “deal with it” by using something called “Pi-hole”, which essentially turns a Raspberry Pi into a DNS server for your local network, which intercepts advertisements being sent to your client devices and replaces them with white space. While I suppose this may not stop Samsung from collecting the data, it prevents it from disrupting my use of the TV.
While there are browser based plugins like AdBlock that work quite well for computers and mobile devices, that doesn’t help me much with my TV. There is only one option – nuke the ads from orbit…it’s the only way to be sure.
I ordered a Raspberry Pi 3 kit from Amazon for about $50, which came with a clear case, power supply, two heat sinks, and the Raspberry Pi board itself. In addition, I purchased a 16 GB class 10 micro SD card for about $6 bucks (side note, can’t believe how cheap high capacity removable flash media is now).
I won’t bother with the assembly instructions as it’s pretty straight forward, but figured I would create a post that detailed the steps required to install the Raspberry Pi operating system (Raspbian Jessie Lite which is the GUI / desktop-less version), configure basic settings, and install Pi-hole.
- Download the latest version of Raspbian Jessie Lite from https://www.raspberrypi.org/downloads/raspbian/ and extract the .IMG file from the .ZIP archive. The light version contains no GUI, which is probably unnecessary anyway for the way this Raspberry Pi will be used.
- Download Win32 Disk Imager from https://sourceforge.net/projects/win32diskimager/ and install it.
- Download SD Card Formatter from https://www.sdcard.org/downloads/formatter_4/ and install it.
- Plug in the SD card to your computer and launch the SDFormatter App. Click the “Format Option – Option” button and set “Format Size Adjustment” to “ON”, and then click “Format”.
- Next, run Win32 Disk Imager. Click the “Browse” button and browse to Raspbian Jesse .IMG file you extracted from the .ZIP archive.
Ensure the correct drive letter for your SD card is selected under “Device” and then click “Write” to burn the .IMG file to it. This may take several minutes to complete.
Once it is done writing the image to your SD card, you should receive a success message.
- Eject your SD card, insert it in the Raspberry Pi, and power the unit up. It will be easiest if you hard wire the Raspberry Pi to your router or switch using the ethernet port. You will need to attach a monitor and keyboard as well so that you can enable SSH for remote administration.
- Login to the Raspberry Pi with the default credentials – username = pi and the password = raspberry
- Perform the initial configuration by entering the command “sudo raspi-config”.
- The “Raspberry Pi Software Configuration Tool” window will open, and a variety of options for configuration will be displayed.The first step we will do is to enable SSH so that we can access the Raspberry Pi from a remote system for the remainder of the configuration.Select “7 Advanced Options” and then “A4 SSH”. Answer “Yes” when asked “Would you like the SSH server to be enabled?”.
Select “Finish” from the raspi-config menu and answer “Yes” when asked to “Reboot now?”. From this point on, you should be able to perform the rest of the configuration from a remote system at the comfort of your own desk.
- Assuming you have DHCP enabled on your router or switch, your Raspberry Pi should’ve received an IP address. You will need to know this IP address to connect to use SSH from another system. I logged into my router’s admin portal and found a device named “raspberrypi”, which is the default name given, and then noted its IP address.
- Open an SSH session to the Raspberry Pi’s IP address and login using the default credentials.
- Once you’re logged in to the SSH session, you will see a warning that SSH is enabled but the default credentials have not been changed, which poses a security risk. We will be changing this, among other settings, by running the raspi-config wizard again. Enter the command “sudo raspi-config”.
- First, we will choose “1 Expand Filesystem” to utilize the remainder of the SD card. Mine is 16 GB and it’d be nice to have it all available for use. You will see a message that the root partition has been resized and it’ll require a reboot to complete. No need to reboot yet though.
- Next, choose “2 Change User Password”. Click “Ok” on the next window, and then you will be prompted to enter and re-enter a new password. Assuming you entered the password correctly twice, you should see a success window.
- Next, choose “4 Internationalisation Options”. We will be configuring our timezone and Wi-fi County here. Select “I2 Change Timezone” and select your major region, then your applicable timezone.
- Next, select “7 Advanced Options” and then “A2 Hostname”. This will allow us to change the default hostname from “raspberrypi” to something custom. Perhaps you have a naming convention on your network that you need to adhere to, or you don’t want it to be blatantly obvious what the device is used for based on the name. Enter your hostname then select “Ok”.
- Now that most of the basic configuration items have been addressed, return to the main raspi-config menu and choose “Finish”. A reboot will be required to apply the changes.
- Open a new SSH session to the Raspberry Pi and login with your new credentials. You will notice that the terminal now shows the customized hostname you selected in the previous steps.
- Now that we have basic configuration and network connectivity, it is time to download and install any updates available for your Raspberry Pi. The first command you need to enter is “sudo apt-get update”. You should see the updates begin downloading.
- When you see the message “Reading package lists… Done”, the download is complete and it’s time to install the updates. Enter the command “sudo apt-get dist-upgrade”. You will be notified that some amount of additional disk space will be required, and you will need to answer “Y” to continue. Depending on the amount of updates available, it could take a few minutes to complete. Once it’s done installing updates, enter “sudo reboot” for good measure.
- Now we will install the Pi-hole software. Log back into the Raspberry Pi with an SSH session and enter the command “curl –L https://install.pi-hole.net | bash”. Alternatively, if you don’t want to pipe to bash, you can use the “alternative semi auto installation” instructions located here.
The install script will launch, which performs various prerequisite checks and downloads the necessary files before launching the “Pi-hole automated installer” wizard.
- The first message you will see is a notification that “the installer will transform your device into a network-wide ad blocker”. Well, that is why we’re here after all. The next window notifies you that the software is free and open sourced, but “powered by your donations”. If you like the results, kick a little money their way.
- The next window states that you need to use a STATIC IP address, since it is after all a server and if its IP were to change, it’d break your Pi-hole DNS service. Because we never set a static IP address in any of the previous steps, we will have the chance to do so now.
- Now you will be asked to select an interface. “eth0” is the Ethernet port on your Raspberry Pi, and “wlan0” is the WiFi adapter. I am going to hard wire my Pi-hole to my router for the simplest and most reliable service, so I have selected “eth0”.
- The next window asks you to select which protocol(s) to use – since I am not using IPv6 on my network, I’ve left just IPv4 selected.
- The next window displays the current IP information and asks if you’d like to use that as your static address. Since I currently have a DHCP address leased, I do not want to configure a static IP with this address, so I’ve selected “No” and will enter the new information on the next window. If you decide to reuse the IP address issued to you by DHCP instead of one outside the DHCP pool, it’s possible that a duplicate IP address could be issued (depending on how smart your router/switch is) and cause an issue.
- Enter your IP address in “CIDR notation” – meaning that instead of specifying an IP and subnet mask like “255.255.255.0”, you’d enter the IP like “192.168.1.254/24”, implying that it’s a 24 bit mask.
- Most likely, the default gateway you received from DHCP will be the same one you want to use when configuring the static IP.
- Verify the information is correct and if so, answer “Yes”.
- The next screen asks you to select an “Upstream DNS Provider”. I use OpenDNS currently and have selected that for use by the Pi-hole. OpenDNS may give you some additional filtering flexibility as opposed to your local internet service provider’s DNS service.
- You will be shown a summary of your DNS configuration – if everything looks correct, select “Yes”.
- You will see some commands execute in the background, and then the “Installation Complete” window should appear. It tells you that in order for the Pi-hole to do its job, the devices on your network need to use it as their DNS server. Also, since we did assign a new IP address as part of the configuration, a reboot will be required. Select “Ok”, and then enter the “sudo reboot” once you’re back at the terminal prompt.
- At this point, the Pi-hole is ready for use by your clients. If you’re using DHCP on your router or switch, the easiest way to accomplish this is probably to modify your DHCP options so that the Pi-hole’s IP address is handed out as the DNS server. If you have static IP addresses set on any of your devices, you will have to modify their DNS server information manually.The option in red below “inserts” my routers IP address into the DHCP config as an available DNS server. For purposes of verifying that the Pi-hole is doing its job, I have disabled this setting which forces the clients to only use the Pi-hole and nothing else. For long term use, you could either configure a public DNS server like OpenDNS or Google in the “DNS Server 2” field, or set “Advertise router’s IP in addition….” To “Yes”.
- Now, we will test that the Pi-hole is doing its job and blocking ads. Before doing this testing, be sure to disable any browser-based ad blockers like “AdBlocker” so that we don’t mask the results of the test. Also, since you’ve already set your DHCP options to use the Pi-hole, you will need to manually override your device’s IP settings to use the router, or something other than the Pi-hole, as your DNS server.Now, pick a site that is chock full of ads – while I’m not the Hollywood gossip type, I figure they spam you pretty well, so I went to www.thehollywoodgossip.com and sure enough, several Amazon ads were there (I guess someone has been shopping for pastel colored Yeti tumblers in this house).
- Now that we have our “control”, go ahead and revert to using the Pi-hole as the DNS server on your device. Refresh the page (Ctrl + F5 if using Windows) and you shouldn’t see any ads this time.
- Also, the Pi-hole hosts a webpage that gives you ad blocking statistics, which I find really interesting. In your browser, navigate to http://%5Byour-pihole-ip%5D/adminIn just a few minutes of time, I can see that 16.5% of my internet traffic has been for ads – not an insignificant amount. It’s also worth noting that this page is open for access by default, so anyone that knew the IP of your Pi-hole and was aware of how to pull up the “admin” page could open your query log and see everything you’ve accessed on the internet.
I found a good blog post that details how to add authentication to force password protection to a page hosted on your Raspberry Pi. This is probably a good idea to do, for obvious reasons. I haven’t had a chance to try yet, but will update this post when I get it setup.