In this article, we will guide you through the process of replacing systemd-resolved and configuring DNS on Ubuntu 18. Systemd-resolved is a service that provides network name resolution to applications. However, there may be situations where you need to disable it and configure your own DNS settings. Let’s dive in.
To replace systemd-resolved and configure DNS on Ubuntu 18, you need to disable systemd-resolved using the
systemctl command, remove and symlink the
resolv.conf file, and configure your DNS servers by editing the
resolv.conf file. Restart the networking service to apply the changes.
The first step in this process is to disable systemd-resolved. This service is responsible for DNS resolution in Ubuntu, and we need to disable it before we can configure our own DNS settings.
To disable systemd-resolved, you will need to use the
systemctl command. This command is used to control the systemd system and service manager, which is responsible for controlling how services are started and run on your Ubuntu system.
Open a terminal and run the following command:
sudo systemctl disable systemd-resolved.service
This command disables the systemd-resolved service, preventing it from starting automatically on boot.
Removing and Symlinking resolv.conf
Next, you will need to remove the existing
resolv.conf file and create a symbolic link to the
stub-resolv.conf file provided by systemd-resolved. The
resolv.conf file is used by the resolver library to determine the DNS servers that the system will use.
To do this, run the following commands in the terminal:
sudo rm /etc/resolv.conf sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
rm command removes the existing
resolv.conf file, and the
ln -s command creates a symbolic link to the
Configuring DNS Servers
Now that you have disabled systemd-resolved and set up the
resolv.conf file correctly, you can configure your DNS servers. To do this, you will need to edit the
/etc/resolv.conf file and add the IP address of your local DNS server.
resolv.conf file in a text editor of your choice, such as nano or vim:
sudo nano /etc/resolv.conf
In this file, add the following line, replacing
192.168.1.2 with the IP address of your local DNS server:
You can also add additional DNS servers if needed, each on a new line starting with
Restarting Networking Services
After configuring your DNS servers, you will need to restart the networking service to apply the changes. To do this, run the following command in the terminal:
sudo systemctl restart networking.service
This command restarts the networking service, applying the changes you made to the
By following these steps, you should have successfully disabled systemd-resolved and configured your own DNS servers on Ubuntu 18. Please note that this solution may not work well with VPN connections that provide their own DNS servers for a specific domain.
If you encounter any issues or need further assistance, you can refer to the Ask Ubuntu answer and Ask Ubuntu question for additional details and troubleshooting tips.
Remember, disabling systemd-resolved and manually configuring DNS settings can have implications on system functionality and updates. Always proceed with caution and ensure you have a backup or a clear understanding of the changes you are making.
Systemd-resolved is a service in Ubuntu that provides network name resolution to applications. It is responsible for DNS resolution on the system.
There may be situations where you need to disable systemd-resolved and configure your own DNS settings. This could be necessary if you want to use a different DNS server or if you are experiencing issues with systemd-resolved.
To disable systemd-resolved, you can use the
systemctl command. Open a terminal and run the command
sudo systemctl disable systemd-resolved.service. This will prevent systemd-resolved from starting automatically on boot.
Removing the existing
resolv.conf file and creating a symbolic link to the
stub-resolv.conf file provided by systemd-resolved is necessary to correctly configure DNS settings. This ensures that the resolver library uses the correct DNS servers.
After disabling systemd-resolved and setting up the
resolv.conf file correctly, you can configure your DNS servers by editing the
/etc/resolv.conf file. Open the file in a text editor and add the IP address of your local DNS server using the
nameserver keyword. You can add additional DNS servers if needed.
To apply the changes made to the
resolv.conf file, you will need to restart the networking service. Use the command
sudo systemctl restart networking.service to restart the networking service and apply the changes.
Please note that this solution may not work well with VPN connections that provide their own DNS servers for a specific domain. It is important to be aware of this limitation and consider it when configuring DNS settings.