Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Configure and Use systemd-resolved for DNS Resolution in Linux

systemd-resolved is a system service that provides network name resolution to local applications. It is an integral part of the systemd suite and is used to resolve DNS queries, manage DNS cache, and provide DNS-over-TLS (DoT) for enhanced security. Understanding how to configure and use systemd-resolved is crucial for maintaining a reliable and secure network environment on Linux systems.


systemd-resolved offers several benefits, including:



  • Caching: Reduces the number of DNS queries sent over the network.

  • DNS-over-TLS: Encrypts DNS queries to protect against eavesdropping and tampering.

  • Multiple DNS Sources: Supports resolving from multiple DNS sources, including DNS servers, /etc/hosts, and mDNS.


In this article, we will explore how to configure and use systemd-resolved on a Linux system.


Examples:


1. Enabling systemd-resolved:
To enable and start systemd-resolved, use the following commands:


    sudo systemctl enable systemd-resolved
sudo systemctl start systemd-resolved

2. Checking the status of systemd-resolved:
You can check if systemd-resolved is running and its status using:


    sudo systemctl status systemd-resolved

3. Configuring DNS Servers:
Edit the /etc/systemd/resolved.conf file to configure DNS servers:


    [Resolve]
DNS=8.8.8.8 8.8.4.4
FallbackDNS=1.1.1.1 1.0.0.1

After editing the file, restart systemd-resolved to apply the changes:
```bash
sudo systemctl restart systemd-resolved
```

4. Using systemd-resolved for DNS resolution:
To use systemd-resolved for DNS resolution, create a symbolic link from /etc/resolv.conf to /run/systemd/resolve/resolv.conf:


    sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

5. Testing DNS Resolution:
Use the resolvectl command to test DNS resolution:


    resolvectl query example.com

6. Enabling DNS-over-TLS:
To enable DNS-over-TLS, add the following line to the [Resolve] section of /etc/systemd/resolved.conf:


    DNSOverTLS=yes

Restart systemd-resolved to apply the changes:
```bash
sudo systemctl restart systemd-resolved
```

By following these steps, you can effectively configure and use systemd-resolved for DNS resolution on your Linux system. This will enhance your system's DNS performance and security.


To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.