Solve the problem of failure of changing DNS configuration and restarting under ubuntu server

888u

Last update at :2024-06-21,Edit by888u

Although when we choose a hosting provider in mainland China or abroad, we may install CentOS, Ubuntu and other mirror systems according to our own habits, but sometimes due to merchant configuration issues, we will still have some differences in the software installation process. questionable. For example, Snail made an error when updating the source when installing the Ubuntu system on a merchant server in mainland China today.

At first we thought it was a source problem, so the same problem occurred when we changed the Alibaba Cloud and 163 sources. Finally, we found that the DNS was not configured, so we changed it to Google DNS (8 8 8 8 / 8 8 4 4 ), but the configuration file is lost after restarting the server. This is not possible. If the server is restarted, it may affect the system files. How to solve it specifically?

Here we see this when setting the resolv.conf file in the server.

# 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

DNS does not persist, so we need to solve the problem of restarting the server DNS to keep it valid.

First, add configuration files

/etc/network/interfaces

Add at the end of this file

dns-nameservers 8.8.8.8dns-nameservers 8.8.4.4

Save the replacement after adding.

Second, the execution file takes effect

resolvconf -u

It will take effect after executing the file. Of course, it is best to restart the server and check the resolv.conf file to see if there are two more lines in the file.

This way we can see that the DNS will not disappear due to restarting the server.

Recommended site search: overseas server rental price, high-defense US server, cloud server, free virtual host, asp host, vps host, overseas virtual host space, domain name registration website, mobile proxy ip, website virtual host space, < /p>

Solve the problem of failure of changing DNS configuration and restarting under ubuntu server

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码