[Root @ localhost ~] # Ping www.baidu.com
Ping: unknown host
This is because the DNS server is not configured properly. If the network is correct, perform the following steps:
1) vi/etc/resolv. conf
Add
Nameserver 192.168.59.2 gateway address of the Local Machine (vro address)
Search localdomain # search parameter specifies the domain name search order
2) set the Gateway
Vi/etc/sysconf/network-scripts/ifcfg-eth0
Add
GATEWAY = 192.168.59.2
Or
Set using commands
Route add default gw 192.168.59.2
Then restart the network service:
Service network restart
3) make sure DNS resolution is available
[Root @ localhost Desktop] # grep hosts/etc/nsswitch. conf
Output
Hosts: files dns
This file/etc/nsswith. conf is an extended name server switch developed by SUN. It is used to set the order in which files are read. If you want to read the/etc/hosts file first, you must first find the DNS server.
Hosts: files dns specifies to first find the/etc/hosts file. If the file fails, go to the DNS server to find the host information corresponding to the domain name.
4) test DNS
Ping www.centoscn.com