vagrant up command giving error and eth1 not showi

2020-03-31 21:24发布

问题:

I am new to VMs, but have been using vagrant to run a Centos VM on Ubuntu 14.04. All of a sudden vagrant up command is giving this error:

root@shanky:~/centos# vagrant  up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'chef/centos-6.5' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Available bridged network interfaces:
1) eth0
2) wlan0
==> default: When choosing an interface, it is usually the one that is
==> default: being used to connect to the internet.
    default: Which interface should the network bridge to? 1
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 80 => 5444 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> 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: Warning: Connection timeout. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> 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!

ARPCHECK=no /sbin/ifup eth1 2> /dev/null

Stdout from the command:


Determining IP information for eth1...PING 10.1.34.1 (10.1.34.1) from 10.1.34.183 eth1: 56(84) bytes of data.

--- 10.1.34.1 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2999ms
pipe 3
PING 10.2.56.1 (10.2.56.1) from 10.2.56.156 eth1: 56(84) bytes of data.

--- 10.2.56.1 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3000ms
pipe 3
 failed.
Stderr from the command:

I am able to vagrant ssh to VM but eth1 is no longer giving a resolvable ip (i.e. it does not give inet addr paramater. How to resolve this?

P.S. https://unix.stackexchange.com/questions/188413/not-able-to-resolve-ip-address-for-eth1-in-vagrant-vm

I have tried some tinkering with eth1 as suggested in above link but to non avail. PLz help. Thanks.

回答1:

It turns out that eth2 is the adapter to connect the Virtual-box directly to the outside Internet, so commenting out

config.vm.network :public_network

from the VagrantFile stopped the public network interfaces being loaded and so solved the issue.



回答2:

This seems to be happen with bootup network configurations.

Although it failed to bring-up the network interface, you should be able to ssh into the box. To remove persistent network interfaces execute following commands in vagrant box folder.

vagrant ssh
sudo rm /etc/udev/rules.d/70-persistent-net.rules
exit
vagrant reload

source: https://github.com/mitchellh/vagrant/issues/921#issuecomment-15789964