VirtualBox 使多个虚拟机处在同一个局域网 作者: Chuwen 时间: 2021-12-26 分类: VirtualBox 评论 这里以 macOS 下举例子了,Windows 平台找到类似的菜单设置即可 1. 打开:管理 -> 主机网络管理器  2. 然后创建  3. 假设我们创建得到的是 **vboxnet2**,然后按照图中进行配置,配置完成后点击 应用 即可 > 需要启用 DHCP 服务器,不然主机没办法自动获取到 IP 地址  4. 选择一个你创建的虚拟机,然后点击设置  5. 配置网络,然后点击 OK 保存  6. 进入虚拟机查看 IP 地址,使用 `ip addr` 命令查看  7. 如果你有多个虚拟机想要在同一个局域网,那么再从**第 4 步骤**再设置其它虚拟机即可,配置好后,可以通过 `ip addr` 获取本机的 IP 地址,然后用另一台虚拟机使用 ping 命令看是否能够 ping 通  希望能这片够对你有所帮助,我也是前前后后花了许多时间去理解,现在大致能够知道怎么去使用,甚至搭建一个旁路由
解决 VirtualBox Error creating machine: Error in driver during machine creation: Error setting up host only network on machine start 作者: Chuwen 时间: 2021-12-14 分类: VirtualBox 评论 执行命令 `docker-machine create --driver virtualbox master` 创建虚拟网卡报错: ```log Running pre-create checks... Creating machine... (master) Copying /Users/chuwen/.docker/machine/cache/boot2docker.iso to /Users/chuwen/.docker/machine/machines/master/boot2docker.iso... (master) Creating VirtualBox VM... (master) Creating SSH key... (master) Starting the VM... (master) Check network to re-create if needed... (master) Found a new host-only adapter: "vboxnet0" Error creating machine: Error in driver during machine creation: Error setting up host only network on machine start: /usr/local/bin/VBoxManage hostonlyif ipconfig vboxnet0 --ip 192.168.99.1 --netmask 255.255.255.0 failed: VBoxManage: error: Code E_ACCESSDENIED (0x80070005) - Access denied (extended info not available) VBoxManage: error: Context: "EnableStaticIPConfig(Bstr(pszIp).raw(), Bstr(pszNetmask).raw())" at line 242 of file VBoxManageHostonly.cpp ``` 搜到的相关链接: - https://www.bookstack.cn/read/Minikube-1.24-en/ad8abb690946c9ec.md 原因:**在 Linux、Mac OS X 和带有 VirtualBox >= 6.1.28 的 Oracle Solaris 上,默认情况下,仅主机网络只允许 192.68.56.0/21 范围内的 IP 地址。** 然而 docker-machine 指定创建(VBoxManage hostonlyif ipconfig vboxnet0 --ip192.168.99.1 --netmask 255.255.255.0)`192.168.99.1/24` 的网段,这就导致创建失败 ## 解决办法 1.VirtualBox 降级到 `6.1.28` 之前的版本,可以从这里下载:https://www.virtualbox.org/wiki/Download_Old_Builds_6_1 我下载的是 `6.1.26` (注意我下载的是 macOS X 版本):https://download.virtualbox.org/virtualbox/6.1.26/VirtualBox-6.1.26-145957-OSX.dmg 成功运行了 2.执行以下命令: > **我自己测试是失败的** ```shell sudo mkdir -p /etc/vbox sudo vim /etc/vbox/networks.conf ``` 内容填写 `* 10.0.0.0/8` 然后保存即可 --- #### 你在 Big Sur 安装,可能会遇到的: ``` Kernel driver not installed (rc=-1908) Make sure the kernel module has been loaded successfully. where: suplibOsInit what: 3 VERR_VM_DRIVER_NOT_INSTALLED (-1908) - The support driver is not installed. On linux, open returned ENOENT. ``` 解决办法:https://apple.stackexchange.com/questions/410529/virtualbox-does-not-work-after-upgrading-to-big-sur 简要概述: - 重启到恢复模式 -> 终端 -> 运行命令 `spctl kext-consent add VB5E2TV963` - 最后重启进系统即可