Im using virtualbox + ubuntu + vagrant.
However im not able to ping or wget any url. Please guide me on how I can allow the VM to access my host machine's internet?
this works for me.
Configure the Vagrantfile with this.
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
I hope this help.
Related
I have this VagrantFile:
Vagrant.configure("2") do |config|
# Use Ubuntu 14.04 Trusty Tahr 64-bit as our operating system
config.vm.box = "ubuntu/trusty64"
# Configurate the virtual machine to use 2GB of RAM
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
# Forward the Rails server default port to the host
config.vm.network :forwarded_port, guest: 4200, host: 4200
config.vm.network :forwarded_port, guest: 35729, host: 35729
Everything works good, in my Windows I can visit http://localhost:4200 and it works. But, there is a big but.
I have the ember's project files in a Windows folder shared with vagrant.
If I save files of my ember's project in Windows I can't have livereload, and in my vagrant ssh I even can't view the changes detected.
If I go with vagrant ssh and use nano application.hbs and then save something new it detect changes and livereload works in my Chrome's window on Windows.
What the hell is the problem?
The way Vagrant syncs directories between your desktop and the VM will break the default mechanism ember-cli uses to watch files and cause issues when updates are subsequently compiled.
To restore this functionality, you can either add the following lines to the '.ember-cli' file
"liveReload": true,
"watcher": "polling"
or invoke the serve command using the fallback polling watcher.
ember serve --watcher polling
I fixed that with this: ember serve --watcher polling. NFS sharing with Vagrant doesn't work on Windows.
I believe this may help you: http://www.ember-cli.com/user-guide/#usage-with-vagrant
Seems like you didn't fallback to polling watcher.
And you didn't also use NFS since it's not in your config. For windows user, you should use the winnfsd plugin and install with vagrant plugin install vagrant-winnfsd
I have created a VM using vagrant and tried to insert a cd, when realized that there is no such device to read it installed.
An option would be to go to my provider UI and through settings add what I need.
I want to know if there is any way to insert this setting (add a cdrom device to VM) into the vagrant file.
My provider is VirtualBox.
>>UPDATE
Mixing info from here and here, and extending some code example already existing in Vagrantfile I came up with
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
...
...
config.vm.provider :virtualbox do |vb|
vb.customize ["storagectl", :id, "--name", "IDEController", "--add", "ide"]
vb.customize ["storageattach", :id, "--storagectl", "IDEController", "--port", "0", "--device", "0", "--type", "dvddrive", "--medium", "none"]
vb.customize ["modifyvm", :id, "--boot1", "disk", "--boot2", "dvd"]
end
...
...
end
in the Vagrantfile.
The problem is that now, when attempting to perform vagrant reload, I get
VBoxManage.exe: error: No storage device attached to device slot 0 on port 0
--medium none is to telling VirtualBox to delete that DVD, please use --medium emptydrive.
See this link https://groups.google.com/forum/#!topic/vagrant-up/Z_KruTTN0vk and medium help:
--medium
Specifies what is to be attached. The following values are supported:
"none": Any existing device should be removed from the given slot.
"emptydrive": For a virtual DVD or floppy drive only, this makes the
device slot behaves like a removable drive into which no media has
been inserted.
I have some network-booted (PXE/TFTP) test/dev vms that are created and run using Vagrant.
However, by default Vagrant/Virtualbox adds SATA controller while some of those vms run older Linux distros that do not understand SATA and require virtual IDE controllers.
I can't seem to find the way to change controller type in Virtualbox that I could customize in Vagrant.
Is there a way to specify disk controller type in Vagrant (or, not so preferably, in underlying Virtualbox itself) using smth like http://www.virtualbox.org/manual/ch08.html#vboxmanage-storagectl ?
If you know the exact commands for VBoxManage, you could try something like:
Vagrant.configure("2") do |config|
# ...
config.vm.provider "virtualbox" do |v|
v.customize ["storagectl", :id, "--name", "SATA Controller", "--remove"]
v.customize ["storagectl", :id, "--name", "IDE Controller", "--add", ...]
end
end
I installed a precise32 VM using Vagrant in which I am trying to employ devstack for openstack developing. In order to access the service from host, I set up some forward ports in configure file but it does not work. That is I can not connect to 10.0.2.15 to which devstack prompted me to connect. I tried to switch the networking mode in VirtualBox from NAT to Bridge, then an error popped out saying something like "the NAT name already exists". I checked out the VirtualBox documentation but did not really understand. Anybody help me out please...
I add following to vagrant configure file:
Vagrant::Config.run do |config|
config.vm.forward_port 80, 9090
config.vm.forward_port 5000, 5000
config.vm.forward_port 5672, 5672
config.vm.forward_port 3333, 3333
config.vm.forward_port 8773, 8773
config.vm.forward_port 8774, 8774
config.vm.forward_port 8776, 8776
config.vm.forward_port 8777, 8777
config.vm.forward_port 9191, 9191
config.vm.forward_port 9292, 9292
config.vm.forward_port 35357, 35357
config.vm.forward_port 40529, 40529
config.vm.forward_port 47117, 47117
config.vm.forward_port 55977, 55977
config.vm.customize ["modifyvm", :id, "--memory", 8192]
end
If you have multiple ports to be exposed (port forwarding), it'll be better off using bridged.
Basically you need to enable Public Network in the Vagrantfile, add the following to the config block
config.vm.network "public_network"
See doc: http://docs.vagrantup.com/v2/networking/public_network.html
NOTE: you can leave the default NAT there, vagrant will add a 2nd virtual network adapter.
Once vagrant up completes, vagrant ssh into the box and do a ifconfig -a to get the IP address of the 2nd interface, you should be able to access the services from the host (as they are within the same network / LAN) as long as they bind not only to loopback.
I use Vagrant Version 2 with the precise32 vm and use port forwarding successfully as indicated by their documentation
Vagrant.configure("2") do |config|
config.vm.box = "precise32"
config.vm.network "forwarded_port", guest: 8080, host: 1234
end
Then I access using localhost:1234
Hope this helps.
Can anyone explain why I am getting the following error
"Vagrant: Network type 'bridged' is invalid. Please use a valid network type."
when I try to bring vagrant up on Virtual Box with the following Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.hostname = "gitserver"
config.berkshelf.enabled = true
config.vm.box = "centos57"
config.vm.box_url = "http://xx.xx.xx.xx/os/centos-5.7-x86_64.box"
config.vm.network :bridged, :bridge => 'eth0'
# Provision VM using chef
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe "mysqlserver"
end
config.vm.customize ["modifyvm", :id, "--memory", 1024]
end
I have tried all possible combinations with bridged configuration, but it simply does not like it. I cannot find any additional info as to why. Any help here would be hugely appreciated.
Since you are using a Vagrant config file version 2 (and therefore Vagrant 1.1+) instead of :bridge there is now the new type :public_network.
To use v1 code, you can insert it into a config 1 block like this:
Vagrant.configure("1") do |config|
config.vm.network :bridged, :bridge => 'eth0'
end
For Vagrant 1.3.5 in used the following:
config.vm.network :public_network, bridge: "en0: Wi-Fi (AirPort)"
It worked for me.
I am installing vagrant on ubuntu 10.04 with Virtualbox VirtualBox 4.1.24 from https://www.virtualbox.org/wiki/Linux_Downloads and then downloaded recent version of vagrant.
$ vagrant -v
Vagrant version 1.2.2
$ dpkg -l virtualbox*
ii virtualbox-4.1 4.1.26-84997~U Oracle VM VirtualBox
In order to use bridge network and specifically wifi i just added the line below inside Vagrantfile
config.vm.network :public_network, :public_network => "wlan0"
When you will do
$ vagrant up
You will see option asking for device for bridge interface you can use 1 for wlan0. Hope it helps.