Solve the ping failure problem of centos 6.7 ping: unknown host on the Internet
1. confirm that the NIC settings are correct.
vim /etc/sysconfig/network-scripts/ifcfg-eth*
The IP address must be in the same CIDR block as the gateway. For a virtual machine, make sure that the virtual machine ip address gateway and Host ip address are in the same network segment.
2. Check whether the route settings are correct.
After the first step is correct, the virtual machine can ping the host and the gateway can also ping the host. At this time, you can use the route-n command to view the system's route settings. For example, if my eth0 IP address is 192.168.0.100 and the gateway is 192.168.0.1, you should have a route set to any address connected to the Internet:
Kernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
Destination indicates that the Destination address 0.0.0.0 represents any address (if you have special requirements, you can set it yourself. Here, we only use any address as an example) Gateway indicates the Gateway, Iface indicates the NIC used by the Destination address, you can learn the route command by yourself.
3. Check whether iptables (firewall) is correctly configured.
Firewall knowledge is not explained here. If your machine does not have security requirements, you can disable the firewall.
service iptables stop
4. Set the dns server
vim etc/resolv.conf
Add the following content
nameserver 8.8.8.8