Let's talk about hostname resolution a little bit more.
So hostname resolution allows host names to be matched to IP addresses and the other way around.
And the local etc host file is the primary solution as we have just seen.
But you will normally also use domain name system and
these DNS name servers are configured in etcresolve configuration.
That's a classical way.
And in this classical way you would use the etcnsswitch conf to identify the
order. But there's a new kid in town and that is systemd resolved.
Systemdresolved is how it works on Ubuntu. Let's talk about systemd Resolved.
It's a component of systemd and it's responsible for managing DNS name resolution. And it runs as
a service that communicates with the network stack and it makes sure that multiple DNS sources can
be used and DNS DNS records are cached as well. So it functions as a local DNS
server. To speed up your networking, you can check the current status of it using systemctl status
on systemd resolve d and you can use resolvectl status for information about current DNS configuration.
And if ever you need to overwrite the DNS configuration, you edit the file etc.
Systemdresolved configuration and restart systemd resolve D. Let's check out the systemd resolve D.
Okay, so what happens when I use
sudo systemctl status on systemd resolve d?
Well, oh no, I can see that systemdresolve d could not be found. This is one
of these parts where the distributions are taking a different road. So I'm going to open
a new terminal, and in my new terminal I'm going to SSH to Ubuntu.
And on the Ubuntu system I'm using
sudo systemctl status of systemd resolve d.
And there we can see that systemd resolve d is running.
So how exactly does it work? Well, we have the input file
etc systemd resolved conf and in etcsystemdresolved conf you will find the
configuration. Oh no, I don't have vim on Ubuntu. Help.
Let's do a quick sudo apt install vim because really, vim is my favorite editor.
Try again. Here we can see what the systemd resolve d looks like. Oh boy, that's a lot of configuration.
If ever you need to put in some additional configuration for DNS, you can put
it right here. Probably the most important thing for you to do is resolvectl status.
That will show you the current DNS configuration on link 2 we
can see that the current DNS server is set to 192.21682 9.2.
That's the local host internal DNS that is provided by systemdresolve D and
it allows me to cache records which will nicely speed up my connections.