PiHole Setup
07/08/2024
In this guide, we will go through the setup of PiHole and additional configuration that is needed. No worries - its as easy as running a few commands.
What is PiHole?
Pi-Hole is a network-wide ad blocker that acts as a DNS sinkhole. It intercepts DNS requests and filters out domains known for serving ads, trackers, and malicious content. By doing so, it improves browsing speeds and enhances privacy for all devices connected to your network. Pi-Hole is easy to set up on a Raspberry Pi or other Linux-based systems, making it a popular choice for users looking to block unwanted content at the network level.
Installation
-
Create a directory and open it
mkdir pihole cd pihole -
Create a docker file
nano docker-compose.yml -
Copy and paste the below:
version: "3" # More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/ services: pihole: container_name: pihole image: pihole/pihole:latest # For DHCP it is recommended to remove these ports and instead add: network_mode: "host" ports: - "53:53/tcp" # Host Port:Container Port - "53:53/udp" # - "67:67/udp" # Only required if you are using Pi-Hole as your DHCP server - "80:80/tcp" environment: TZ: 'England/London' WEBPASSWORD: 'password' # Volumes store your data between container upgrades volumes: - './etc-pihole:/etc/pihole' - './etc-dnsmasq.d:/etc/dnsmasq.d' # https://github.com/pi-hole/docker-pi-hole#note-on-capabilities cap_add: - NET_ADMIN # Required if you are using Pi-Hole as your DHCP server, else not needed restart: unless-stopped -
Save with
CTRL+X,Y,Enter -
Deploy the container
docker-compose up -d -
Confirm that it deployed successfully
docker ps
If it has been successful, you should see something like:
We are now ready with the installation. Pretty easy, huh? Lets continue with further configuration.
Access
You can now access the PiHole admin panel at localhost/admin (e.g., 192.168.100.186/admin) with the password you've set in the docker-compose.yml file.
Usage
Option 1
The first and the easiest option is to simply set your local devices' DNS to the IP of the server running the PiHole. However, so you do not need to manually amend all devices' DNS, you can refer to Option 2.
Option 2
The second option, which is just a touch harder than the previous option is to set your router's DNS to the IP of the server you run PiHole from. That way, all devices connected to your router will utilize the PiHole's capabilities.
Firewall Port configuration
If you do have a firewall in place, make sure that you've properly allowed the requried ports in the firewall. In case you need assistance with this - check my guide for UFW here.
Potential issues
If port 80 is already in use, just change the host port in the docker file, but keep the container port the same. For example:
ports:
- "90:80/tcp"
Conclusion
And that's it! You've successfully set up Pi-Hole to block ads and trackers across your network, enhancing both privacy and browsing speed. By following these simple steps, you've transformed your network into a cleaner, faster environment. Remember to keep an eye on your Pi-Hole dashboard for insights and adjustments. If you encounter any issues, refer to the troubleshooting tips or consult additional resources. Enjoy an ad-free browsing experience, and feel free to revisit this guide anytime you need a refresher!