unknown host ping solve a problem under Linux virtual machine

When using CentOS6.5 in a virtual machine, ping www.baidu.com error message appears: "ping: unknown hostwww.baidu.com", virtual and physical machines connected to the network is NAT mode, access Internert normal physical machines, virtual machines It may be the network card settings, gateway settings, DNS settings as a result can not connect to external networks.

1. Check the NIC setting: vim / etc / sysconfig / network-scripts / ifcfg-eth0 

 If the NIC IP for static IP that is BOOTPROTO = static, then try to get to a dynamic IP, namely BOOTPROTO = dhcp

 Then take a look at ping www.baidu.com

 

 2. If the problem is not caused by a static IP, then try to set up a server gateway, DNS try:

 

First, set the gateway: vim / etc / sysconfig / network file open add GATEWAY = 192.168.0.1

Second, set up DNS: After vim /etc/resolv.conf open the file directly to add or change the DNS1, DNS2 into the following two lines of code,

  nameserver 8.8.8.8

   nameserver 8.8.4.4

8.8.8.8,8.8.4.4 which is Google's preferred and alternate DNS of the IP,

        Can be replaced by domestic Primary and Secondary DNS the IP 221.228.225.1,114.114.114.114,

That nameserver 221.228.225.1

      nameserver 114.114.114.114

Then, check the routing table netstat -rn, if the routing table is not set Gateway, add the press in the following manner gateway (which corresponds to the LAN gateway IP routing local computer located in IP):

 route add default gw 192.168.0.1

    Finally, restart the network services, service network restart

Try to ping www.baidu.com

Guess you like

Origin www.cnblogs.com/puyi/p/11564072.html