You are on page 1of 9

6/7/2020 Block Ads Across Your Network With Pi-Hole Using macOS

To make Medium work, we log user data. By using Medium, you agree to our Privacy Policy, including
cookie policy.

You have 2 free stories left this month. Sign up and get an extra one for free.

Block Ads Across Your Network With Pi-Hole


Using macOS
Guntang Konchdrone
Apr 30 · 7 min read

With security and privacy being paramount in today’s society, why not take the time to
block unwanted ads across your entire home network? This guide will show you how to
block ads at the DNS level, which means that the ads will not even be downloaded,
saving your precious internet bandwidth and sparing your attention from further
distraction.

This guide will show you how to setup Pi-Hole ad blocking software on a Raspberry Pi.

Download Raspbian

https://medium.com/macoclock/block-ads-with-raspberry-pi-and-macos-1d1ba5fbce05 1/9
6/7/2020 Block Ads Across Your Network With Pi-Hole Using macOS

Firstly,
To we arework,
make Medium goingwetolog
download Raspbian
user data. By Buster
using Medium, youLite,
agreewhich is a small
to our Privacy operating
Policy, including
cookie
systempolicy.
for our Raspberry Pi hardware. This doesn’t include things like a full graphical
desktop, but if you want that functionality, feel free to download a more feature-rich
version.

Go to Raspbian Downloads, and download Raspbian Buster Lite.

The file you just downloaded may be a zip file (a file ending with a .zip extension).
This kind of file is a compressed archive, and cannot be written directly to the SD card
of your Pi, so make sure you extract this file first. You should then have a file with a
.img extension, and this is what we will be writing to the SD card.

Download and Install Balena Etcher


Now we are going to download a tool that lets us write our freshly extracted image file
to the SD card which will be used in our Pi.

Visit Balena Etcher’s Download Page, and download Balena Etcher.

Follow the usual steps for installing software on your Mac, and you are now ready to
start the writing process!

Install Raspbian On SD Card


Grab your micro SD card and insert it into your card reader slot. Now launch Balena
Etcher, and you will be greeted with the following screen:

https://medium.com/macoclock/block-ads-with-raspberry-pi-and-macos-1d1ba5fbce05 2/9
6/7/2020 Block Ads Across Your Network With Pi-Hole Using macOS

To make Medium work, we log user data. By using Medium, you agree to our Privacy Policy, including
cookie policy.

Balena Etcher Main Screen

Here we only need to do two things: Select the Raspbian image file that you
downloaded earlier as your desired image. Then, select the SD card that you inserted
as the target drive.

Be very careful when selecting the drive: data on the drive will be lost once the
writing has completed, so be sure that you select the correct volume before
proceeding.

If you are in any doubt, be sure to stop here and double-check that everything is
correct. It may help to unplug any other external drives and cards from your system, so
you can more easily identify the correct one.

Setup Remote SSH Access


Mount the drive that just flashed (removing it and re-inserting it is usually sufficient
for it to appear).

We are now going to enable remote access to our Pi by enabling SSH connections. We
do this by simply adding a file named ’ssh’ to the top-level directory of the card. This
directory is usually called ‘boot’, and you should see this name in the finder when the
drive is mounted.

https://medium.com/macoclock/block-ads-with-raspberry-pi-and-macos-1d1ba5fbce05 3/9
6/7/2020 Block Ads Across Your Network With Pi-Hole Using macOS

Adding
To this file
make Medium simply
work, tells
we log userthe operating
data. systemyou
By using Medium, to agree
enable SSH
to our connections,
Privacy which
Policy, including
cookie
means policy.
we can connect remotely to our Pi over the network without needing to attach a
mouse and keyboard.

We are going to do this part inside the Terminal application. On Catalina, this can be
found in Applications/Utilities. Run this application, and you will be greeted with the
command line.

The Terminal Command Line

We will use the ‘cd’ command to change our current location in the filesystem. We
want to be inside the ‘boot’ volume, which is essentially the top-level of our SD card.

Type

cd /Volumes

Then hit the TAB key. This should show you a list of possible completions. Among them
should be the ‘boot’ volume (if you have followed this guide).

Keep pressing TAB until the ‘boot’ volume is selected, and then hit enter. You can then
hit ENTER to run the command, which will change the current location to where the
Raspbian operating system is.

Now type

https://medium.com/macoclock/block-ads-with-raspberry-pi-and-macos-1d1ba5fbce05 4/9
6/7/2020 Block Ads Across Your Network With Pi-Hole Using macOS

To make Medium work, we log user data. By using Medium, you agree to our Privacy Policy, including
ls
cookie policy.

and hit ENTER.

You should see a lot of files listed. Don’t worry about these, as we are merely
confirming that we are in the correct location before we proceed — always a good idea
when running commands in the Terminal.

At this point, we are ready to create our file. Type the following, and hit ENTER:

touch ssh

You have now created a new file named ‘ssh’, which will enable SSH connections when
your device boots up.

Note that the file we are creating does not need to have an extension. It is simply
named ‘ssh’.

Firing Up For The First Time


You can now assemble your Raspberry Pi, plug everything in and watch it boot up for
the first time. If all goes well, you should now be able to log in remotely, and start
configuring your new ad blocker!

To test our new setup (making sure that you have plugged your Pi into your local
network, of course), we will first log in and update the operating system.

This article will use the IP address of 192.168.1.10 as the assumed address for
the Raspberry Pi. In the command below, be sure to type in the actual address of
your Pi as it appears on your network. You can check your router’s admin
interface to find a list of connected devices, and get the address from there.

Open up the Terminal application again if it’s not already open, and type

ssh pi@192.168.1.10

You will be prompted for your username and password, which by default will be set to
https://medium.com/macoclock/block-ads-with-raspberry-pi-and-macos-1d1ba5fbce05 5/9
6/7/2020 Block Ads Across Your Network With Pi-Hole Using macOS

To make Medium work, we log user data. By using Medium, you agree to our Privacy Policy, including
username: pi
cookie policy.
password: raspberry

Fill these in. You should be greeted with an interactive session.

Entering The Shell

Update operating system


Next we will update the operating system:

sudo apt update -y


sudo apt upgrade -y

After these two commands have completed, your system should be up-to-date and
ready to go.

Set Static IP Address For Pi


We are now going to edit a file that lets the Raspberry Pi reserve a static (unchanging)
IP address on your local network, so you will be able to tell other devices to use it for
DNS requests.

sudo vi /etc/dhcp/dhcpd.conf

https://medium.com/macoclock/block-ads-with-raspberry-pi-and-macos-1d1ba5fbce05 6/9
6/7/2020 Block Ads Across Your Network With Pi-Hole Using macOS

The
To above
make Medium command assumes
work, we log user data.familiarity withyou
By using Medium, the ‘Vi’totext
agree editor,
our Privacy a quick
Policy, guide to
including
cookie
which policy.
can be found at this Vi guide.

Find the section that looks like

interface eth0
static ip_address=192.168.1.10/24
static routers=192.168.1.250
static domain_name_servers=192.168.1.250

and change the ‘ip_address=‘ value to the IP address that you want your Raspberry Pi
to have. As mentioned earlier, you will have to make sure that this is a valid address on
your network, so check with your router first.

Ideally, you would have set your router to reserve IP addresses, making them
static, to ensure that other devices on the network do not steal this address form
your pi. Setting this here, however, can achieve a similar effect if your router
doesn’t support such functionality.

Also set the ‘routers=‘ value to the IP address of your router.

These settings should ensure that your Raspberry Pi has a static IP address, and is easy
for you to find on your network. Once these values have been entered, be sure to save
the file and exit.

You can now reboot your Pi:

sudo shutdown -r now

When your Pi has finished rebooting, you should be able to SSH into it using the IP
address you just assigned to it, in this example that will be 192.168.1.10

ssh pi@192.168.1.10

Installing Pi-Hole
Now we are ready to install the Pi-Hole ad blocker.
https://medium.com/macoclock/block-ads-with-raspberry-pi-and-macos-1d1ba5fbce05 7/9
6/7/2020 Block Ads Across Your Network With Pi-Hole Using macOS

When
To make logged
Medium into
work,your
we logPiuser
viadata.
the By
Terminal, run you agree to our Privacy Policy, including
using Medium,
cookie policy.

curl -sSL https://install.pi-hole.net | bash

This will install pi-hole for you.

Follow the on-screen prompts and accept all of the defaults, as they are usually fine for
most purposes.

At the end of installation, you will be given an admin password for pi-hole. Make a note
of this.

Configuring Pi-Hole
You should now be able log in to the admin interface of pi-hole, by visiting the
following in your web browser:

http://192.168.1.10/admin/

Enter the password that you noted from the installation step, and you should find
yourself looking at the admin panel.

Now go to Settings and select the DNS tab at the top of the page. Here we can set the
server that is used by pi-hole to resolve valid DNS requests that are not blocked. You
can use whatever DNS server you like here, but a good default is to use whatever your
router was already using.

At this point, we are almost done. We just need to go back to our router’s admin
interface, and tell it to only use our Raspberry Pi for resolving DNS requests.

When you find the relevant section in your router’s config screen, enter the IP address
of your Pi as the only DNS server. Again, our example uses 192.168.1.10 as the address
of the Pi, but make sure to use whatever you assigned.

https://medium.com/macoclock/block-ads-with-raspberry-pi-and-macos-1d1ba5fbce05 8/9
6/7/2020 Block Ads Across Your Network With Pi-Hole Using macOS

To make Medium work, we log user data. By using Medium, you agree to our Privacy Policy, including
cookie policy.

Manual DNS Settings

That’s it!

If everything worked as expected, you should now have ads blocked across your entire
network, so all of your devices should benefit from reduced ads and bandwidth
consumption!

Conclusion
There are many more things that can be tweaked and configured, and what we have
covered here is just a basic setup. Blacklists can be updated and extended, settings can
be adjusted — you can even add your own custom exclusions.

Check out the official pi-hole documentation at pihole.net for more ideas!

Mac Raspberry Pi Ad Blocking Macos Privacy Protection

About Help Legal

Get the Medium app

https://medium.com/macoclock/block-ads-with-raspberry-pi-and-macos-1d1ba5fbce05 9/9

You might also like