Pi-hole Ubuntu Deploy has been tested in two VM network configurations. The right choice depends on whether you want Pi-hole to serve your entire LAN or only the host machine.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/damianiglesias/pihole-ubuntu-deploy/llms.txt
Use this file to discover all available pages before exploring further.
VPN and NAT configurations are not covered in v1 of the project. The author notes that bridged networking is the simplest approach for full LAN coverage, and more complex topologies will be addressed in a future version.
Bash Script Deployment
When usingdeploy.sh to install Pi-hole directly on the OS, the VM’s network adapter mode determines which devices can reach the Pi-hole DNS server.
- Bridged Adapter
- Host-Only Adapter
In Bridged mode, the VM is treated as a first-class device on your physical LAN. It receives its own IP address from your router (or a static IP assigned by Advantages:
deploy.sh), and any device on the network can point its DNS to Pi-hole.How it works:- All LAN devices can use Pi-hole as their DNS server
- No port forwarding or VPN required
- Static IP assigned directly to the VM interface via Netplan
- Recommended for production deployments
- Set your VM’s network adapter to Bridged in VirtualBox/VMware
- Run
sudo ./deploy.shand select Static IP when prompted - Set Pi-hole’s IP (
192.168.1.x) as the DNS server in your router’s DHCP settings
Ansible / Docker Deployment
When using the Ansible playbook, Pi-hole and Unbound run as Docker containers inside a custom bridge network. The host OS acts as the gateway, publishing container ports to the physical network interface.Docker Network: pihole_net
The playbook creates a dedicated Docker bridge network named pihole_net with a /16 subnet:
| Container | Image | Fixed IP | Role |
|---|---|---|---|
pihole | pihole/pihole:latest | 172.20.0.2 | DNS sinkhole + web admin |
unbound | mvance/unbound:latest | 172.20.0.5 | Recursive DNS resolver |
DNS Forwarding Between Containers
Pi-hole is configured withPIHOLE_DNS_1: '172.20.0.5#5335' — it forwards all upstream queries to the Unbound container on port 5335, keeping both containers within the private pihole_net network and avoiding any external dependency for recursion.
Port Reference
All ports used by Pi-hole Ubuntu Deploy — both for the direct OS install and the Docker method.| Port | Protocol | Service | Direction |
|---|---|---|---|
| 22 | TCP | SSH access | Inbound |
| 53 | TCP + UDP | DNS queries | Inbound |
| 80 | TCP | Pi-hole web admin | Inbound |
| 5335 | UDP | Unbound recursive resolver (if enabled) | Internal |
In the Ansible playbook, UFW only opens port 53 over TCP (task 9 loops over TCP only). UDP port 53 is handled by Docker’s port publishing, which bypasses UFW by default on Linux. For
deploy.sh, ufw allow 53 opens both TCP and UDP.DNS Query Flow
The resolution chain differs depending on whether Unbound is enabled.- Without Unbound
- With Unbound
DNS queries are resolved by an external upstream (Google or Cloudflare). Blocked domains return This is the default configuration after running
0.0.0.0.deploy.sh without enabling Unbound.Static IP and Netplan
A static IP is critical for a DNS server. If the Pi-hole machine’s IP changes (e.g., due to DHCP lease renewal), all devices on the network that point to Pi-hole as their DNS server will lose connectivity until the address is updated.deploy.sh handles this at Step 6 by writing a Netplan configuration that:
- Detects the current interface IP and default gateway automatically
- Locks that IP as static by disabling DHCP (
dhcp4: false) - Sets nameservers to
8.8.8.8(external fallback) and127.0.0.1(Pi-hole itself) - Backs up all existing Netplan YAML files to
/etc/netplan/backup/before writing
chmod 600 permissions as required by netplan apply.