1.宿主机和虚拟机互相访问
a.虚拟机采用主机模式(host-only),点击虚拟机网络适配器,配置ip,
b.配置固定ip,注意ens33可以通过ifconfig查看,此处配置错误名字,网络服务重启将失败
vim /etc/network/interfaces
auto lo
iface lo inet loopback
增加
auto ens33
iface ens33 inet static
address 192.168.1.200
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8
重启生效
sudo /etc/init.d/networking restart
配置网关
sudo vim /etc/resolv.conf
增加
nameserver 192.168.1.1
重启生效
sudo /etc/init.d/networking restart
c.测试
虚拟机:ping 192.168.1.1
宿主机:ping 192.168.1.200
2.虚拟机访问外网
如果上网是无线上网,选择无线网络连接
如果虚拟机网络适配器对应的ip变了,需要手动再改回来。
测试:
虚拟机:ping www.baidu.com