1.宿主机和虚拟机互相访问

a.虚拟机采用主机模式(host-only),点击虚拟机网络适配器,配置ip,

virtual box配置ubuntu网络访问

virtual box配置ubuntu网络访问

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.虚拟机访问外网

如果上网是无线上网,选择无线网络连接

virtual box配置ubuntu网络访问

virtual box配置ubuntu网络访问


如果虚拟机网络适配器对应的ip变了,需要手动再改回来。

virtual box配置ubuntu网络访问

virtual box配置ubuntu网络访问


测试:

虚拟机:ping www.baidu.com

相关文章:

  • 2022-01-16
  • 2021-04-04
  • 2021-11-12
  • 2022-12-23
  • 2021-09-21
  • 2021-09-08
  • 2021-09-01
猜你喜欢
  • 2021-10-25
  • 2021-07-05
  • 2022-12-23
  • 2021-05-04
  • 2021-08-08
  • 2021-11-11
相关资源
相似解决方案