在执行 yum install gcc 时 发现下载失败
ping www.baidu.com
ping 不通
ping 百度的IP:220.181.111.188却能ping 通
由此证明是DNS的问题
百度后查到设置DNS 需要运行命令:vi /etc/resolv.conf
添加:
nameserver 192.168.0.1
nameserver 192.168.0.1
然而运行vi /etc/resolv.conf后提示:
# Generated by NetworkManager
search An
# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com
于是运行 vi /etc/sysconfig/network-scripts/ifcfg-eth0
添加
DNS1=192.168.0.1
DNS2=192.168.0.1
DOMAIN=lab.foo.com bar.foo.com
运行service network restart
发现还是ping 不通
运行 vi /etc/resolv.conf 发现添加的nameserver 丢失
网络搜索后找到解决方案:
1、#Remove network Manager from startup service
chkconfig NetworkManager off
2、#Add Default Net Manager
chkconfig network on
3、Stop NetworkManager first
service NetworkManager stop
4、#and then start Default Manager
service network start
5、#restart network
service network restart
重新配置DNS配置文件,重启网络
ping www.baidu.com
成功。
ubuntu DNS出错,用以下命令可以解决:http://www.linuxdiyf.com/linux/14395.html
ubuntu/debian禁用ipv6模块后能提高DNS解析的速度:http://www.linuxdiyf.com/linux/14264.html
Ubuntu 15.04配置静态IP和DNS:http://www.linuxdiyf.com/linux/14252.html
ubuntu 14.04 64 bit上开启nscd服务缓存加速及清除dns缓存:http://www.linuxdiyf.com/linux/13923.html
在Ubuntu 14.04 64bit中永久添加DNS的方法:http://www.linuxdiyf.com/linux/13922.html