centos7 ping www.baidu.com ping 不通。
记录下,在搭建NodeJS服务器遇到的坑:centos7 ping www.baidu.com ping 不通。
1. 配置网卡 vi ifcfg-eth0
DEVICE=eth0
TYPE="Ethernet"
BOOTPROTO="static"
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
HWADDR=00:0c:29:1c:06:e5
NAME="eth0"
DEVICE="eth0"
ONBOOT="yes"
IPADDR="192.168.100.22"
NETMASK="255.255.255.0"
GATEWAY="192.168.100.1"
DNS1="192.168.95.1"
DNS2="168.95.192.1"
修改dns, 修改方法如下:
CentOS执行YUM安装文件时出现以下错误讯息 :
[root@localhost ~]# yum -y install net-snmpLoaded plugins: fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=addonserror was
[Errno 4] IOError: <urlopen error (-3, 'Temporary failure in name resolution')>
Error: Cannot find a valid baseurl for repo: addons
根据提示“urlopen error”,判定为连接错误
键入Ping mirrorlist.centos.org,发现ping不通,出现 ping: unknown host mirrorlist.centos.org 的讯息。
于是确认DNS的设定上是否有问题
方法一:
[root@localhost ~]# vi /etc/resolv.conf
显示如下:
; generated by /sbin/dhclient-script
search localdomain
nameserver 192.168.169.2
#加入以下适合的DNS
#GOOGLE的DNS
nameserver 8.8.8.8
nameserver 8.8.4.4
#中华电信
nameserver 168.95.1.1
nameserver 168.95.192.1
或是用此种方式加入
[root@localhost ~]# echo "nameserver 8.8.8.8" >> /etc/resolv.conf
[root@localhost ~]# echo "nameserver 8.8.4.4" >> /etc/resolv.conf
[root@localhost ~]# echo "nameserver 168.95.1.1" >> /etc/resolv.conf
[root@localhost ~]# echo "nameserver 168.95.192.1" >> /etc/resolv.conf
方法二:
# setup
到 Network configuration 选项下选择Edit DNS configurationon,然后添加dns服务器ip地址。退出保存。
加入或修改DNS后,再重新执行YUM应该就可以正常使用了。