Can i change the DNS in /etc/resolv.conf?

September 1, 2014 10.3k views

Hi Guys,

Previously on my 123-reg vps I configured OpenDNS as my resolver and I want to use OpenDNS on my DigitalOcean server. The file says that I should not modify by hand what do you recommend.

I have to use OpenDNS dns lookup.


1 comment
  • I have never been able to figure this out either

    I have a script that runs on new droplet.

    sed -i 's/dns-nameservers' /etc/network/interfaces

    Seems to work after reboot. But at some point gets lost. Right now the address is all I am seeing in my resolv.conf. the interface file has my only.

    I may have had to manually enter it in the resolv.conf later. Can’t remember.

3 Answers

You can modify /etc/network/interfaces to change the name servers

auto eth0
iface eth0 inet static
        dns-nameservers # modify this line

auto eth0 inet6 static << if ipv6 is enabled
       similar to ipv4 config

Then just run the following command to restart the network interface to reload new configuration.

# should be in one single line, otherwise you have to reenable the eth0 in DO console
 sudo ifdown eth0; sudo ifup eth0; 

Yes you are right the after reboot it gets lost. I found another solution you can edit resolvconf configuration.

edit - /etc/resolvconf/resolv.conf.d/base
add whatever name server you want it works.

  • How do you force resolvconf to update from those files? I edited the base file, but the DNS servers from the interfaces file just got added overtop of the ones in the base file.

I was just having problems with the default resolver, switched over to Google DNS ( and I wonder if DigitalOcean will have their internal/co-located DNS service to speed up these queries? Otherwise GoogleDNS works well (even if it’s not the fastest according to what I’ve read elsewhere).

Have another answer? Share your knowledge.