After setting up DNS in/etc/resolv.conf , the file is overwritten each time you restart Ubuntu server, and some workarounds are found for this situation
Methods to prevent/etc/resolv.conf from being overwritten
Method One
1. Need to create a file/etc/resolvconf/resolv.conf.d/tail
sudo vi/etc/resolvconf/resolv.conf.d/tail
2. Write the DNS server you need in the file in the same format as/etc/resolv.conf
NameServer 8.8. 8.8
3. Restart the RESOLVCONF program
sudo/etc/init.d/resolvconf restart
Then look at the/etc/resolv.conf file and you can see that the DNS server you added is already in the file
Method Two
In the/etc/network/interfaces
# # #interfaces中 ###### #auto eth0 iface eth0 inet static192.168. 3.250 255.255. 255.0 #子网掩码 192.168. 3.1 #网关 DNS8.8. 8.88.8. 4.4 #设置dns服务器
Issues that are overwritten when resolv.conf is restarted in Ubuntu Server