A server that I was using had their own in-house DNS servers which seemed somewhat slow to update, so let’s change them! To do this, we’re going to use resolvconf
.
First, make a note as to what DNS server is currently in use:
root@server:~# systemd-resolve --status | grep Current
Current Scopes: DNS
Current DNS Server: 161.x.x.x
Now install resolvconf
:
sudo apt install resolvconf
sudo systemctl enable --now resolvconf.service
Edit the resolv.conf
and add your desired DNS servers. For this, we’ll be using the CloudFlare DNS servers:
root@server:~# nano /etc/resolvconf/resolv.conf.d/head
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.
nameserver 1.1.1.1
nameserver 1.0.0.1
Update resolv.conf:
sudo resolvconf -u
You may need to reboot your server for the changes to be fully applied.
Check that the DNS servers have updated by executing systemd-resolve
again:
root@server:~# systemd-resolve --status | grep Current
Current DNS Server: 1.1.1.1
Current Scopes: DNS