On this page
- Which setup does this guide build?
- What should the server have first?
- How do you run the Pi-hole installer?
- How do you set the admin password and settings?
- How do you keep port 53 closed to strangers?
- How do you open the web dashboard safely?
- How do you prove blocking works?
- How do you add lists and keep Pi-hole current?
- What should you check when names stop resolving?
- Questions
Which setup does this guide build?
The result is a single VPS running Pi-hole v6 that answers DNS for a short list of trusted sources and refuses everyone else. Pi-hole is a DNS forwarder with block lists: names that appear on a list get a null answer, all other names go to an upstream resolver. Version 6 ships its own built-in web server inside the pihole-FTL daemon, so there is no separate PHP stack or lighttpd to look after.
Two ways of reaching it make sense on a remote server:
- Through a VPN, the cleanest option. Clients connect with WireGuard and use the tunnel address of the server as their DNS. Nothing about DNS is visible from the internet.
- From a fixed home IP, when your router has a static public address. The firewall admits only that address on port 53.
A resolver that answers anybody gets abused for amplification attacks within days, so leaving port 53 open to the whole internet is not an option. The examples use the server address 198.51.100.24, a home address of 203.0.113.50 and a WireGuard network of 10.8.0.0/24.
What should the server have first?
A small plan is plenty: Pi-hole uses well under 200 MB of memory even with a few hundred thousand blocked domains. Deploy Ubuntu 24.04, Ubuntu 22.04, Debian 12 or Debian 13, log in as a sudo user (see your first SSH session) and update the system:
sudo apt update && sudo apt full-upgrade -y
sudo apt install -y curl dnsutils ufwOn Ubuntu, systemd-resolved keeps a stub listener on 127.0.0.53:53. The Pi-hole installer detects it and turns the stub off for you, but it helps to know what is bound to port 53 before and after:
sudo ss -lunp | grep ":53 "If you plan to reach Pi-hole over a tunnel, set up WireGuard first with the manual WireGuard guide or deploy the WireGuard app image, so that wg0 already exists when the installer asks which interface to use.
How do you run the Pi-hole installer?
The project documents a one-line installer. If you prefer to read the script before running it, download it to a file first:
curl -sSL https://install.pi-hole.net -o basic-install.sh
less basic-install.sh
sudo bash basic-install.shThe text dialogs ask a few questions. Choose these answers on a VPS:
- Interface:
wg0if clients come through WireGuard, otherwise the public interface such aseth0. - Upstream DNS: any provider for now; you can point it at a local Unbound resolver later.
- Block list: keep the default list offered by the installer.
- Query logging: on if you want to see per-client statistics, off for maximum privacy.
When it finishes, check the versions and the service:
pihole -v
pihole status
systemctl status pihole-FTL --no-pagerHow do you set the admin password and settings?
Set a strong web password right away, because the installer may print a random one you did not save:
sudo pihole setpasswordAll settings now live in one TOML file, /etc/pihole/pihole.toml, and the same keys can be read or changed from the shell. Pi-hole answers only nearby networks by default. That default suits WireGuard clients, since 10.8.0.0/24 sits on a local interface. For a home IP that arrives over the internet, switch the listening mode to all interfaces and let the firewall decide who gets through:
sudo pihole-FTL --config dns.listeningMode
sudo pihole-FTL --config dns.listeningMode ALLOnly make that change once the ufw rules in the next section are active. Upstream servers are a list as well:
sudo pihole-FTL --config dns.upstreams
sudo pihole-FTL --config dns.upstreams '["9.9.9.9", "149.112.112.112"]'How do you keep port 53 closed to strangers?
Use a default-deny policy and add narrow rules for SSH, DNS and nothing else. Allow SSH before enabling the firewall so you do not lock yourself out:
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow OpenSSH
sudo ufw allow from 203.0.113.50 to any port 53 proto udp
sudo ufw allow from 203.0.113.50 to any port 53 proto tcp
sudo ufw allow in on wg0 to any port 53
sudo ufw enable
sudo ufw status numberedDrop the two home lines if you only use the VPN, or drop the wg0 line if you have no tunnel. Do not open ports 80 and 443: the admin page stays reachable through an SSH tunnel or the VPN. The ufw guide explains the rule syntax, and the nftables tutorial covers the same idea without ufw. From any address that is not on the list, a query should simply time out.
How do you open the web dashboard safely?
Forward a local port over SSH and browse to it on your own machine. Run this on your laptop, not on the server:
ssh -L 8080:127.0.0.1:80 deploy@198.51.100.24Then open http://localhost:8080/admin and sign in with the password you set. VPN users can skip the tunnel and visit http://10.8.0.1/admin directly, because traffic on wg0 is trusted. The dashboard shows queries per client, the top blocked domains and the state of every list. Groups let you give one device a stricter policy than another.
How do you prove blocking works?
Query a known advertising domain and a normal domain from an allowed client. Over WireGuard the server is 10.8.0.1; from home use the public address:
dig @198.51.100.24 doubleclick.net +short
dig @198.51.100.24 example.net +shortThe first query returns 0.0.0.0, the second returns real addresses. On the server itself, ask Pi-hole which list matched a name:
pihole -q doubleclick.net
sudo tail -f /var/log/pihole/pihole.logFinally, run a query from a host that is not allowed, for example a second server. It must time out. The dig guide explains the flags if any answer looks odd.
How do you add lists and keep Pi-hole current?
Add extra block lists under Lists in the dashboard, then rebuild the gravity database so they take effect:
pihole -gA weekly gravity update runs from a scheduled job installed with Pi-hole, so lists stay fresh without intervention. Upgrade Pi-hole itself with its own updater, and the operating system with apt:
pihole -up
sudo apt update && sudo apt upgrade -yIf a website breaks, find the blocked name in the query log and allow it with pihole allow cdn.example.net. Keeping the configuration small means a reinstall plus the installer gets you back in minutes; the optional daily backups add-on covers the rest.
What should you check when names stop resolving?
Work from the service outward. First see whether pihole-FTL runs and listens:
sudo systemctl restart pihole-FTL
sudo ss -lunp | grep pihole
sudo journalctl -u pihole-FTL -n 50 --no-pagerIf FTL fails to bind, another program owns port 53, usually the resolved stub. Set DNSStubListener=no in /etc/systemd/resolved.conf and restart systemd-resolved. If clients time out but the server answers locally, the cause is nearly always the firewall or the listening mode: your home address may have changed, or the mode is still limited to local networks. If upstream lookups fail, test an upstream directly with dig @9.9.9.9 example.net.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about Pi-hole DNS sinkhole
Is it safe to make Pi-hole public so friends can use it?
No. An open resolver is found and abused quickly for reflection attacks. Give friends a WireGuard profile instead and keep port 53 limited to wg0 and known addresses.
My home IP changes often. What then?
Use the VPN route. A WireGuard client on the router or on each device brings a fixed tunnel address, so the firewall rule never needs updating. A dynamic DNS name helps for other services but ufw rules take addresses, not names.
Does Pi-hole need much memory?
Very little. A plan with 1 GB of RAM leaves plenty of room, even with large lists and query logging enabled.
Can Pi-hole and Unbound run on the same server?
Yes, that is a common pairing. Unbound listens on 127.0.0.1 port 5335 and Pi-hole uses it as the only upstream. The Unbound guide shows the exact configuration.
How is this different from AdGuard Home?
Both filter DNS with block lists. AdGuard Home is a single Go binary with built-in encrypted DNS, while Pi-hole focuses on a classic forwarder with a rich query log. Pick whichever dashboard you like; the firewall rules are the same.
More in VPN and private DNS
- WireGuard VPN server (manual setup)
- wg-easy WireGuard web UI
- WGDashboard for WireGuard
- OpenVPN server with easy-rsa
- Pritunl VPN server
- OpenConnect VPN server (ocserv)
- AdGuard Home DNS filter
- Unbound validating resolver
- Technitium DNS Server
- IPsec VPN with strongSwan
- Squid forward proxy with authentication
- Shadowsocks proxy server
- Authoritative DNS with BIND 9