比如,经常会遇到这样的问题**************************
[root@SourceCompiler local]# pwd
/usr/local
[root@SourceCompiler local]# ping www.baidu.com
ping: unknown host www.baidu.com
[root@SourceCompiler local]#
习惯做法是,
[root@SourceCompiler local]# vi /etc/resolv.conf
# Generated by NetworkManager
# 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
nameserver 8.8.8.8
一般,我们会这样的,但是发现带图形界面安装的CentOS6.5,会在每次开机,会自动清除掉/etc/resolv.conf,所追加的内容,为此。
CentOS 6.5静态IP的设置(NAT和桥接都适用)
解决办法:
[root@SourceCompiler local]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DNS1=192.168.80.2 //这个第一,很重要!!!自己的网关
DNS2=8.8.8.8
DNS3=114.114.114.114
DNS4=223.5.5.5
如下图
重启网卡,service network restart
ok。
[root@SourceCompiler local]# service network restart
Shutting down interface eth0: Device state: 3 (disconnected)
[ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/2
[ OK ]
[root@SourceCompiler local]# ping www.baidu.com
PING www.a.shifen.com (111.13.100.92) 56(84) bytes of data.
64 bytes from 111.13.100.92: icmp_seq=1 ttl=128 time=55.1 ms
64 bytes from 111.13.100.92: icmp_seq=2 ttl=128 time=55.1 ms
64 bytes from 111.13.100.92: icmp_seq=3 ttl=128 time=55.3 ms
^C
--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2698ms
rtt min/avg/max/mdev = 55.159/55.240/55.388/0.104 ms
[root@SourceCompiler local]#