How can I configure private network in vagrant box

2k views Asked by At

Setup: On my laptop, I have windows 10 pro install. On that, I have installed latest virtualbox 5.1.2, latest vagrant 1.9.1 and latest packer 0.12.1. My laptop is highend and with strong configuration. I am on wifi.

Purpose: I want to have three vagrant boxes running Windows 2012 r2 so that I can install SQL server on one, and two different web applications on others.

Success: Till now I have managed to create vagrant boxes without any hassles. If I use forwarded port method, I am even able to rdp into those machines.

Failure: My plan is to configure private network for these machines so that they can have their own ip addresses and can communicate with each other. But so far I am unable to achieve so. The private network settings as recommeded on vagrantup.com and other websites do not seem to work for me somehow, as I am sure I am doing some mistake somewhere.

can somebody please help me on how to go about this? I have searched a lot on this site also and gone through many suggestions but none seem to help.

Below is my vagrant file that I am using.

Vagrant.configure(2) do |config|

    config.vm.box = "xxxx.box"

    config.vm.communicator = "winrm"
    config.vm.hostname = "xxxserver"    

    # Admin user name and password
    config.winrm.username = "vagrant"
    config.winrm.password = "vagrant"

    config.vm.guest = :windows
    config.windows.halt_timeout = 600
    config.vm.network "private_network", ip: "192.168.50.4"

end

And below is the error message that I get when I run vagrant rdp *

==> default: Detecting RDP info... RDP connection information for this machine could not be detected. This is typically caused when we can't find the IP or port to connect to for RDP. Please verify you're forwarding an RDP port and that your machine is accessible.

*

But if I replace

config.vm.network "private_network", ip: "192.168.50.4" 

with

config.vm.network "forwarded_port" , host: 33390 , guest: 3389

and then reload the box then vagrant rdp works fine and I am able to loginto it. I want to use static ips for my vms.

Kindly guide.. thanks.

1

There are 1 answers

0
ipper On

I also use a private_network with a static ip. Only adding (not replacing) the line config.vm.network "forwarded_port" , host: 33390 , guest: 3389 works.

$ vagrant rdp
==> fe: Detecting RDP info...
    fe: Address: 127.0.0.1:33389`enter code here`
    fe: Username: vagrant
==> fe: Vagrant will now launch your RDP client with the connection parameters
==> fe: above. If the connection fails, verify that the information above is
==> fe: correct. Additionally, make sure the RDP server is configured and
==> fe: running in the guest machine (it is disabled by default on Windows).
==> fe: Also, verify that the firewall is open to allow RDP connections.