Skip to content

Instantly share code, notes, and snippets.

@jwasden
Last active October 25, 2021 01:35
Show Gist options
  • Save jwasden/9ed004666e2b352704ad316dcb6ed916 to your computer and use it in GitHub Desktop.
Save jwasden/9ed004666e2b352704ad316dcb6ed916 to your computer and use it in GitHub Desktop.
Up and running with pi hole.

Steps to set up a pi hole on a rpi zero w

  1. Get a raspberry pi zero w (not required, as you can run the software elsewhere, but c'mon, you want to get a r-pi anyway.)
  2. Flash an OS to the pi
  3. Set up auto install on first boot
  4. Boot it up
  5. Set up the pihole as your DNS

1. Get a pi

this is an nice kit. It comes with everything you need to get going.

You also need an sd card.

Here's an unboxing video of what you are buying.

2. Flash an OS to the pi

The out of the box OS for the pi is good; but I went with an even more lightweight option, dietpi, since the pi zero w is pretty gutless as it is. (no hate, I love you pi zero w) https://dietpi.com/

Below is a guide to flash the OS to your sd card. https://dietpi.com/docs/user-guide_installation/

I'd reccommend setting your wifi creds in the flashed sd card. These instructions are in the above steps, but are collapsed and easy to miss. Also, if you are using a 5G access point on your router; dont. The pi zero w doesn't support that. (2.4 Ghz for us.) Also, if the text file is using single quotes for the var values, just change them to double quotes.

To setup the WiFi, open the SD card folder, and update next two files using a text editor of your choice:

  • Open the file named dietpi.txt. Find AUTO_SETUP_NET_WIFI_ENABLED and set to value 1.
  • Open the file dietpi-wifi.txt and set aWIFI_SSID[0] to the name of your WiFi network.
  • In the same file dietpi-wifi.txt, set aWIFI_KEY[0] to the password of your WiFi network.
  • Save and close the files

3. Set up pi-hole to auto install on first boot

Open the file named dietpi.txt again. In here, you can configure a list of software that you want to be installed on first boot. ( if you fudge something here, you can still add/remove programs manually later.) Find the section that has AUTO_SETUP_INSTALL_SOFTWARE_ID= commented out. un comment it. you can assign the id of any dietpi optimized software here. for us, we want to set the following:

AUTO_SETUP_INSTALL_SOFTWARE_ID=93

you can see the full list of indexes for optimized software here.

4. Boot it up!

Put the SD Card in your pi zero w. Drop the PCB in the case. Put the sticky heatsync on the boards processor. plug in the power supply to the power in usb. I'd leave the top lid off for now. (also, sad panda, it won't fit perfectly, as the heat sync is too tall.)

Plug in the power to the pi, then plug the Power Supply into the wall. Flip the switch on the cord to on, if needed.

Now, look at your pi. (You left the lid off, right?) If you see the green light doing things, then you are good to go. Leave for 5 minutes and come back later.

if the green light is off... well, something went wrong probably on boot. This happened to me, and I had to grab an old key board, and the HDMI from my tv as a monitor, to hook up and manually fix the wifi and install the software I needed. it's not too hard, but it's better if it's all done automagically. You can find instructions for manually installing software on the dietpi website. Basically, it's just cli work from here; check for instructions on dietpi.com.

(That's sounds harder than it is; it's just easier to see what error is happening when you have a keyboard and monitor. for me, I was connecting to 5G, or trying to, and so the whole thing was failing. I updated to the non 5G on my router, and made sure that worked, then I manually selected the pi hole software from the available lists. The auto install is supposed to be easier, but it didn't work for me, so...)

You can ssh into the pi by finding it's ip address on your network. I literally just guessed my way to the right IP address. not saying it's the best way, but it's what I did. the default ssh creds are below. yes, you can and should change them. Bonus: you can write down your pihole password when it appears if you install it manually.

username: root password: dietpi

after the 5 minutes are done (assuming it all went well and you saw the green light), you can come back and keep at it. At this point, you probably have the pi up and running. You can check by trying to get into the web interface on your network. if your pi ip address was 192.168.0.37, then you can get to the web interface at http://192.168.0.37/admin/index.php

There should be way here with instructions to reset your password if you never got it due to automagic install; sorry, I never did that successfully. I had to install manually, so I'm not sure how or where you'd get the web cred otherwise. :(

so you will probably have to SSH in to the pi and run that command. To reset the password, run the following while SSH'd in the pihole: pihole -a -p

it should prompt you for what you need.

5. Set up the pihole as your DNS

Technically, you could do this on a device by device basis, but it's easier and more practical to do this on your home router. Login to your router, and provide the ip address of the pi hole as your DNS. If it requires 2 ip addreses, you can set the second one to 127.0.0.1

That's pretty much it. from here, you can interact with the pihole via cli or the web interface; since someone went through the trouble of building the web interface, I'd start there. You can add block lists, white list domains, pause the service, etc. truly useful, IMHO.

Let me know if you get stuck anywhere; I'm sure we can sort it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment