Jump to content

Pi-Hole

From Official NixOS Wiki
Revision as of 10:59, 27 February 2026 by J7 (talk | contribs)

Pi-Hole is a DNS service that functions as network ad-blocker.

Minimal Configuration Example

services.pihole-ftl = {
    enable = true;
    openFirewallDNS = true;              # To open port 53 for DNS traffic

    # Settings documented at <https://docs.pi-hole.net/ftldns/configfile/>
    settings = {
        dns.upstreams = [ "1.1.1.1" ];   # To use Cloudflare's DNS Servers
        hosts = [                        # Optionally resolve local domains
            "192.168.178.188 some.domain"
        ];
    };

    # Lists can be added via URL
    lists = [
        {
            url = "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/adblock/pro.txt";
            type = "block";
            enabled = true;
            description = "Sample blocklist by hagezi";
        }
    ];
};

At your option, a web interface can be enabled via services.pihole-web.enable = true;. You will have to open the corresponding ports when doing so.

Now, setting your routers DNS server to your IP will direct your traffic to the Pi-Hole. Blocked domains will not be resolved.