How to permanently change DNS nameservers in Ubuntu 18.04.3? Wiki article is not working.


I am trying to permanently change the DNS nameserver being using on my droplet.

I following this article:

But the permanent fix option is not working.

The file “/etc/network/interfaces.d/50-cloud-init.cfg” does not exist. And when I add nameservers to the file “/etc/network/interfaces” and restart the droplet, no change occurs. The file is saved, but the DNS server being used are still the default ones.

My “/etc/network/interfaces” file looks like the following:

auto lo
iface lo inet loopback

source /etc/network/interfaces.d/*


Am I missing something? I am new to Linux.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
November 25, 2019
Accepted Answer


With the older Ubuntu distributions, you could do that with the /etc/resolv.conf however, with Ubuntu 18.04 you should make the change in the netplan configs at /etc/netplan/*.yaml files.

The file would look something like this:

    version: 2
                macaddress: cc:8c:11:e1:1b:81
                search: []
            set-name: eth0

To change your nameservers, just update the addresses under the nameservers section. And then run:

sudo netplan apply

Hope that this helps! Regards, Bobby

Just to point out for servers:

For persistence through reboots, you must create a file to stop cloudinit from resetting 50-cloud-init.yaml… (tested on ubuntu 20 server on DO today)

Copied from the default /etc/netplan/50-cloud-init.yaml : This file is generated from information provided by the datasource. Changes to it will not persist across an instance reboot. To disable cloud-init’s network configuration capabilities, write a file /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: network: {config: disabled}

*** Info: The actual addresses will be nameservers rather than redirects to resolvconf, so no etc in the yaml file.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel