详细教程见:http://blog.****.net/liukun321/article/details/6662950
1、虚拟机中的centos系统要连接外网,我们需要使用桥接网络
2、正常配置eth0网口
DEVICE=eth0
HWADDR=00:0C:29:EF:00:83
TYPE=Ethernet
UUID=7493ecea-c1d2-4edc-a4f1-8381956c87cc
ONBOOT=yes #开机启动
NM_CONTROLLED=yes
BOOTPROTO=static #使用静态ip
IPADDR=192.168.0.222 #主机所在网络中的ip地址
NETMASK=255.255.255.0
DNS1=114.114.114.114
DNS2=192.168.0.1 #网关地址作为DNS
3、service network restart
4、route add default gw 192.168.0.1 #这里根据局域网网络ip的不同,网关不同
5、route 查看
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 1002 0 0 eth0
default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
然后就可以了
6、vi /etc/resolv.conf
nameserver 114.114.114.114
nameserver 8.8.8.8
7、尝试ping www.baidu.com