Let's talk about DNS client configuration. So DNS is for name resolution. And DNS is the
internet-based system that ensures that all hosts have a unique name and can be reached
by it. To get the IP address that belongs to the name, the internet DNS server is contacted.
Traditionally, the file etcresolve.conf on Linux has always taken care of the DNS name
resolution. We call it the DNS resolver. The file etchost can be used to resolve hostnames
on the local network without using DNS. So if you want to use a local host by name, put
its name and IP address in etchosts. And if the hostname is defined in etchosts, it will
have higher priority than DNS hostnames, which is by the way managed in the file etcnsswitch.conf.
Now in most cases, you want to set up a DNS client. As mentioned, resolve.conf is the
old standard. On network manager systems, the file can be written directly or is managed
by network manager. On systemd networkd systems, like Ubuntu, a different approach is used.
And that is where systemd resolved comes in. So systemd resolved is a systemd component
that manages DNS name resolution. And it runs as a systemd service that communicates with
the networking stack and makes sure that multiple DNS sources can be used and DNS records are
cached. You can check the current status using systemctl status systemd resolved. And use
the resolvectl status for information about the current DNS configuration. If ever you
want to overwrite DNS configuration, you edit the file uselib systemd resolved.conf or better
etcsystemd resolved.conf. And then you restart systemd resolved to pick up your edits and
write the correct information to your etcresolved.conf. So first, systemctl status on systemd
resolved is showing that systemd resolved is actively running. And that means that this is
managing your DNS configuration. So let's do something funny. And let me use sudo vim on etc
resolved.conf. And there, I'm going to change my configuration. Let me put a comment sign in front
of it and I make it nameserver 8888. All right. Next, I'm going to use a sudo systemctl restart
systemd resolved. And back to my resolve.conf. And as you can see, the nameserver 8888 has
disappeared. And that is because if you want to overwrite your DNS configuration, well, actually
it's saying it right here. And this is the file. So in fact, if I want to change my configuration,
well, I need to be in uselib systemd resolved.conf. That is the input file that is actually being
used. And hey, do you remember what is going on with these files in uselib? Uselib is supposed to
be provided by packages. Do not edit it. Instead of editing this file, copy the file to etc systemd
resolved.conf and edit that. And that will make sure that your edits find their way into the
resolved.conf configuration. Confusing, huh? But you better be aware of it. Otherwise, it won't
ever work.