CentOS: how to fix error ping Name or service not known

root@tutorialspots ~]# ping google.com

ping: google.com: Name or service not known

How to fix it?
Method 1:
Check file /etc/resolv.conf:

1

2

3

4

[root@tutorialspots ~]# cat /etc/resolv.conf

# Generated by NetworkManager

search nocix.net

nameserver 127.0.0.1

Add theses lines:

1

2

nameserver 8.8.8.8

nameserver 8.8.4.4

Done!, now you can ping

1

2

3

4

[root@tutorialspots ~]# ping google.com

PING google.com (172.217.12.78) 56(84) bytes of data.

64 bytes from dfw28s05-in-f14.1e100.net (172.217.12.78): icmp_seq=1 ttl=52 time=

40.8 ms

But every time when you restart the computer your /etc/resolv.conf will be replaced by default.

你可能感兴趣的:(CentOS: how to fix error ping Name or service not known)