首页 > 代码库 > Linux DNS 设置失败
Linux DNS 设置失败
在执行 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 NetworkManagerMangager off
2、#Add Default Net Manager
chconfig 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
成功
本文参考http://wenku.baidu.com/link?url=HdeBL7k6lihJId-zQwmIHw5mKswm4d7lS8P-YRHb7IgBpKYlRMXNVO5sFxgDS7BgwRN9v2iX5a5C9NbgMqQ0DTJPSH1CIb47_VqzxRdUhcW
Linux DNS 设置失败