Public static ip for vagrant box

Posted by Numbata on Server Fault See other posts from Server Fault or by Numbata
Published on 2012-08-16T22:03:31Z Indexed on 2012/12/08 11:14 UTC
Read the original article Hit count: 394

Filed under:
|
|
|

I have server (Debian Squeeze) with 1 ethernet card and 2 public static IPs (188.120.245.4 and 188.120.244.5).

What I want: Setup virtual box (Ubuntu) with access via static IP (188.120.244.5).

What I was trying:

  • config.vm.forward_port - good idea: setup interface "eth1:1" with 188.120.244.5 on host-machine, and add to Vagrant file "config.vm.forward_port = hmm..?"
  • config.vm.network :hostonly, "188.120.244.5" - not working. Was created new interface on host-machine with ip "188.120.244.1". Of course 188.120.244.1 IP isn't mine and I can't access my server via this IP.
  • config.vm.network :bridged - I'm confused how this works :)

What I have now: Not working configuration.

Debian-host-machine# cat Vagrantfile
Vagrant::Config.run do |config|
  config.vm.define :gitlab do |box_config|
    box_config.vm.box = "ubuntu"
    box_config.vm.host_name = "ubuntu"
    box_config.vm.network :bridged
    box_config.vm.network :hostonly, "188.120.244.5", :auto_config => false
  end
end

Debian-host-machine# ifconfig
eth1      Link encap:Ethernet  HWaddr 00:15:17:69:71:bb  
          inet addr:188.120.245.4  Bcast:188.120.247.255  Mask:255.255.248.0

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0

vboxnet0  Link encap:Ethernet  HWaddr 0a:00:27:00:00:00  
          inet addr:188.120.244.1  Bcast:188.120.246.255  Mask:255.255.255.0

Ubuntu-virtual-machine# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:ee:8d:0c  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0

eth1      Link encap:Ethernet  HWaddr 08:00:27:45:71:87  

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0

How I can access virtual box via public static IP from network?

I'm using Oracle VM VirtualBox Manager 4.1.18 and Vagrant version 1.0.3.

Thanks in advance for your feedback.

© Server Fault or respective owner

Related posts about networking

Related posts about routing