Linux报错ping: https://www.baidu.com: Name or service not known

问题:

[root@localhost104 softwares]# ping https://www.baidu.com
ping: https://www.baidu.com: Name or service not known

没有默认的网关,需要添加

[root@localhost104 softwares]# route -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0             0.0.0.0     0.0.0.0         UG    0      0        0 ens33
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 ens33
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 ens33
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0

[root@localhost104 softwares]# cat /etc/resolv.conf

# Generated by NetworkManager
nameserver 8.8.8.8
nameserver 114.114.114.114
search localhost104

[root@localhost104 softwares]# grep GATEWAY /etc/sysconfig/network-scripts/ifcfg*

/etc/sysconfig/network-scripts/ifcfg-ens33:GATEWAY=192.168.0.1

[root@localhost104 softwares]# grep hosts /etc/nsswitch.conf

#hosts:     db files nisplus nis dns
hosts:      files dns myhostname

[root@localhost104 softwares]# route add default gw 192.168.0.1

[root@localhost104 softwares]# ping www.baidu.com

PING www.a.shifen.com (14.215.177.38) 56(84) bytes of data.
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=1 ttl=55 time=7.04 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=2 ttl=55 time=8.16 ms
^Z
[5]+  Stopped                 ping www.baidu.com

[root@localhost104 softwares]# route -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 ens33
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 ens33
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 ens33
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
发布了118 篇原创文章 · 获赞 26 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/qq_43147136/article/details/84853106