Question

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

  • Posted on September 1, 2014
  • ed5Asked by ed5

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.

Thanks. Ersin.

Show comments

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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

auto eth0
iface eth0 inet static
        address xxx.xxx.xxx.xxx
        netmask xxx.xxx.xxx.xxx
        gateway xxx.xxx.xxx.xxx
        dns-nameservers 8.8.4.4 8.8.8.8 # 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; 

I was just having problems with the default 4.2.2.1 resolver, switched over to Google DNS (8.8.8.8 and 8.8.4.4). 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).

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.