4

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
Lamian
  • 313
  • 2
  • 5
  • 12

2 Answers2

3

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.

Terry Wang
  • 13,840
  • 3
  • 50
  • 43
  • Still not working...However,I tried enable the private network. It works if I enter 192.168.33.xx which is the static IP assigned. But the port forwarding still not working. I entered 127.0.0.1:9090 in my browser and got a "not available" page. – Lamian Jan 15 '14 at 05:53
  • 1
    You are mixing network modes. Port forwarding is ONLY for NAT. Private in Vagrant is Host-only, the host should access it using the ip address 192.168.33.xx in your case. – Terry Wang Jan 15 '14 at 08:10
2

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.

aarti
  • 2,815
  • 1
  • 23
  • 31