Vagrant networking

77 views
Skip to first unread message

ja...@shiftgig.com

unread,
Mar 4, 2016, 4:42:33 PM3/4/16
to Vagrant
Hello. I am having an issue that I am hoping to get assistance on, maybe someone else has run into it, because googling for it has been hard.

I have been using a CentOS 7 box, which I made with Packer, that regularly has issues starting up. I am using a boilerplate Vagrantfile, with the only meaningful addition being:
config.vm.network "private_network", ip: "172.18.7.6"

Version: 1.7.4
Provider: VirtualBox
Host: Suse Leap
Guest: CentOS 7

Output:
vagrant up
Please report a bug if this causes problems.
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'centos7'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: centos7
==> 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: 22 => 2222 (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: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> 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!

cat /sys/class/net/veth00d3838/address

Stdout from the command:



Stderr from the command:

cat: /sys/class/net/veth00d3838/address: No such file or directory

Alvaro Miranda Aguilera

unread,
Mar 4, 2016, 9:18:28 PM3/4/16
to vagra...@googlegroups.com
Hello,

I am more than happy to review and help you to get this working, and I can check the packer part if you are willing to share what you got.

Alvaro.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/34c76054-6862-4d71-a809-3516e48af924%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jacob Dougherty

unread,
Mar 6, 2016, 10:37:17 AM3/6/16
to vagra...@googlegroups.com
Sure.

I build with: https://github.com/sgjacob/packer-centos7-virtualbox-vagrant
Then import the box locally and up with: https://gist.github.com/sgjacob/8c710c8b2c27ecd921f5
Some times it will start fine, but reload a few times and the error shows up. Once it shows, I can't get vagrant to up anymore, I just continually get that error, for hours.

Thanks for taking a look.

Jacob.
You received this message because you are subscribed to a topic in the Google Groups "Vagrant" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vagrant-up/6vnXcHc3mv4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAHqq0exOLLofK5CmbNTZTPSLPiuf29MX9ANdnFZ-qnyL7Z2R2Q%40mail.gmail.com.

Alvaro Miranda Aguilera

unread,
Mar 6, 2016, 11:27:25 PM3/6/16
to vagra...@googlegroups.com
Hello Jacob,

This is what I have found.

If I build the box, and run a vagrant file like this:

Vagrant.configure(2) do |config|

  config.vm.box = "sgjacob"

  config.ssh.username = "vagrant"

  config.ssh.password = "vagrant"

end


It works.


The reason is, in your provision script, seems you are missing to add the vagrant known public ssh key.


So you can add this to your template:


      "mkdir ~vagrant/.ssh",

      "chmod 700 ~vagrant/.ssh",

      "echo 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key' > ~vagrant/.ssh/authorized_keys",

      "chmod 600 ~vagrant/.ssh/authorized_keys",

      "chown -R vagrant: ~vagrant/.ssh",


And should fix the issues.


Alvaro.



Jacob Dougherty

unread,
Mar 7, 2016, 10:46:26 AM3/7/16
to vagra...@googlegroups.com
Alvaro,

Thanks for giving it a try. I had to clean up the packer template to post it and accidentally removed the portion that adds the default vagrant key.

If you take a look at my original email, you will see it was indeed there:


>default: Vagrant insecure key detected. Vagrant will automatically replace
>default: this with a newly generated keypair for better security.

That aside, I too find that it works sometimes, but most of the time it doesn't for me.
I just built the box, with the added the vagrant ssh key (updated the git repo, you can see the most recent commit).
Running `vagrant up` started fine, but a subsequent `vagrant reload` results in another similar error:

The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
cat /sys/class/net/veth02d999b/address
Stdout from the command:

    
Stderr from the command:
cat: /sys/class/net/veth02d999b/address: No such file or directory

From this point I have now destroyed it a few times and each up results in the same type of error. I will see if I can make a screen capture.

In case it helps, I can still `vagrant ssh` through virtualbox's default NAT interface, but the private network I have specified does not work, and synced folders are not processed.

Thanks again,
Jacob

Alvaro Miranda Aguilera

unread,
Mar 7, 2016, 5:20:19 PM3/7/16
to vagra...@googlegroups.com
hello, well

vagrant is meant to ssh over the nat.

If you need the VM to be available over private/public, you can update the default GW, etc

but vagrant should always connect as is, using the first nic with NAT.

Alvaro.

Reply all
Reply to author
Forward
0 new messages