Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
Do you have DHCP setup on your network, so that your VM gets an IP automatically? There's a note at the end of the docs regarding bridged networks that say it won't work everywhere. Starting by determining whether or not the VM is getting an IP address is where I would go. If you're working on this on your home network, you should be able to see a new DHCP lease being issued for the VM itself. If it's a work network and you're not the network admin, you'll need to check with your network admin to determine this. –  jefflunt Dec 10 '12 at 3:34
    
The 127.0.0.1 address is localhost, which is another name for your "local" machine. So, the vagrant VM isn't going to be available on that IP, if bridged networking is working. Also, the output from vagrant states that you should check the VirtualBox VM to see if the VM booted up - do you see it running in VirtualBox? –  jefflunt Dec 10 '12 at 3:36
    
I logged onto my router and couldn't find any record of a lease for my Ubuntu VM. I had set up other VMs without Vagrant, and their records were there. When networking defaulted to NAT (via Vagrantfile), I was able to ssh into the VM. –  Jay Godse Dec 10 '12 at 11:41
    
Hm...maybe this? (scroll down to "sathlan's" comment): github.com/mitchellh/vagrant/issues/655 - I've only done Vagrant on OS X, so I probably can't help if it's something specific to the Windows implementation. –  jefflunt Dec 10 '12 at 16:09
add comment

1 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 your config.vm.network line to be:

config.vm.network :bridged

See the docs for reference.

The Vagrantfile just goes at the root of your project - the same folder from where you run vagrant 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 the Vagrantfile), and it will take care of creating, configuring, connecting, and tearing down the VM.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.