使用 Vagrantfile 配置私网 ip 导致运行 vagrant up 时终端输出神秘错误

使用 Vagrantfile 配置私网 ip 导致运行 vagrant up 时终端输出神秘错误
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "jasonc/centos7"

  config.vm.define "test1" do |test1|
    test1.vm.hostname = "test1"
    test1.vm.network "private_network", ip: "10.9.8.5"
end

config.vm.define "test2" do |test2|
  test2.vm.hostname = "test2"
  test2.vm.network "private_network", ip: "10.9.8.6"
end

我正在使用 vagrant 设置两个虚拟机,当我尝试编辑 vagrantfile 来设置虚拟机 IP 时遇到了问题。运行“vagrant up”后,我看到了一条非常神秘的消息

~/shellclass/multitest$ vagrant up test2 Bringing machine 'test2' up with 'virtualbox' provider...
==> test2: Importing base box 'jasonc/centos7'...
==> test2: Matching MAC address for NAT networking...
==> test2: Checking if box 'jasonc/centos7' version '1.4.4' is up to date...
==> test2: Setting the name of the VM: multitest_test2_1656346764547_30766
==> test2: Clearing any previously set network interfaces... There was an error while executing `VBoxManage`, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.

Command: ["hostonlyif", "ipconfig", "vboxnet4", "--ip", "10.9.8.1", "--netmask", "255.255.255.0"]

Stderr: 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

访问被拒绝(扩展信息不可用)VBoxManage:错误:上下文:“EnableStaticIPConfig(Bstr(pszIp).raw(),Bstr(pszNetmask).raw())”位于文件 VBoxManageHostonly.cpp 的第 242 行

该块指向一个名为 VboxManageHostOnly.cpp 的文件,但我从未触碰过该文件。

相关内容