Page 1 of 1
switch to bridged network via VBoxManage CLI
Posted: 22. Jun 2016, 16:42
by ftartaggia
Hi,
I'm trying to setup a VM (host: macosx, guest: windows 7) beginning with a NAT network config and then switching to bridged network using VBoxManage modifyvm. The result is that the vm autoassigns itself a random IP address as it doesn't configure a Default Gateway.
If I try doing the same using VirtualBox GUI, the network configuration is correct.
Can you help me understand what steps I am missing?
Thanks a lot in advance
Re: switch to bridged network via VBoxManage CLI
Posted: 22. Jun 2016, 19:59
by scottgus1
The commands for editing nic connections via Vboxmanage modifyvm include two commands for setting to Bridged:
--nic<1-N> none|null|nat|natnetwork|bridged|intnet|hostonly|generic to set to Bridged
--bridgeadapter<1-N> none|<devicename>
description on the second command from the manual:
If bridged networking has been enabled for a virtual network card . . . use this option to specify which host interface the given virtual network interface will use.
Sounds like just setting the nic to Bridged isn't enough. You have to pick the host's physical adapter name, too. (NAT doesn't ask for which host adapter to use.) The GUI is set to pick the first in the list, but the CLI can have nothing connected, so you need to do it with a new command.
Re: switch to bridged network via VBoxManage CLI
Posted: 23. Jun 2016, 09:41
by ftartaggia
Thanks a lot for your reply, but that's what I'm already doing: I set nic1 to bridged and bridgeadapter1 to en0.
But when I do this via VB GUI, the VM correctly autoconfigures the Default Gateway to my host's LAN router, while when I do the same via VBoxManage, the VM's Default Gateway remains unset.
Any idea?
Re: switch to bridged network via VBoxManage CLI
Posted: 23. Jun 2016, 13:41
by scottgus1
I don't have a Mac host to see what the answer to my question is, so let me please ask you.
This is the Windows version of a guest's Network settings:

- bridgedadapter.PNG (64.71 KiB) Viewed 16720 times
You will see that when I set my guest to Bridged, the name of the network card appears in the "Name" dropdown.
Does yours show the actual name of the network card in the dropdown, or does it say "en0"?
Maybe you could also post a screenshot of what your guest Network window loosk like, as well as the commands you're using.
Re: switch to bridged network via VBoxManage CLI
Posted: 23. Jun 2016, 14:21
by ftartaggia
I finally solved it
I need to pass the network interface name, not its identifier!
I was passing "--bridgeadapter en0", but I need to pass "--bridgeadapter 'en0: Wi-Fi' (AIrport)"
LOL
Anyway, thanks a lot for your help!
Re: switch to bridged network via VBoxManage CLI
Posted: 23. Jun 2016, 14:23
by scottgus1
Very good, had a feeling that was it. Glad it's working!