首先虚拟机和主机之间采用桥接模式
然后在虚拟机中进行设置,首先进入到目录
/etc/sysconfig/network-scripts/
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# ls
ifcfg-eth0 ifdown-eth ifdown-post ifdown-tunnel ifup-eth ifup-plip ifup-routes init.ipv6-global
ifcfg-lo ifdown-ippp ifdown-ppp ifup ifup-ippp ifup-plusb ifup-sit net.hotplug
ifdown ifdown-ipv6 ifdown-routes ifup-aliases ifup-ipv6 ifup-post ifup-tunnel network-functions
ifdown-bnep ifdown-isdn ifdown-sit ifup-bnep ifup-isdn ifup-ppp ifup-wireless network-functions-ipv6
[root@localhost network-scripts]# 我们编辑
ifcfg-eth0
添加内容如下:采用dhcp模式
DEVICE=eth0
HWADDR=00:0C:29:0D:7F:46
TYPE=Ethernet
UUID=87c470b0-2ca6-44cd-ae81-37c87ad60c83
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
然后重启network 服务就可以了
service network restart