I am trying to set up a Vagrant VirtualBox (v4.2.4) virtual machine with a Ubuntu "box" which I got from www.vagrantbox.es.
I was able to use Vagrant to set it up as a headless box and start it, and then I was able to ssh locally into it (using 127.0.0.1:2222), connect the internet and sun a bunch of "sudo apt-get" commands to update it and install new software.
I would like to be able to access this virtual machine on my network, so I need a bridged network adapter for the virtual box. When I went to the VirtualBox console for this device, and tried to set up bridged networking, it said that I needed the "guest additions". I tried to install them and I couldn't get the .iso file for the guest additions.
I went elsewhere on the 'net and it seems that I had to run "sudo apt-get install virtualbox-guest-additions-iso" from the virtual machine in order to get bridged networking. I tried this, and it installed fine after a couple of reboots. I then tried to set up bridged networking again (VirtualBox console to Devices->Network Adaptors…) but it didn't work.
————– EDIT more clarification——————-
My Vagrantfile looks like this:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "ubuntu1204"
config.vm.box_url = "http://dl.dropbox.com/u/4031118/Vagrant/ubuntu-12.04.1-server-i686-virtual.box"
config.vm.network :bridged
end
When I tried "vagrant up", here is what I got:
C:\Users\Jay\vagrantprojects\vagrant_guide>vagrant up
[default] VM already created. Booting if it's not already running...
[default] Clearing any previously set forwarded ports...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] Failed to connect to VM!
Failed to connect to VM via SSH. Please verify the VM successfully booted
by looking at the VirtualBox GUI.
C:\Users\Jay\vagrantprojects\vagrant_guide>vagrant ssh
`vagrant ssh` isn't available on the Windows platform. You are still able
to SSH into the virtual machine if you get a Windows SSH client (such as
PuTTY). The authentication information is shown below:
Host: 127.0.0.1
Port: 2222
Username: vagrant
Private key: C:/Users/Jay/.vagrant.d/insecure_private_key
I tried to ssh to the VM using putty.exe, but it would not let me in. So what do I need to do?
—- end EDIT ——————————————————
What, or what else do I need to do to set up bridged networking in this virtual machine?
I appreciate any help that I can get.
Best Answer
If you're using Vagrant, then you should be able to specify the bridged network option in your
Vagrantfile
, rather than trying to configure it by hand on the VM itself.Here's a sample
Vagrantfile
(note line #8) - just change yourconfig.vm.network
line to be:See the docs for reference.
The
Vagrantfile
just goes at the root of your project - the same folder from where you runvagrant up
and such.Also, you can ssh into the box using
vagrant ssh
- you don't need to specify the IP address and port - vagrant will take its config file (Vagrantfile
- see a theme here? - most everything having to do with the basic VM config goes in theVagrantfile
), and it will take care of creating, configuring, connecting, and tearing down the VM.