使用 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 的文件,但我從未接觸過該文件。

相關內容