异常信息
[root@localhost ~]# yum -y updateLoaded plugins: fastestmirror, refresh-packagekit, securitySetting up Update ProcessLoading mirror speeds from cached hostfile * base: centos.ustc.edu.cn * extras: ftp.sjtu.edu.cn * updates: centos.ustc.edu.cnhttp://centos.ustc.edu.cn/centos/6.8/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'centos.ustc.edu.cn'"Trying other mirror.http://ftp.sjtu.edu.cn/centos/6.8/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'ftp.sjtu.edu.cn'"Trying other mirror.http://mirror.bit.edu.cn/centos/6.8/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirror.bit.edu.cn'"Trying other mirror.http://mirrors.163.com/centos/6.8/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirrors.163.com'"Trying other mirror.http://mirrors.aliyun.com/centos/6.8/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirrors.aliyun.com'"Trying other mirror.http://mirrors.cn99.com/centos/6.8/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirrors.cn99.com'"Trying other mirror......sssd-krb5-common-1.13.3-22.el6_8.6.x86_64: failure: Packages/sssd-krb5-common-1.13.3-22.el6_8.6.x86_64.rpm from updates: [Errno 256] No more mirrors to try. nss-tools-3.21.3-2.el6_8.x86_64: failure: Packages/nss-tools-3.21.3-2.el6_8.x86_64.rpm from updates: [Errno 256] No more mirrors to try. iscsi-initiator-utils-6.2.0.873-22.el6_8.x86_64: failure: Packages/iscsi-initiator-utils-6.2.0.873-22.el6_8.x86_64.rpm from updates: [Errno 256] No more mirrors to try. db4-4.7.25-20.el6_8.1.x86_64: failure: Packages/db4-4.7.25-20.el6_8.1.x86_64.rpm from updates: [Errno 256] No more mirrors to try.
1.服务器解析不了域名, ping mirrors.ustc.edu.cn 这个地址,发现 unknown host mirrors.ustc.edu.cn,ping www.baidu.com同样不行
[root@localhost ~]# ping mirrors.ustc.edu.cnping: unknown host mirrors.ustc.edu.cn
2.查看 /etc/resolv.conf 文件,发现没有设置域名服务
[root@localhost ~]# cat /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.comsearch localhost
3.查看网络配置文件,发现没有配置默认网关
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=eth0IPADDR=192.168.200.105NETMASK=255.0.0.0NETWORK=127.0.0.0# If you're having problems with gated making 127.0.0.0/8 a martian,# you can change this to something else (255.255.255.255, for example)BROADCAST=127.255.255.255ONBOOT=yesNAME=eth0
3.查看当前网关信息,发现默认网关不对
[root@localhost ~]# routeKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Ifacelink-local * 255.255.0.0 U 1002 0 0 eth0192.0.0.0 * 255.0.0.0 U 0 0 0 eth0
4.添加默认网关(虚拟机选择桥接模式配置下面信息)
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 #网卡名称#HWADDR=00:0C:29:3B:A3:99 MAC地址可以不写(与 /etc/udev/rules.d/70-persistent-net.rules 文件中的 ATTR{address}值一致就行)TYPE=Ethernet #网络类型(通常是Ethemet)UUID=3259a85a-c34c-4ecf-98e8-e1fe495c899f #随机数,唯一标识ONBOOT=yes #设置为yes,开机自动启用网络连接NM_CONTROLLED=yes #network mamager的参数 ,是否可以由NNetwork Manager托管BOOTPROTO=static #设置为none禁止DHCP,设置为static启用静态IP地址,设置为dhcp开启DHCP服务DNS1=192.168.200.1 #DNS 配置IPV6INIT=no #是否启用IPv6的接口USERCTL=no #是否允许非root用户控制该设备,设置为no,只能用root用户更改IPADDR=192.168.200.200 #指定静态ip地址NETMASK=255.255.255.0 #子网掩码GATEWAY=192.168.200.1 #默认网关
windows查看网关
控制面板 -->网络和Internet -->网络和共享中心 -->本地连接 -->详细信息
如图
5.重启网络
service network restart