第一步:对创建的vm配置NAT+Host-only Aadpter,,具体virtualbox操作如下截图所示:
其中,VirtualBox Host-Only Ethernet Adapter #2配置如下:
第二步:登录虚拟机,进行相关配置:
vim /etc/network/interfaces
结果如下图所示:
# 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(NAT)
auto enp0s3
iface enp0s3 inet dhcp
# 增加的Host-only静态IP设置
auto enp0s8
iface enp0s8 inet static
#192.168.56.xxxx这个你自己随便写,根据实际情况
address 192.168.56.11
netmask 255.255.255.0
第三步:重启Ubuntu中的网络服务
sudo /etc/init.d/networking restart
通过windows Ping ubuntu ,和ubuntu ping windows 来检测两边是否都能ping通
注意:
NAT网络,负责上外网通信;
Host-Only网络,负责主机和虚机通信。