最好的办法就是使用两块网卡,NAT(虚拟机访问互联网,使用10.0.2.X段)和host-only(虚拟机和主机互相通信,使用192.168.56.X段).


VirtualBOX Ubuntu14.04网络设置
 

注意:需要将虚拟机关闭后,才能添加虚拟机的网卡

 
VirtualBOX Ubuntu14.04网络设置


VirtualBOX Ubuntu14.04网络设置 

VirtualBOX Ubuntu14.04网络设置
 
 
VirtualBOX Ubuntu14.04网络设置


 
 
VirtualBOX Ubuntu14.04网络设置
 


 

 

eth0不需设置gateway,设置了会导致无法访问外网

 

 

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.56.106
netmask 255.255.255.0

auto eth1
iface eth1 inet dhcp
~                      

 

 

注意不能设置GATEWAY,原因:Linux双网卡默认路由问题: 在安装第二块网卡后出现无法上网问题,使用route发现是默认路由出现问题

相关文章: