Solution to ping Baidu in Linux
I encountered a problem when I learned about DNS today. My virtual machine can ping the IP address but cannot ping www.baidu.com www.qq.com or other domain names. First, the following error occurs:
After several hours, I finally found a solution.
1. Check whether the virtual machine can ping the Internet. You can ping the gateway.
ping 172.17.0.1
[Plain] view plaincopy
2. Make sure that the gateway is configured
[Plain] view plaincopy
Vim/etc/sysconfig/network-scripts/ifcfg-eth1
[Plain] view plaincopy
GATEWAY = 172.17.0.1
DNS1 = 172.17.0.1
After the modification, You need to restart the network service. Centos6:
Service network restart
3. Make sure there are available domain name servers
Cat/etc/resolv. conf
If not, edit one by yourself.
[Plain] view plaincopy
Vim/etc/resolv. conf
Nameserver 172.17.0.1
Nameserver 114.114.114.114
In this case, there is no problem.
But I still encountered a problem.
It should still be a network problem. I restarted the network service, but it still doesn't work.
So I checked the route table and found that a default route record is missing.
Add a route record.
Failed to add
We had to clear the path with records
Restart the network service, add the default route, and then parse the address.
.