1

My Windows 10 host is set to start a VirtualBox Virtual Machine in headless mode on startup. I have the VM configured to bridged mode, so it gets its own IP address. I then SSH to it from the Windows Terminal, so I don't need to see or use the VirtualBox GUI. Sometimes, however, the network interface misbehaves and I cannot connect to the VM, even after a VM reset.

What I found is that changing the adapter to NAT and then back to bridged, fixes the problem. But it means having to go to the GUI, so now I want to do it on the command line, so I can just run a script.

This is how I change it to NAT on the terminal prompt:

& 'C:\Program Files\Oracle\VirtualBox\VBoxManage.exe' controlvm VMName nic1 nat

The above works fine, but if I try changing it back to bridged:

& 'C:\Program Files\Oracle\VirtualBox\VBoxManage.exe' controlvm VMName nic1 bridged
VBoxManage.exe: error: Missing argument to 'bridged'

I totally get the error, on the UI, there's a drop-down where I select the network connection, in my case "Intel(R) Wi-Fi 6 AX201 160MHz". How do I specify it on the CLI?

Nagev
  • 981

1 Answers1

1

The solution was to specify the entire string exactly as it appears on the UI:

& 'C:\Program Files\Oracle\VirtualBox\VBoxManage.exe' controlvm VMName nic1 bridged "Intel(R) Wi-Fi 6 AX201 160MHz"

Notice that even the (R) is there. If the string doesn't match, the CLI command fails silently, i.e. there's no error message, but on the VM terminal I can see with ip a that the interface does not have an IP address.

By the way, something similar is done to change the adapter to Host-Only:

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm VMName nic2 hostonly "VirtualBox Host-Only Ethernet Adapter"

Would be good to know if there's a better way to do this, or a CLI command to list these strings.

Nagev
  • 981