Pihole DNS on Unifi

Pihole DNS on Unifi

There is quite a lot of information out there on how to setup a whole home Ad Blocker with Unifi and PiHole. So, I will not attempt to rewrite those tutorials. Rather I will focus on a few sticky points that I encountered and how I resolved them.

For starters this is now my second time setting up PiHole on a Raspberry Pi to function as my in home DNS server. The first time I set it up I used the service for over a year and it was great. Then I moved and I decided to go with a fresh Raspberry Pi OS and PiHole install before setting it up in my new home.


I followed this "tutorial" on YouTube but the first place I got stuck was figuring out my Raspberry Pi's IP address.

The solution was to connect an external mouse, keyboard, and monitor to my Raspberry PI (after I had used the Raspberry Pi Imager to install a fresh OS on a MicroSD). Once the external devices were connected I connected the Raspberry Pi to my wi-fi network. Since I have a Unifi Dream Machine I was able to get the IP directly off of the GUI for the router. However, if you do not have that option you can always enter

ifconfig wlan0

in the Raspberry Pi's terminal.

Once I had the Raspberry Pi's IP I thought I would be able to SSH into it. However, when I gave it a shot I kept getting an odd error message about a man in the middle attack possibility because my "secrets did not match" (I think I had an old key for the IP address from a botched earlier install process before I figured out what my IP address was - hence the reason for this post).

So, I went to /Users/<myusername>/.ssh then nano known-hosts and I deleted the ssh-rsa for the Raspberry Pi's IP address. Then I shut down the Raspberry PI, ejected the MicroSD, and inserted it into my machine. Then in the terminal (I use iTerm2) I went to cd Volumes/boot (note: your SD cards name may be different), entered sudo touch ssh followed by my machine's master password, then entered cd .. so that I could eject the SD card and reinserted it back into my Raspberry Pi. Once it had booted back up I was finally able to SSH into my Raspberry Pi and go through the Raspberry Pi install process outlined in the above mentioned tutorial.

Boulder-1500.jpg

So, after all that I was finally able to get Pihole installed and up and running on my Unifi home network. As an aside I found this video very informative in getting a more advanced home network setup and running. If you have any questions feel to reach out at mountaintopcoding.dev or in the comments below. Cheers!