how to reset DNS settings to the defaults?

while I'm learning the DNS, I have installed too many apps such as BIND and DNSmasq and made some changes to /etc/resolve.conf

and now I would like to reset the DNS settings to defaults? I have removed DNSmasq and the things I remember but is there's someway to reset the DNS settings to defaults rather than reinstall the system?


Solution 1:

First, your /etc/systemd/resolved.conf should look like:

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details

[Resolve]
#DNS=
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=yes
#DNSStubListener=yes

Then run: sudo rm /etc/resolv.conf && sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

And check your systemd-resolved is enabled with: systemctl status systemd-resolved.service and if not then enable it: systemctl enable systemd-resolved.service and start: systemctl start systemd-resolved.service

Seems, that's all.