Netplan DNS Problem
I’ve always encountered a problem with Netplan when I configure nameservers via Netplan. My expectation always was that whatever I configure as my namservers in netplan would be applied to /etc/resolv.conf
but that doesn’t happen.
Netplan uses systemd-resolvd
but by default it always creates a symbolic link from /etc/resolv.conf
to /run/systemd/resolve/stub-resolv.conf
which uses 127.0.0.53
Most of the time this doesn’t result in my desired outcome which is that I want the nameservers defined in Netplan to be explicitly configured in /etc/resolv.conf
.
So here’s the solution to this problem:
sudo unlink /etc/resolv.conf
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
and then restart the service:
sudo systemctl restart systemd-resolved.service
And we’re done! Your nameservers will now be applied. You’re welcome.
January 30, 2024 ∙