When running Alpine within a QEMU-based hypervisors such as Proxmox, it's common for DNS resolutions to fail

Alpine Linux is renowned for its simplicity, security, and efficiency, making it a popular choice for developers and system administrators. Its small footprint and lightweight nature make it ideal for running in containerized environments and virtual machines. Unfortunately, running the Alpine operating system within QEMU-based hypervisors (such as Proxmox) can often lead to issues in DNS resolution.

In this blog, we will explore the common DNS resolution issues that can arise when using Alpine on QEMU and offer a way to fix it.

The issue

When running Alpine within a QEMU-based hypervisors such as Proxmox, it’s common for DNS resolutions to fail when performed indirectly through invoking applications. For example, a call to ping www.vokke.com.au may fail, but a direct DNS lookup via nslookup www.vokke.com.au will work. Interestingly, performing a ping after a direct call to ping www.vokke.com.au will subsequently work (likely due to caching of the resolved IP address).

This issue is extremely problematic, as it prevents the installation of packages and even the installer from finding a mirror.

The fix

The fix is obscure, but luckily quite easy to implement.

Step 1

Make (or edit, if it exists) a file at /etc/udhcpc/udhcpc.conf and add the line RESOLV_CONF="NO"

Step 2

Restart networking via rc-service networking restart

Step 3
Add in two DNS servers into /etc/resolv.conf (if the file doesn’t exist, make it). It appears a single DNS server won’t cut it – you need at least two. For example:

echo "nameserver 8.8.8.8" > /etc/resolv.conf
echo "nameserver 8.8.4.4" >> /etc/resolv.conf

Step 4

Restart networking again rc-service networking restart

Test
Do a ping to www.vokke.com.au and it should work!

Back to Blog