Vagrant 無法在 Xubuntu 16.04 客戶機上啟動 eth1
我對 Linux 和 Vagrant 比較陌生。不久前,我將我的 VM 來賓系統(Windows 主機上的 VirtualBox 5.0.18 + Vagrant 1.8.1)從 Xubuntu 15.10 更新到了 Xubuntu 16.04。那時或在我注意到一些奇怪的東西之後不久,例如滑鼠游標未對齊(偏離幾個像素)和缺少共享目錄。我的猜測是,這是由於在 期間報告了以下錯誤
vagrant up
:==> default: Clearing any previously set forwarded ports... ==> default: Clearing any previously set network interfaces... ==> default: Preparing network interfaces based on configuration... default: Adapter 1: nat default: Adapter 2: hostonly ==> default: Forwarding ports... default: 8080 (guest) => 8080 (host) (adapter 1) default: 9000 (guest) => 9000 (host) (adapter 1) default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Running 'pre-boot' VM customizations... ==> default: Booting VM... ==> default: Waiting for machine to boot. This may take a few minutes... default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key ==> default: Machine booted and ready! GuestAdditions 5.0.18 running --- OK. ==> default: Checking for guest additions in VM... ==> default: Configuring and enabling network interfaces... The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed! /sbin/ifup eth1 Stdout from the command: Failed to bring up eth1. Stderr from the command: mesg: ttyname failed: Inappropriate ioctl for device run-parts: /etc/network/if-up.d/ubuntu-fan exited with return code 1
我在網上結合 Vagrant 和 VirtualBox 尋找錯誤,但我發現的案例似乎與我的有點不同。人們寫的
/etc/udev/rules.d/70-persistent-net.rules
- 但它似乎不存在於我的機器上,也不存在/etc/sysconfig
。登錄後嘗試執行
/sbin/ifup eth1
以獲取更多資訊會給我以下資訊:vagrant@IDE-machine ~ $ sudo /sbin/ifup -v eth1 Configuring interface eth1=eth1 (inet) /bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d run-parts: executing /etc/network/if-pre-up.d/bridge run-parts: executing /etc/network/if-pre-up.d/ethtool run-parts: executing /etc/network/if-pre-up.d/wireless-tools run-parts: executing /etc/network/if-pre-up.d/wpasupplicant /bin/ip addr add 192.168.56.21/255.255.255.0 broadcast 192.168.56.255 dev eth1 label eth1 RTNETLINK answers: File exists Failed to bring up eth1.
我的 Vagrant 文件如下所示:
Vagrant.configure(2) do |config| # a locally stored box config.vm.box = "IDE-machine" config.ssh.private_key_path = "ssh/id_rsa" config.vm.network "forwarded_port", guest: 8080, host: 8080 config.vm.network "forwarded_port", guest: 9000, host: 9000 config.vm.network "private_network", ip: "192.168.56.21" config.vm.provider "virtualbox" do |vb| vb.gui = true vb.memory = "12288" vb.cpus = 2 vb.name = "my_IDE-machine" vb.customize ["modifyvm", :id, "--monitorcount", "1"] vb.customize ["modifyvm", :id, "--vram", "64"] vb.customize ["storageattach", :id, "--storagectl", "SATA", "--port", 1, "--device", 0, "--type", "hdd", "--medium", "V:/BoxStorage/Projects.vdi"] end config.vm.provision "shell", inline: "/vagrant/provision.sh" end
安裝了來賓添加,我使用了
vagrant-vbguest
之前設置正確的來賓外掛版本的外掛。有人知道可能是什麼問題,或者暗示我如何進一步探勘?
更新: 有人指出我:https ://github.com/mitchellh/vagrant/issues/7155 (這並不完全適用於我的情況)這導致我這樣做:https ://askubuntu.com/questions/689070 /network-interface-name-changes-after-update-to-15-10-udev-changes/732638#732638
我嘗試使用 更改
/etc/default/grub
,GRUB_CMDLINE_LINUX="net.ifnames=0"
然後update-grub
以 root 身份重新啟動,但無濟於事。更多的探索向我展示了這一點:
vagrant@IDE-machine ~ $ cat /etc/network/interfaces # interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback #VAGRANT-BEGIN # The contents below are automatically generated by Vagrant. Do not modify. auto eth1 iface eth1 inet static address 192.168.56.21 netmask 255.255.255.0 #VAGRANT-END
**更新 2:**這裡要求的是 dmesg 的輸出和 ubuntu-fan 的內容:
vagrant@IDE-machine ~ $ dmesg | grep eth [ 1.692133] e1000 0000:00:03.0 eth0: (PCI:33MHz:32-bit) 08:00:27:af:31:b4 [ 1.692144] e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection [ 2.068113] e1000 0000:00:08.0 eth1: (PCI:33MHz:32-bit) 08:00:27:94:1e:dc [ 2.068120] e1000 0000:00:08.0 eth1: Intel(R) PRO/1000 Network Connection [ 5.732516] e1000: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX [ 5.732980] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready [ 5.733061] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready [ 6.790923] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready [ 6.793512] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready [ 6.795646] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX [ 6.796069] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
vagrant@IDE-machine ~ $ cat /etc/network/if-up.d/ubuntu-fan #!/bin/sh set -e case "$IFACE" in lo) exit 0 ;; fan-*) exit 0 ;; esac case "$ADDRFAM" in inet) ;; *) exit 0 ;; esac # NOTE: NetworkManager simply does not call out to the normal # down hooks as it only checks _after_ the interface has # been lost. Roll with this. case "$PHASE::$METHOD" in post-up::static|post-up::dhcp|post-up::NetworkManager) ;; pre-down::static|pre-down::dhcp|post-down::NetworkManager) ;; *) exit 0 ;; esac case "$MODE" in start|stop) ;; *) exit 0 ;; esac /usr/sbin/fanctl net "$MODE" "$IFACE"
你檢查你的
/etc/network/interfaces
配置文件了嗎?也許您有幾個網關,正如這裡指出的那樣。無論如何,稍微調整一下該文件並使用
ifconfig
可以幫助您解決問題。還要檢查權限,我懷疑它來自那裡,但仍然:/
/etc/network/interfaces
如果還不是這樣,您可以嘗試返回到更簡單的配置,然後一點一點地返回到原始配置文件。我會這樣做,我想。編輯:從您的
dmesg
輸出看來,連結已準備就緒,因此網路部分應該沒問題。如果製作dmesg | grep eth
,有沒有相關資料?另外,你會貓
/etc/network/if-up.d/ubuntu-fan
嗎?它以退出程式碼 1 退出,檢查那裡發生的事情可能會很有趣。更新:
您
dmesg
的輸出似乎沒問題,連結 eth0/1 最終準備就緒,因此網路應該可以正常工作。您應該嘗試
ubuntu-fan
逐行執行腳本並檢查退出程式碼(echo $?
應該是0
)。我想知道問題是否不是來自最後的fanctl
程序。它通常用於控制機器上的風扇,但這裡是一個虛擬機,所以……如果它來自這條線,你可以試著看看它為什麼失敗,但我會刪除這fanctl
條線,然後可能整個文件都在事實。我猜其他行是在這里處理要觸發的事件fanctl
。我檢查了我的流浪虛擬機(雖然主要是 ubuntu 14.04),但我在任何地方都看不到任何
fanctl
東西……我不確定嘗試控制虛擬機內的風扇是否有意義。