Bridged network with vmware workstation, windows guest

791 views
Skip to first unread message

andr...@gmail.com

unread,
Nov 19, 2017, 7:55:57 PM11/19/17
to Vagrant
When I add this line to my vagrantfile:

    config.vm.network "public_network", bridge: "vmnet0"

vagrant creates second adapter which is bridged. 
Both primary and secondary adaters seems to work fine in this configuration.
I do not want second adapter I want the primary one to be bridged.

How do I configure this?

Vagrantfile to test:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "StefanScherer/windows_2016_docker"

  config.vm.network "public_network"
  config.vm.provider :vmware_workstation do |v|
    v.gui = true
  end
end



Cheers,
Andrew

Alvaro Miranda Aguilera

unread,
Nov 20, 2017, 4:47:42 AM11/20/17
to vagra...@googlegroups.com
the first nic is by default.

So you don't want to add a new nic, you can override the first one.

have a look at this:

Alvaro


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/f564595c-48f5-4dc3-ae48-067f09b2da0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

andr...@gmail.com

unread,
Nov 20, 2017, 7:47:25 PM11/20/17
to Vagrant
Thank you for this.
Apologies, I tried many different things before posting and none of them worked. Regarding you link with vagrant file like this:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "StefanScherer/windows_2016_docker"

  config.vm.network "public_network", adapter: "0"
  config.vm.provider :vmware_workstation do |v|
    v.gui = true
  end
end

The error I'm getting is this:

Bringing machine 'default' up with 'vmware_workstation' provider...
==> default: Cloning VMware VM: 'StefanScherer/windows_2016_docker'. This can take some time...
==> default: Checking if box 'StefanScherer/windows_2016_docker' is up to date...
==> default: Verifying vmnet devices are healthy...
==> default: Preparing network adapters...
WARNING: The VMX file for this box contains a setting that is automatically overwritten by Vagrant
WARNING: when started. Vagrant will stop overwriting this setting in an upcoming release which may
WARNING: prevent proper networking setup. Below is the detected VMX setting:
WARNING:
WARNING:   ethernet0.pcislotnumber = "33"
WARNING:
WARNING: If networking fails to properly configure, it may require this VMX setting. It can be manually
WARNING: applied via the Vagrantfile:
WARNING:
WARNING:   Vagrant.configure(2) do |config|
WARNING:     config.vm.provider :vmare_workstation do |vmware|
WARNING:       vmware.vmx["ethernet0.pcislotnumber"] = "33"
WARNING:     end
WARNING:   end
WARNING:
==> default: Starting the VMware VM...
==> default: Waiting for the VM to receive an address...
==> default: Forwarding ports...
    default: -- 3389 => 3389
    default: -- 22 => 2222
    default: -- 5985 => 55985
    default: -- 5986 => 55986
==> default: Waiting for machine to boot. This may take a few minutes...
==> default: Stopping the VMware VM...
==> default: Deleting the VM...
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/plugins/communicators/winrm/helper.rb:41:in `winrm_info_invalid?': undefined method `start_with?' for 0:Integer (NoMethodError)
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/plugins/communicators/winrm/helper.rb:36:in `winrm_address'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/plugins/communicators/winrm/helper.rb:21:in `winrm_info'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/plugins/communicators/winrm/communicator.rb:37:in `block in wait_for_ready'
        from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/timeout.rb:93:in `block in timeout'
        from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/timeout.rb:33:in `block in catch'
        from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/timeout.rb:33:in `catch'
        from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/timeout.rb:33:in `catch'
        from C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/timeout.rb:108:in `timeout'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/plugins/communicators/winrm/communicator.rb:31:in `wait_for_ready'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-2.0.1/lib/vagrant/action/builtin/wait_for_communicator.rb:16:in `block in call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/logging-2.2.2/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'

Did you ever actually got this working in practice, or is that a case of "should work in principle"?

Cheers,
Andrew
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.



--
Alvaro

andr...@gmail.com

unread,
Nov 20, 2017, 7:55:06 PM11/20/17
to Vagrant

On Monday, 20 November 2017 22:47:42 UTC+13, Alvaro Miranda Aguilera wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.



--
Alvaro

Alvaro Miranda Aguilera

unread,
Nov 21, 2017, 4:01:38 AM11/21/17
to vagra...@googlegroups.com
Hello

without having all the knowledge on what you want to do and why you want to avoid nat, yes it does work and yes i have used it.

proof:

kikitux@alvaro MINGW64 ~/Downloads/precise64
$ vagrant destroy -f
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...

kikitux@alvaro MINGW64 ~/Downloads/precise64
$ vagrant up --provider virtualbox
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'hashicorp/precise64'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'hashicorp/precise64' is up to date...
==> default: Setting the name of the VM: precise64_default_1511254703644_84079
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: bridged
==> default: Forwarding ports...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 10.0.113.246:22
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default:
    default: Guest Additions Version: 4.2.0
    default: VirtualBox Version: 5.1
==> default: Mounting shared folders...
    default: /vagrant => C:/Users/kikitux/Downloads/precise64

kikitux@alvaro MINGW64 ~/Downloads/precise64
$

there is 1 chicken egg here, that is, you can boot a VM add public_network and grab the IP and macaddress

then you can use that mac/ip to solve the chicken egg.

the first network will take DHCP, Vagrant doesn't know the IP, so you can bootstrap that part with a known mac/ip

after that it works.

$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "hashicorp/precise64"
  config.vm.network "public_network", adapter: 1, auto_config: false, :mac => "080027880ca6"
  config.vm.network :forwarded_port, guest: 22, host: 2222, id: "ssh", disabled: true, auto_correct: true
  config.vm.provider :vmware_workstation do |v|
    v.gui = true
  end
  config.ssh.host = "10.0.113.246"
end


Enjoy,
Alvaro.

To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/30e5c933-2bd5-46c4-87dd-67fdfaf5e71d%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

andr...@gmail.com

unread,
Nov 21, 2017, 4:54:49 AM11/21/17
to Vagrant
Thank you Alvaro,

as I mentioned in my question I need windows guest and I need vmware provider. Your example is linux guest and virtualbox provider, unfortunately it does not help me.

Let me tell you a little bit more about what I'm trying to achieve.

I have build a box that represents an application that we developed (let's call in the API). Other applications need to interact with the API and the goal is to provide the vagrant box for the application developers to point to, to consume the API.
The application does not necessarily run on the same machine where the vagrant is run, it would be beneficial for us to point the application from any environment to a particular API box instance for testing.

Thus I need to provide a quick and easy way for people to up this box and point their application to it. I cannot ask everyone to fiddle with vagrant config and re-run several times in different network configurations until it works, that would not be reasonable.
I need to give them a way to vagrant up and then just point to that IP from anywhere.

Nat would not allow this as the box won't get its own external IP and port forwarding won't do because of clash with the used host ports. I need bridge.
At the same time I don't want to confuse people with multiple IP address for the box: one that comes from NAT and the other that comes from bridge. It should be easy for them to up the box, grab the address and point whatever they need to point to this address.
The address will be given by external DHCP on the host network.

It almost works to my satisfaction. The only hurdle is that I still have useless NAT on the box, which I don't need 
"man, why did you build this box for us with two network adapters? What is the second for? - Well guys, sorry, it's not me it's vagrant, it insists on having the second adapter with NAT or manual configuration of the box is required to remove the extra adapter once the box is up. it's a bit lame but no can do" <= so that's the conversation I'm trying to avoid. 

Please let me know if anything is not clear.

Cheers,
Andrew




--
Alvaro

Alvaro Miranda Aguilera

unread,
Nov 21, 2017, 5:24:42 AM11/21/17
to vagra...@googlegroups.com
Hello

Missed the vmware part from your message, but I can see it now in the vagrantfile, I just took a bit from it didn't copy paste all.

So for VMWare, it also works:

kikitux@alvaro MINGW64 ~/Downloads/vagrant_bridge_eth0_vmware
$ vagrant up
Bringing machine 'default' up with 'vmware_workstation' provider...
==> default: Cloning VMware VM: 'hashicorp/precise64'. This can take some time...
==> default: Checking if box 'hashicorp/precise64' is up to date...
==> default: Verifying vmnet devices are healthy...
==> default: Preparing network adapters...
WARNING: The VMX file for this box contains a setting that is automatically overwritten by Vagrant
WARNING: when started. Vagrant will stop overwriting this setting in an upcoming release which may
WARNING: prevent proper networking setup. Below is the detected VMX setting:
WARNING:
WARNING:   ethernet0.pcislotnumber = "32"
WARNING:
WARNING: If networking fails to properly configure, it may require this VMX setting. It can be manually
WARNING: applied via the Vagrantfile:
WARNING:
WARNING:   Vagrant.configure(2) do |config|
WARNING:     config.vm.provider :vmare_workstation do |vmware|
WARNING:       vmware.vmx["ethernet0.pcislotnumber"] = "32"
WARNING:     end
WARNING:   end
WARNING:
==> default: Starting the VMware VM...
==> default: Waiting for the VM to receive an address...
==> default: Forwarding ports...
    default: -- 22 => 2222
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 0:22
    default: SSH username: vagrant
    default: SSH auth method: private key
    default:
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Configuring network adapters within the VM...
==> default: Waiting for HGFS to become available...
==> default: Enabling and configuring shared folders...
    default: -- C:/Users/kikitux/Downloads/vagrant_bridge_eth0_vmware: /vagrant

kikitux@alvaro MINGW64 ~/Downloads/vagrant_bridge_eth0_vmware
$ vagrant ssh -c 'ifconfig ; route -n'
eth0      Link encap:Ethernet  HWaddr 00:0c:29:1f:47:89
          inet addr:10.0.15.89  Bcast:10.0.115.255  Mask:255.255.252.0
          inet6 addr: fe80::20c:29ff:fe1f:4789/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1469 errors:0 dropped:0 overruns:0 frame:0
          TX packets:497 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:224165 (224.1 KB)  TX bytes:70375 (70.3 KB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.12.1      0.0.0.0         UG    100    0        0 eth0
10.0.12.0      0.0.0.0         255.255.252.0   U     0      0        0 eth0
Connection to 10.0.115.89 closed.

kikitux@alvaro MINGW64 ~/Downloads/vagrant_bridge_eth0_vmware
$


This one requires less tricks since VMware works bit differently:

$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "hashicorp/precise64"
  config.vm.network "public_network", adapter: 0, auto_config: false
  config.vm.provider :vmware_workstation do |v|
    v.gui = true
  end
end

let me know if works.

Alvaro.
Reply all
Reply to author
Forward
0 new messages