DNS Basics: Hostname Resolution

0
103
DNS Basics: Hostname Resolution

Dit bericht verscheen eerder bij FOSSlife

If you want your system to resolve a hostname differently, add a line to /​etc/​hosts.

Enable Local DNS Server

Most modern distributions use systemd, which can provide a lot of services: it is much more than a replacement for the old SysVinit-style initialization. One of the services it offers is DNS. If installed and enabled, it will act as a DNS cache – that means it will ask another DNS server when it does not know an IP address, but it will memorize previous lookups, so that it won’t ask for the same address again and again. This should speed up loading web pages. (The information will time out eventually.) Check if it’s in use with:

resolvectl status

If it’s working, it will display information about the DNS server to which it forwards queries: You should see a line like

Current DNS Server: 192.168.178.1

in the output. If you get an error message instead, you need to enable the service, and you may also have to install it first. For example, on a current openSUSE installation, I had to install the systemd‑network package with Zypper first. Then edit /etc/systemd/resolved.conf (as root) and add a line

DNS=a.b.c.d

where a.b.c.d is the IP address of the DNS server that you’ve used before – typically, that will be your router. Run

sudo systemctl enable systemd‑resolved
sudo systemctl start systemd‑resolved

to enable the service. On the openSUSE test system, resolvectl timed out after these steps; the problem went away after a reboot. Also, even though the DNS server was active, the system did not use it. To fix that problem, open /etc/resolv.conf (again, as root), comment out any nameserver line by adding a # prefix and add

nameserver 127.0.0.53

This address, like 127.0.0.1, always points to your computer.

This article originally appeared in Cool Linux Hacks and is reprinted here with permission.

Want to read more? Check out the latest edition of Cool Linux Hacks.

 

 

Dit bericht verscheen eerder bij FOSSlife

Vorig artikelDjango 5.0 Now Available
Volgend artikelTake the 2024 Open Source Professionals Job Survey