1. 程式人生 > >Centos7+ ping www.baidu.com 報錯 name or service not know

Centos7+ ping www.baidu.com 報錯 name or service not know

修改配置

#檢視閘道器
[[email protected] ~]#  route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.112.2   0.0.0.0         UG    100    0        0 ens33
192.168.112.0   0.0.0.0         255.255.255.0   U     100    0        0 ens33
[[email protected]
~]# [[email protected] network-scripts]# pwd /etc/sysconfig/network-scripts [[email protected] network-scripts]# vi ifcfg-ens33 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static #*********注意************# DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE
=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens33 UUID=5cde921f-9ae2-4db5-b915-c2ab2cb8ffa9 DEVICE=ens33 ONBOOT=yes IPADDR=192.168.112.130 NETMASK=255.255.255.0 GATEWAY=192.168.112.2

修改 vi /etc/resolv.conf


[[email protected] network-scripts]# vi /etc/resolv.conf
# Generated by NetworkManager
nameserver 8.8
.8.8 nameserver 114.114.114.114

儲存退出,重啟閘道器

[[email protected] network-scripts]# service network restart
[[email protected] network-scripts]# ping www.baidu.com
PING www.a.shifen.com (220.181.112.244) 56(84) bytes of data.
64 bytes from 220.181.112.244 (220.181.112.244): icmp_seq=1 ttl=128 time=9.52 ms
64 bytes from 220.181.112.244 (220.181.112.244): icmp_seq=2 ttl=128 time=7.24 ms
64 bytes from 220.181.112.244 (220.181.112.244): icmp_seq=3 ttl=128 time=6.10 ms
^C
--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 6.104/7.624/9.523/1.421 ms