Back in the day, users would directly edit the /etc/resolv.conf file to configure DNS on Ubuntu. These days, DNS configuration is handled by the systemd-resolved service. You can still edit the conf files to set the DNS servers, but this change won’t be persistent. Instead, methods like netplan or nmcli are used to permanently change the DNS server. Change via Network Settings The traditional method works differently now, and there are multiple new ways to configure the DNS. I’ve seen a lot of users get confused due to these changes. If you’ve been out of the loop for a while or are new to Linux, I recommend following the GUI approach as it’s the easiest to understand. Search Settings and open the Network (Ethernet) or WiFi page. Click on the Settings cog beside the connection and switch to the IPv4 tab. Toggle off Automatic DNS here, enter the DNS server address, and press Apply. Restart the connection (toggle on-off) to apply the new config. You can press the Settings cog afterward to verify the change. Edit Netplan Configuration Netplan is the default network configuration utility on Ubuntu. To put things simply, you can edit its config file from the /etc/netplan directory to set custom parameters such as the IP Address or DNS server. You’ll need the interface’s name to set the DNS, so check that first with nmcli device status Open the config file with a text editor. sudo nano /etc/netplan/*.yaml The config should look something like this. Identify the interface you’re trying to modify with the device name from earlier. Then, change the DNS values in the nameservers section, or add the section if it isn’t present. network: version: 2 renderer: NetworkManager ethernets: enp1s0: dhcp4: no addresses: - 192.168.122.50/24 routes: - to: default via: 192.168.122.1 nameservers: addresses: [188.8.131.52, 184.108.40.206] Just make sure the number of prefix spaces is the same as shown here, as that’s necessary for the config to work. Now, save the new config and apply the changes with sudo netplan apply You can verify the change using resolvectl status Use Nmcli to Set DNS We used the NetworkManager GUI applet to set the DNS in the first method, but you can also do the same with the CLI tool (nmcli). To do this, list the interfaces first and note the connection name. nmcli device status Modify the specified connection like so sudo nmcli con edit ‘Wired connection 1’ Use the set ipv4.dns commands to set the DNS servers. set ipv4.dns 220.127.116.11, 18.104.22.168 Save the changes, quit the nmcli editor, and verify the new DNS servers with the following commands. save persistent quit resolvectl status Set Temporary DNS with resolvectl If you only need to change your DNS server for the current session, you can use the resolvectl binary to make a temporary change. First, check the interface name with nmcli device status Now, specify the interface name and the DNS servers in the following manner. resolvectl dns enp1s0 22.214.171.124 126.96.36.199 Finally, verify the change with resolvectl status Keep in mind that NetworkManager will overwrite this config when its restarted, so this change isn’t permanent.