# 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 WILL BE OVERWRITTEN 注意看:
1 /etc/resolv.conf is actually a Link
It actually points to /run/resolvconf/resolv.conf
3 If you want to define your own nameserver, there are two ways:
A Add in the configuration file /etc/network/interfaces of the network card:
dns-nameservers 192.168.3.45 192.168.8.10
dns-search foo.org bar.com
restart the network
sudo service networking restart or sudo /etc/init.d/networking restart
You can also restart the network card
sudo ifconfig eth0 down sudo ifconfig eth0 up
B Modify the configuration file of the resolvconf service: /etc/resolvconf/resolv.conf.d/base
echo "search test.com" >> /etc/resolvconf/resolv.conf.d/base
echo "nameserver 202.106.0.20 " >> /etc/resolvconf/resolv.conf.d/base
In this way, the configuration can be guaranteed to be written to /etc/resolv.conf even when the machine is restarted or the resolvconf service is restarted.
Restart the resolvconf service
service resolvconf restart
A has a higher priority than B, but the network may be disconnected.
Excerpted from: http://blog.csdn.net/liangdsh/article/details/70256039