Using Pi-hole with Unbound: Difference between revisions

From Alpine Linux
m (fix formatting)
(added minor headings)
Line 13: Line 13:
== Configuration ==
== Configuration ==


{{Note| This page uses 192.168.1.3 as IP address of Pi-hole server.}}
Add your local user to the 'pihole' group as follows: {{cmd|$ doas addgroup pihole $USER}}
 
{{Note|This section uses 192.168.1.3 as IP address of Pi-hole server, while the Internet gateway router/DHCP server is at 192.168.1.1}}


Add your local user to the 'pihole' group as follows: {{cmd|$ doas addgroup pihole $USER}}
=== Unbound configuration ===


Create a file {{Path|/etc/unbound/unbound.conf.d/pi-hole.conf}} based on the content given in [https://docs.pi-hole.net/guides/dns/unbound unbound page of Pi-hole website].
Create a file {{Path|/etc/unbound/unbound.conf.d/pi-hole.conf}} based on the content given in [https://docs.pi-hole.net/guides/dns/unbound unbound page of Pi-hole website].
Line 25: Line 27:


Once the above changes are made, [[Setting_up_unbound_DNS_server#Service_management|check the unbound config and restart the unbound service]].
Once the above changes are made, [[Setting_up_unbound_DNS_server#Service_management|check the unbound config and restart the unbound service]].
=== Enable recursive DNS ===


Start the {{ic|pihole}} service as per command given in [[#Service management|Service management]] section.  
Start the {{ic|pihole}} service as per command given in [[#Service management|Service management]] section.  
Line 42: Line 46:
Ensure that your clients point their DNS to Pi-hole ip address:192.168.1.3
Ensure that your clients point their DNS to Pi-hole ip address:192.168.1.3


Enjoy Ad-Free browsing!  
Enjoy Ad-Free browsing!


== Service management ==
== Service management ==

Revision as of 08:10, 3 November 2025

This page documents the steps to use Pi-hole with unbound as an All-Around DNS Solution along with ad-blocker functionality by using a publicly available blacklist.

Prerequisites

  • You should have a dnsmasq (or another DHCP server) and unbound both working on your network.

Installation

Currently the pihole is available in the testing repository. It can be safely installed by following the guidelines for enabling the testing repo and for installing such packages with the use of the @testing tag.

The command below installs the Alpine Linux pihole package:

# apk add pihole@testing

Configuration

Add your local user to the 'pihole' group as follows:

$ doas addgroup pihole $USER

Note: This section uses 192.168.1.3 as IP address of Pi-hole server, while the Internet gateway router/DHCP server is at 192.168.1.1

Unbound configuration

Create a file /etc/unbound/unbound.conf.d/pi-hole.conf based on the content given in unbound page of Pi-hole website.

Download root hints for the Unbound server.

Ensure that the the /etc/unbound/unbound.conf files has only the following line uncommented as follows:

Contents of /etc/unbound/unbound.conf

# All lines are to be commented out like this, except the below ... include-toplevel: "/etc/unbound/unbound.conf.d/*.conf"

Once the above changes are made, check the unbound config and restart the unbound service.

Enable recursive DNS

Start the pihole service as per command given in Service management section.

Once the pihole service is started, connect to pihole admin interface: https://192.168.1.3/admin/

Add unbound to the Custom DNS servers section on the admin page: https://192.168.1.3/admin/settings/dns as follows: 127.0.0.1#5335

Remember to Save&Apply to make the changes to Pi-hole permanent.

Add blocklist file

On the Subscribed lists group management page at https://192.168.1.3/admin/groups/lists, add stevenblack list by adding an entry http://sbc.io/hosts/hosts and Click Add blocklist button.

To load the blocklist, Update Gravity (list of blocked domains) by clicking Update on the page https://192.168.1.3/admin/gravity or running the command:

$ pihole -g

Ensure that your clients point their DNS to Pi-hole ip address:192.168.1.3

Enjoy Ad-Free browsing!

Service management

Add the pihole service to auto-start using OpenRC:

$ doas rc-update add pihole default

pihole service can be managed using standard start|stop|restart OpenRC commands. To start the service immediately:

$ doas rc-service pihole start

See also