Using PiHole as Local DNS
Tired of having to remember local machine IP addresses? Hate ads? Kill two birds with one stone! But we didn't kill any birds in the making of this article! 🐦
We are back at it with Pi-Hole and setting up local DNS domains. It's much easier than you might think so let's get right into it.
Click for the Pi-Hole Index
If you don't already have Pi-Hole setup, you will need install Pi-Hole first. Once Pi-Hole is setup, head over to the local DNS settings under DNS Records at /admin/dns_records.php
.
Here you can enter a local domain name that will point to a local IP of your choice.
Example, if you have a local Bookstack instance setup on 192.168.10.10 on port 80 using Docker, simply setup a local domain for it by using bookstack.local as the domain name and point it at 192.168.10.10.
Try to avoid using domain extensions that are commonly used online because this can create issues. I find .local and .home work great but you can definitely have some fun and play around with that to see what works for you. 😀
I often times will leave the extension off and just use the name.
Example: I want to point monster
at 192.168.1.82
. So in the domain field I simply put monster
and point it at that IP address. Then all I have to enter in my address bar is http://monster and I'm in! However, If you use a browser that has search enabled in the address bar, you have to add the http:// protocol. I find it just as quick to type monster.local versus having to type http://monster. So this one is a toss up but it does work both ways.
This procedure will overwrite the custom.list file automatically for you.
This way you don't have to manually edit the file on the host.
But even if you did have to, looking at the file, it wouldn't be difficult! 👍
If you need to access a specific Docker app, you will need to append the port the app is using. Port 80 as you may already know is automatically mapped to the root IP address.
Example: If your Docker host is using the local DNS domain of docker.local pointed at your Docker host IP and Bookstack is using port 6875, you would have to use http://docker.local:6875 to access Bookstack.
While this can be helpful for the issue of creating DNS domains for apps on port 80, it won't solve the issue of having to remember all the ports your other apps are hosted on. I recommend a good self hosted dashboard for that!
Having issues with Pi-Hole DNS Domains?
Sometimes people have issues with local DNS domains working for a short period of time and then all of the sudden they stop working. If this is the case, be sure you are using Pi-Hole as the device DNS server and not only at the router level.
Example: If your Pi-Hole server has an IP of 192.168.1.200, you will put that in as your preferred DNS server to resolve that issue. In some cases a reboot may be required but it should work right away.
Another reason local DNS domains might fail is because of VPN providers like Nord VPN are running on your machine. Disable the VPN application and try again. 😉
Final Notes and Thoughts
For me this is a toss up between using Pi-Hole DNS or just setting up a self hosted dashboard on my network. Either way, it's easy and a lot of fun using the powerful features Pi-Hole offers.
We sponsor Pi-Hole! You can too if you'd like. Head over to the Pi-Hole Github repo and check them out!