VirtualBox Network设置的NAT和Bridged Adapter模式区别

网友投稿 939 2022-05-29

区别:

NAT模式下,虚拟机仍然可以访问网络,但是从网络接收者的眼中看来,这些网络请求都来自宿主机,而感知不到虚拟机。外网也无法访问虚拟机网络。虚拟机和宿主机器的IP地址在不同的子网,比如192.168.1.1和192.168.1.2。

帮助文档提到,如果你只是想单纯的在虚拟机里访问网络,使用NAT足够了。

Host-Only: 虚拟机仍然被分配一个IP地址,但是只有在虚拟机运行的环境里可以访问这个IP地址。该地址对外界不可见。

Bridged:虚拟机有独立的IP地址,能被网络上其他主机访问。

VirtualBox的帮助文档:

https://www.virtualbox.org/manual/ch06.html

VirtualBox可以虚拟化以下六种物理网卡:

VirtualBox官网有个表格,非常清晰地展示了几种网络模式的区别:

第一列VM <-> Host: 表明虚拟机和宿主机是否可以通过网络互相访问。

第二列VM1 <-> VM2: 表明虚拟机之前是否能够通过网络相互访问

第三列VM -> Internet: 虚拟机是否可以访问网络

第四列VM <- Internet: 网络是否可以访问虚拟机

我在启动minikube时,遇到如下错误消息:

Starting local Kubernetes v1.10.0 cluster…

Starting VM…

E1010 03:27:37.920050 4827 start.go:174] Error starting host: Error creating host: Error executing step: Running precreate checks.

: We support Virtualbox starting with version 5. Your VirtualBox install is “WARNING: The vboxdrv kernel module is not loaded. Either there is no module available for the current kernel (3.10.0-862.11.6.el7.x86_64) or it failed to load. Please recompile the kernel module and install it by sudo /sbin/vboxconfig You will not be able to start VMs until this problem is fixed. 5.2.18r124319”. Please upgrade at https://www.virtualbox.org.

Retrying.

E1010 03:27:37.921090 4827 start.go:180] Error starting host: Error creating host: Error executing step: Running precreate checks.

: We support Virtualbox starting with version 5. Your VirtualBox install is “WARNING: The vboxdrv kernel module is not loaded. Either there is no module available for the current kernel (3.10.0-862.11.6.el7.x86_64) or it failed to load. Please recompile the kernel module and install it by sudo /sbin/vboxconfig You will not be able to start VMs until this problem is fixed. 5.2.18r124319”. Please upgrade at https://www.virtualbox.org

核心是这个错:

The vboxdrv kernel module is not loaded.

执行命令行:

rcvboxdrv setup

结果:

vboxdrv.sh: Stopping VirtualBox services.

vboxdrv.sh: Starting VirtualBox services.

vboxdrv.sh: Building VirtualBox kernel modules.

This system is currently not set up to build kernel modules.

Please install the gcc make perl packages from your distribution.

Please install the Linux kernel “header” files matching the current kernel

for adding new hardware support to the system.

VirtualBox Network设置的NAT和Bridged Adapter模式区别

The distribution packages containing the headers are probably:

kernel-devel kernel-devel-3.10.0-862.11.6.el7.x86_64

解决方案:

1. 按照这篇文章的介绍安装gcc make perl package:

2. 安装kernel header文件。参考:

3. 执行命令行:

rcvboxdrv setup

确保看到消息:

vboxdrv.sh: Building VirtualBox kernel modules.

这个vboxdrv的作用,VirtualBox的帮助文档写的很清楚:

In order to run other operating systems in virtual machines alongside your main operating system, VirtualBox needs to integrate very tightly into the system. To do this it installs a “driver” module called vboxdrv which does a lot of that work into the system kernel, which is the part of the operating system which controls your processor and physical hardware. Without this kernel module, you can still use the VirtualBox manager to configure virtual machines, but they will not start.

我简单翻译一下:

为了在宿主机里以虚拟机的方式运行其他类型的操作系统,VirtualBox需要和宿主机操作系统的Kernel交互,进行交互的模块就称为vboxdrv驱动,它本身也是操作系统的一部分,负责控制操作系统的CPU和其他硬件资源。如果没有vboxdrv驱动,我们虽然仍旧可以使用VirtualBox manager来管理虚拟机,但无法在宿主系统上启动这些虚拟机。

rcvboxdrv setup执行后问题解决。

要获取更多Jerry的原创文章,请关注公众号"汪子熙".

NAT NAT网关 NAT 虚拟化

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:如何使用ASP.NET技术构建一个容器并发布成ModelArts在线服务
下一篇:从一个简单的Java单例示例谈谈并发(上)
相关文章