Setting up DNS on Debian & Ubuntu
How to change DNS servers on Debian/Ubuntu.
To change DNS servers in modern versions of Ubuntu (18.04 and newer) and Debian (10 and newer), manually editing the /etc/resolv.conf file is not recommended, as it is managed by system services (systemd-resolved or network managers) and overwritten upon reboot.
Note
DNS server IP addresses vary depending on your server's location. You can find the current IP addresses in the control panel under the specific service card: open the IPv4 / IPv6 tab and copy the addresses from the DNS Servers section.
Option 1. For Ubuntu (Configuration via Netplan)
Current versions of Ubuntu use the Netplan utility to manage networking.
1. Locating the Configuration File
Navigate to the Netplan configuration directory and check the file name:
ls -la /etc/netplan/
Typically, the file is named 01-netcfg.yaml, 50-cloud-init.yaml, or similar.
2. Editing the Network Configuration
Open the located file in a text editor, such as Nano (for more details on how to use it, see our Nano editor guide):
nano /etc/netplan/50-cloud-init.yaml
Locate your network interface section (for example, eth0 or ens3) and specify the nameservers block with the current DNS servers for your location (maintain proper space indentation, as the YAML format is sensitive to it):
network:
version: 2
ethernets:
eth0:
addresses:
- 31.172.75.173/24
routes:
- to: default
via: 31.172.75.1
nameservers:
addresses:
- 1.1.1.1
- 8.8.8.8
- 9.9.9.9
3. Applying the Settings
Verify the syntax and apply the configuration:
netplan try
If there are no errors, confirm the changes by pressing Enter (or apply them directly using the netplan apply command).
Option 2. For Debian (Configuration via /etc/network/interfaces)
In standard Debian installations (without a graphical environment), networking is configured via the classic interfaces file and the resolvconf package (or directly via ifupdown).
1. Editing the Interface Configuration
Open the network settings file:
nano /etc/network/interfaces
Locate the configuration for your primary interface (for example, eth0 or ens3) and add or update the dns-nameservers parameter with the current IP addresses from the control panel:
auto eth0
iface eth0 inet static
address 31.172.75.173/24
gateway 31.172.75.1
dns-nameservers 1.1.1.1 8.8.8.8 9.9.9.9
(If the resolvconf package is not installed on the system, the dns-nameservers parameter may be ignored. In this case, install it using apt update && apt install -y resolvconf or configure the systemd-resolved service).
2. Restarting the Network Service
For the changes to take effect, restart the network service:
systemctl restart networking
Verifying DNS Functionality
After configuring either system, ensure that the DNS servers have been applied correctly:
- Check the active DNS servers on the system:
- For Ubuntu (
systemd-resolved):
resolvectl status
- For Debian:
cat /etc/resolv.conf
- Run a test DNS query:
nslookup example.com
If configured correctly, the command will return the domain's IP address using one of your specified DNS servers.
These settings are automatically preserved after a system reboot and ensure stable domain name resolution on VPS and dedicated servers.
Our products and services
Help
If you have any questions or need assistance, please contact us through the ticket system — we're always here to help!