Casey

Full-Stack Developer

#docker #ubuntu

PiHole DNS Cheatsheet for Ubuntu 20

Some of the steps to take on a host, to get PiHole running through Docker without network_mode: host. Useful if the server is used for multiple applications. There are resolution errors when the server uses the PiHole container as primary DNS and cannot communicate with the outside world, so external DNS resolvers are set on the host. It could be my own misconfiguration but who truly knows with DNS.

# enable forwarding
$ sudo nano /etc/sysctl.conf

net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1

# save file
$ sudo sysctl -p

# edit network manager config /etc/NetworkManager/NetworkManager.conf
dns=default

# update /etc/systemd/resolved.conf with default external DNS settings. 
# allows the host and docker to still communicate without issues.
[Resolve]
DNS=8.8.8.8
FallbackDNS=8.8.4.4
DNSStubListener=yes

# remove resolved conf and disable
$ sudo rm /etc/resolved.conf
$ sudo systemctl stop systemd-resolved
$ sudo systemctl disable systemd-resolved