Using Pi-hole as an ad blocker

I’ve used various ad-blockers over the years, and while they have all largely worked, they have also started to slow my browser down (especially on older computers). I read about Pi-hole a few times, but didn’t get around to actually installing it until this week. Now I have installed it I’m wishing I hadn’t waited, because not only does it lead to a largely ad-free browsing experience, but it also makes my older and slower computers noticeably faster.

Pi-hole should work on any Debian or Red Hat derived Linux distribution, but I went for the obvious solution of putting it on one of my always-on Raspberry Pis (which also runs WordPress and a command-line IRC client). To install just type curl -sSL https://install.pi-hole.net | bash in a terminal, and then visit the /admin URL of the machine it’s installed on to view the admin console.

Configuring machines to use it is just a case of defining a custom DNS server (how to do that varies between each OS, but was trivial on Ubuntu and ChromeOS – I’ve not tried anything else yet). Just add the IP address of the Pi as a DNS server, and it will block anything on the block list, and then forward everything else on to be dealt with as normal. If you want to do this for everything on your network then there are various options detailed here that range from configuring one machine to routing everything through Pi-hole.

The admin page will tell you how much blocking is going on. With me it was about 1% of all traffic, and it will even tell you which domains it is blocking so you can whitelist anything you actually want to see (not all ads are bad). I don’t really notice a performance increase on my main computer, but older and slower computers definitely seem snappier, and can maintain about twice as many open tabs before they start to slow down, which is a bonus feature that I wasn’t really expecting.

My Setup

I’ve been maintaining an up to date list of what hardware and software I use since I discovered Uses This a few years ago. It usually lives as a page on this blog, but as I’ve rewritten 95% of it today then I think it deserves to be a blog post.

The hardware I use

Work – Surface Pro 4, with a Targus dock, two generic monitors and a Microsoft keyboard and mouse.

Home – A setup that looks superficially the same as work, but is older, has more cables, and has an excellent solar powered keyboard that is far superior to the Microsoft one I use at work. It also replaces the Surface Pro with a proper laptop, and adds a server with lots of memory that runs my (internal) WordPress sites and contains a backup of all my music. I also have a variety of small laptops and Raspberry Pis that fulfill various server and media functions, and a Synology NAS for backups. I’m trying to phase out a lot of my older computers and only use newer machines with SSDs and lots of memory, but it’s hard to let go sometimes.

Work from home – As home, but with an additional VM that allows me to connect to a remote desktop. Sometimes I’ll plug the Surface in, but that is only required for certain types of work and it’s far from my default setup now.

Travel – Chromebook, Raspberry Pi Zero, iPad (sometimes), Kindle and phone. Sometimes I’ll travel with my laptop, but that is rare. I also carry bootable USB versions of Ubuntu and Tails everywhere I go (even places I don’t take a computer). Increasingly my travel hardware also includes a bike and related tools.

The software I use

At work I’m running Windows 10. It’s ok, but I would like to be able to live without it.

At home (and whilst travelling) It’s a mix of Ubuntu, iOS, LibreElec ChromeOS and Raspbian (although I also have computers running Windows 10 and Mac OS that are rarely switched on now). Some of this is the legacy of spending the first half of 2018 trying to live with each main desktop OS for at least a month, which I must get round to writing up properly soon.

I use Firefox, Chrome and Safari on a daily basis, although Firefox has always been my main browser.

Other software I use that I feel is somewhat noteworthy includes:

WordPress – All my blogs run on WordPress, including several that are only available on my home network (including an extensive knowledge base containing all IT related things I learn). I currently maintain a WordPress multisite installation and several stand alone sites.

Evernote – I use this on every device I own (largely the web version now though), mostly to take notes in meetings and training sessions, and then to revise/reflect later. A lot of my notes are now photographs of whiteboards and other hand drawn scribbles, which Evernote handles very well.

Atom – A text editor that handles Markdown well, and can preview and export to PDF. I also use Pandoc to convert to PDF, HTML and/or .docx if required (I try not to use office software until the point I have to share what I’m working on with someone else).

Trello – I use this for my to do list, and it’s a good way to visualise the planning and execution of any task based work.

Dropbox – Cloud storage and syncing software to ensure I can access everything everywhere. I also use the text editor on the Dropbox mobile app to edit on the move.

IFTTT and Buffer – To automate as much as possible. Between them they handle a lot of the seemingly clever things in my digital life, and explain why I seem to be able to post to social media sites at times when I appear to be elsewhere.

Virtualbox – Because no-one needs as many physical computers as I had before virtualisation was a thing.

Spotify for discovering new music, and Rhythmbox for playing the music I already own.

My dream setup

Maybe I’m already living the dream, but the one thing I’d really like is to go back to doing everything on one computer (ideally running Ubuntu). That was possible 10 years ago, and I’m sad that it doesn’t seem possible today. I also yearn to live the life of a nomad, with just a bike, a change of clothes, and a tiny laptop to my name.

Setting up a Raspberry Pi media centre

A couple of years ago I built a media player using a Raspberry Pi and OpenELEC. I’ve made a few changes since I wrote that blog post (not least moving to LibreELEC), and have also made a smaller version of the same device that I use in hotels when I’m travelling.

Hardware

There are two hardware choices for this sort of project – Any model of full sized Pi, or a Pi Zero (which is more portable, but harder to get media on to).

Preinstalled SD cards can be bought directly from Pi Hut (or just buy blank ones from Amazon which is what I do).

You’ll also need a mouse (for setup), the TV you’re going to plug it into, a HDMI cable, and some way of getting media on to the device if you’re using the Pi Zero (more about that later).

For my Pi III based device I still use the same case as before, and also have small USB drives plugged into each spare USB port to give more storage. I also have it networked now to allow easier streaming from my NAS.

For my Pi Zero I use a case that I can’t find a link for now, but really anything that allows access to all the ports will be fine.

Software

LibreELEC is one of the installation options on the NOOBS image, and can also be bought preinstalled on an SD card. The first option requires an internet connection (which might be tricky on the Pi Zero), and both options require a mouse.

Once installation had finished the device boots into the default Kodi interface. A web-based remote can be accessed by browsing to the device’s IP address on port 8080, and it can be accessed as network based storage from other computers on the same network.

Full details on how to download and install later verions of the software as they become available can be found on the LibreELEC wiki.

Content

Adding content is straightforward if the device is networked. It’s simply a case of browsing to the device and copying files across, or by pointing it at a network share.

For ther Pi Zero I’ve found the best way to do this is to use a USB ethernet adaptor (mine doesn’t have wifi), but I suspect that the newer model linked to above might work on wifi which would reduce the need for a further piece of hardware.

Addons

The original plan for this project was that I’d end up with something that could play movies and music on my TV, and that could handle storing a small amount of content locally so that when I end up in a hotel room with a few hours to kill I have something interesting to watch. The solution I’ve built ticks all those boxes, but I was curious to explore what else LibreELEC could handle.

After exploring the interface and available software for a little while I found channels for Last.fm scrobbles, BBC iPlayer and TED talks. All of these installed and worked fine, and I’ve not found myself needing anything else on these devices.The larger one is used every day, and is definitely my prefered platform for interacting with iPlayer. The smaller one travels with me, and I just copy a variety of films to the internal SD card and use the one USB port for a mouse.

My travel setup

My travel kit (for non-work travel) now consists of:

If I’m working I’ll also have my Surface Pro 4 with me, but apart from that I rarely travel with a laptop these days.

Building the Debian Handbook

What follows is instructions for creating a local HTML copy of the Debian Administrator’s Handbook (which is a very useful source of information for anyone working with any Debian derivative including Ubuntu and Raspian). All work related to this project was done on a Raspberry Pi Zero running Raspian, so I suspect it will work on anything running any Debian derivative (although Ubuntu 16.04 is the only other system I’ve tested this on so far).

Open up a terminal, and issue the following commands to get hold of the source code:

sudo apt install git
sudo git clone
git://anonscm.debian.org/debian-handbook/debian-handbook.git

Install the packages required for building:

sudo apt install publican publican-debian

Build the html files:

cd debian-handbook/
sudo ./build/build-html

It might take a while to build, especially on the sort of hardware I’ve been using. This might be the point to make a cup of tea.

Copy the HTML files into the root of your web server:

sudo cp -R publish/en-US/Debian/8/html/debian-handbook/ /var/www/html/

At this point you should be able to browse to the home page of the directory by navigating to the hostname or IP address of your web server.

Simple CCTV setup using a Raspberry Pi

This weekend I’ve been setting up my latest Raspberry Pi (a version III, in a blue lego case, running Ubuntu) to display a video stream of what’s going on outside my house so I can watch out for deliveries etc.

It’s something I’ve done before on different hardware, but I thought it was worth documenting as it’s a good project for any model of Raspberry Pi, and requires nothing more than the Pi, a USB webcam (or camera module), and 15 minutes of your time. I’m using a piece of software called motion which is available in the Debian/Raspian/Ubuntu repositories.

Install motion:

sudo apt-get install motion

Enable motion to start at boot:

sudo nano /etc/default/motion

Find the line that says start_motion_daemon=no and change it to start_motion_daemon=yes.

Enable the stream to be viewed from other computers on the local network, and also make the output a little bigger:

sudo nano /etc/motion/motion.conf

Change the following values:

daemon on
width 640
height 480
framerate 100
stream_localhost off

Reboot, and then browse to port 8081 on the computer you’ve set it up on.