Ubuntu set a static IP address, set up DNS, open/etc/resolv.conf
Cat/etc/resolv.conf
# Dynamic resolv.conf (5) file for glibc resolver (3) generated by resolvconf (8)
# do not EDIT this FILE by HAND--YOUR changes'll be overwritten
This section warns that this file is created dynamically by the RESOLVCONF program and is not recommended to be edited directly, and the modified value may be overwritten.
Sure enough, the restart will fail after the change.
There are two ways of setting up DNS:
method One: through/etc/network/interfaces, at the end of it add a sentence (multiple DNS separated by a space):
Dns-nameservers 202.97.224.68 202.97.224.69
202.97.224.68 is a DNS service for Unicom. DNS will take effect after reboot, at which point the/etc/resolv.conf file will have one more line:
# Dynamic resolv.conf (5) file for glibc resolver (3) generated by resolvconf (8)
# do not EDIT this FILE by HAND--YOUR changes'll be overwritten
NameServer 202.97.224.68
NameServer 202.97.224.69
method Two : by modifying the/etc/resolv.conf (this file is empty by default)
Insert Inside:
NameServer 202.97.224.68
NameServer 202.97.224.69
If you have multiple DNS, one line
Modify the Save and then execute:
Resolvconf-u
Look at/etc/resolv.conf, the bottom is more than 2 lines:
Cat/etc/resolv.conf
# Dynamic resolv.conf (5) file for glibc resolver (3) generated by resolvconf (8)
# do not EDIT this FILE by HAND--YOUR changes'll be overwritten
NameServer 202.97.224.68
NameServer 202.97.224.69
You can see that the set of multiple DNS has been added, and then ping Baidu, immediately can be resolved without restarting.
Ubuntu Configuring multiple DNS