无法创建具有可访问网络接口的VM

时间:2018-01-12 07:33:54

标签: windows ubuntu vagrant virtualbox ubuntu-17.10

我开始创建一个新的VM用于开发,因为我的ubuntu 14.4似乎已经过时了。

我决定将来切换到ubuntu 17.10,但首次安装失败。

这是我的流浪文件:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

    config.vm.provider "virtualbox" do |vb|
        vb.gui = false
        vb.memory = "1024"
    end

    config.vm.box = "generic/ubuntu1710"
    config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: false
    config.vm.network "private_network", ip: "192.168.37.200"

end

在配置期间我得到了这个

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

/sbin/ifdown 'eth1' || true
/sbin/ip addr flush dev 'eth1'
# Remove any previous network modifications from the interfaces file
sed -e '/^#VAGRANT-BEGIN/,$ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces.pre
sed -ne '/^#VAGRANT-END/,$ p' /etc/network/interfaces | tac | sed -e '/^#VAGRANT-END/,$ d' | tac > /tmp/vagrant-network-interfaces.post

cat \
  /tmp/vagrant-network-interfaces.pre \
  /tmp/vagrant-network-entry \
  /tmp/vagrant-network-interfaces.post \
  > /etc/network/interfaces

rm -f /tmp/vagrant-network-interfaces.pre
rm -f /tmp/vagrant-network-entry
rm -f /tmp/vagrant-network-interfaces.post

/sbin/ifup 'eth1'

Stdout from the command:



Stderr from the command:

bash: line 4: /sbin/ifdown: No such file or directory
bash: line 20: /sbin/ifup: No such file or directory

通过托管窗口无法使用本机。在配置之前我是否必须安装一些东西?或者你更喜欢hashicorb的另一个机器模板吗?

此致 n00n

1 个答案:

答案 0 :(得分:4)

Vagrant目前无法与Ubuntu 17.10一起使用,因为删除了传统的网络配置工具和文件:/sbin/ifup/sbin/ifdown

但您可以创建具有网络接口的vagrant VM,其解决方法如下:

<强> 1 将安装ifupdown添加到您的Vagrantfile中:

# -*- mode: ruby -*-
# vi: set ft=ruby :

$provision_script = <<PROVISION
    apt-get -y update
    apt-get install ifupdown -y
PROVISION

Vagrant.configure("2") do |config|
    config.vm.provision "shell", inline: $provision_script
    config.vm.provider "virtualbox" do |vb|
        vb.gui = false
        vb.memory = "1024"
    end

    config.vm.box = "generic/ubuntu1710"
    config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: false
    config.vm.network "private_network", ip: "192.168.37.200"
end

<强> 2 创建vagrant VM:

vagrant up

当然,它会因错误而失败。

第3 在刚刚创建的VM中启动配置脚本。它会使用必要的文件安装包ifupdown

vagrant provision

<强> 4 现在重新加载你的VM:

vagrant reload