解决 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` - 最后重启进系统即可