Joe's Quest

Ubuntu

resolv.conf Got Overwritten When Setting DNS in Ubuntu?

Some beginners may meet the problem (see also) that when editing resolv.conf to set DNS in Ubuntu as a lot of tutorials said, the file is keeping being overwritten once reboot the system.

The solution is, add following line in /etc/network/interfaces

dns-nameservers 8.8.8.8

For beginners, HOW TO is more important than the answer itself.

When tracing the problem, I noted that when editing resolv.conf it shows:

Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

Hey, it's not about resolv.conf, it's about resolvconf. The two filenames look almost the same except for the missing dot. When you execute resolvconf, it provides more information. Okay, let's check the manual:

...To make ifup push name‐server information to resolvconf when it configures an  interface,  add dns- lines to the relevant iface stanza in /etc/network/interfaces.  To add nameserver addresses add a line beginning with dns-nameservers.

dns-nameservers 11.22.33.44 55.66.77.88

Yeah, that's the answer!

So what beginners can learn from this?

  • Read the system information carefully, especially the ERRORs and CAUTIONs.
  • Follow the lead in the information and DON'T be afraid of long manual.

Discussion (1)

There is one response to “resolv.conf Got Overwritten When Setting DNS in Ubuntu?”.

  1. Katharina responded:

    · Reply

    Generally I do not learn post on blogs, however I would like to say that this write-up very compelled me
    to take a look at and do so! Your writing taste has been amazed me.
    Thank you, quite great article.

Leave a Comment

Your email address will not be published. Required fields are bold.