I’ve been running Pi-Hole as my DNS resolver and Ad Blocker for a couple of months now, and I’ve always had an issue with Pi-Hole not resolving DNS requests whenever I reboot the Ubuntu Virtual Machine. In the past, I’ve managed to fix the issue but unfortunately not spent time figuring out a permanent fix. However, this time, I wanted to get to the bottom of the problem.
Assuming this was a Pi-Hole configuration issue, I wen’t through several support tickets over at the Pi-Hole discord forum. However, none of that turned out to fix the problem. Therefore, having concluded that there was nothing wrong with the Pi-Hole configuration, maybe the Gateway was preventing it from getting out to the internet?
After spending some time digging through the Gateway configuration, nothing was standing out that would be preventing the Pi-Hole instance from resolving DNS requests. However, everything on the Gateway seemed to be working as it should be. I then moved back to the Pi-Hole and started looking at the Ubuntu configuration. Maybe there was an issue with the OS firewall? However, turning the firewall off didn’t yield any results, so it was clearly not the firewall.
So, not the Pi-Hole, nor the Gateway Firewall, nor the OS Firewall. Surely, the OS has internet connectivity, it worked fine before the reboot? Therefore, I was a little surprised when it turned out there was no internet connectivity. Using the ip command and going through the netplan config, I couldn’t see any issues. However, looking at the command history I came across the command
sudo dhclient -r; sudo dhclient
Why wouldn’t the system get a DHCP lease? And why would it not have asked for one when the system booted up? Running the dhclient command, everything started to work as usual again.
Researching a more permanent fix
Digging further, somebody posted a fix that seemed like it might force a DHCP lease to be requested upon startup. Adding the following to /etc/network/interfaces fixed the issue upon the next reboot.
auto <network card alias>
iface <network card alias> inet dhcp
Substituting your <network card alias> with the name of your network card, most cases, that would be eth0.
If you have had the following issue, where Pi-Hole was not resolving DNS requests on Ubuntu, I hope this fixed it. Lastly, if you have a better fix or a better explanation for why this is happening, please post a comment in the comments section or send me an email via the contact form.