- Do not manually modify the file directly/etc/resolv.conf
After installing Ubuntu, the static IP address is set and the domain name cannot be resolved after restarting. Want to reset 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
The content is a warning: say this file is created dynamically by the RESOLVCONF program, do not edit directly, the modification will be overwritten.
[Email protected]:~# cat/etc/resolv.conf# Dynamic resolv.conf (5) file for glibc Resolver (3) generated by resolvconf (8)#Don't EDIT this FILE by HAND--YOUR changes would be OVERWR Ittennameserver 100.100.2.138100.100.2.136options Timeout:2 attempts:3 rotate single-request-reopenroot@Ubuntu14: ~#
There are two ways to modify DNS in Ubuntu.
- Method One: Modify the file/etc/resolvconf/resolv.conf.d/base
[Email protected]:~#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 overwrittenNameServer 100.100.2.138nameserver100.100.2.136Options Timeout:2 Attempts:3 Rotate single-request-Reopenroot@Ubuntu14: ~#Vim/etc/resolvconf/resolv.conf.d/base[Email protected]:~#Cat!$cat/etc/resolvconf/resolv.conf.d/Basenameserver223.5.5.5nameserver223.6.6.6Root@Ubuntu14: ~#Resolvconf-u[Email protected]:~#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 overwrittenNameServer 100.100.2.138nameserver100.100.2.136nameserver223.5.5.5Options Timeout:2 Attempts:3 Rotate single-request-Reopenroot@Ubuntu14: ~#nslookup www.baidu.comserver:100.100.2.138Address:100.100.2.138# -Non-authoritative answer:www.baidu.com canonical name=www.a.shifen.com.Name:www.a.shifen.comAddress:220.181.112.244name:www.a.shifen.comaddress:220.181.111.188Root@Ubuntu14: ~#
- Method Two: Modify the file/etc/network/interdaces
[Email protected]:~# cat/etc/network/interfacesauto loiface lo inet loopbackauto eth0iface eth0 inet dhcpdns-nameservers 223.5.5.5 # Add this line at the end
The caching method for Linux refresh DNS is: SUDO/ETC/INIT.D/NSCD restart
The most violent way to brush DNS, restart network: sudo/etc/init.d/networking restart
To view the current DNS parsing situation:
Nslookup www.baidu.com
Dig | grep SERVER
[Email protected]:~#/etc/init.d/nscd Restart*restarting Name Service Cache Daemon NSCD [OK]root
@iZbp1b66g5htibj2m7yyv3Z: ~#/etc/init.d/networking RestartStop:job failed whileStoppingstart:job is already running:networkingroot@iZbp1b66g5htibj2m7yyv3Z: ~#Dig |grep SERVER;; server:100.100.2.138#(100.100.2.138)[Email protected]:~#nslookup www.baidu.comserver:100.100.2.138Address:100.100.2.138# -Non-authoritative answer:www.baidu.com canonical name=www.a.shifen.com.Name:www.a.shifen.comAddress:220.181.111.188name:www.a.shifen.comaddress:220.181.112.244Root@iZbp1b66g5htibj2m7yyv3Z: ~#
Ubuntu Modify DNS Configuration