English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Perfectly Solve the Problem of DNS Configuration Restart Failure under Linux

Sometimes you can ping the same IP address, but you can't ping the domain name, which is because the DNS is not configured.

But the DNS configuration file /etc/resolv.conf will be invalid after each restart.

Open this configuration file and find that there are comments hinting:

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

原来系统已经提示我们不要手动改此文件,因为这里每次重启都会被覆盖。

------------------------------------------------------

Then the question is, how to solve the problem of having to configure it every time?

Method1

 • Execute sudo vim /etc/network/interfaces

 • Add a line of DNS configuration, such as dns-nameservers 8.8.8.8

Method2

 • Execute sudo vim /etc/resolvconf/resolv.conf.d/base

 • Add DNS configuration, such as nameserver 8.8.8.8

 • If there are multiple DNS, add multiple lines, one per line

 • Save and execute resolvconf -u

At this time, open/etc/resolv.conf will find the DNS configuration added just now.

No problem after restarting ^_^

This is the full content shared by the editor, hoping to provide a reference for everyone, and also hope everyone will support the Shout Tutorial.

You May Also Like