Are you looking to add a DNS server to systemd-resolved? Look no further!
In this tutorial, we will guide you through the process step by step. By the end of this article, you’ll have a clear understanding of how to configure systemd-resolved with a DNS server of your choice.
What is systemd-resolved?
Before we dive into the steps, let’s quickly understand what systemd-resolved is. It is a system service in Linux that provides network name resolution to local applications. It acts as a local DNS resolver and handles network name resolution requests.
Step 1: Open the Configuration File
The first step is to open the /etc/systemd/resolved.conf file in your favorite text editor. This file contains the configuration options for systemd-resolved.
To open the file, run the following command:
$ sudo nano /etc/systemd/resolved.conf
Step 2: Add DNS Server Address
In the configuration file, you’ll find a section called [Resolve]. This section contains various options related to name resolution.
Look for the line that says
#DNS=. Uncomment it by removing the ‘#’ at the beginning of the line.
Beneath that line, add your desired DNS server address. For example:
You can add multiple DNS servers by specifying each address on a new line.
Step 3: Save and Exit
Once you have added the DNS server addresses, save the file by pressing Ctrl + O and exit the editor by pressing Ctrl + X.
Step 4: Restart systemd-resolved
To apply the changes, you need to restart the systemd-resolved service. Run the following command:
$ sudo systemctl restart systemd-resolved
Step 5: Verify Configuration
To verify that your DNS server has been successfully added to systemd-resolved, you can use the resolvectl command. Run:
$ resolvectl status
This will display detailed information about your current DNS configuration, including the DNS server addresses.
You have successfully added a DNS server to systemd-resolved. Now your system will use the specified DNS server for name resolution.
In this tutorial, we learned how to open the configuration file, add a DNS server address, save and exit, restart systemd-resolved, and verify our configuration using resolvectl.
We hope this article was helpful in guiding you through the process of adding a DNS server to systemd-resolved. Now you can enjoy faster and reliable name resolution on your Linux system!