Is there a way to simulate a network outage for running VMs VirtualBox?
I have several guest VMs configured to use internal networking.
Is there a way to simulate a network outage on specific VM interfaces while the guests are running?
Edit: I really need a command line way to do this, I have more than 4 NICs to toggle (GUI supports only the first 4). More details, windows host running VirtualBox 4.2.4 r81684. E.g., trying to use vboxmanage modifyvm IMAGE_NAME --cableconnect5 off
while the guest is running yields the error:
VBoxManage.exe: error: The machine 'IMAGE_NAME' is already locked for a session (or being unlocked)
If I shutdown the VM, I'm able to toggle the connectivity with this command.
Yes. While having the VM running, you still have some options to change on the network, e.g. disconnect cable, connect to another network.
See the sceenshot below. This was done using VirtualBox 4.2.4 (virtualbox.org) on Ubuntu 12.04.
Update (command-line)
It's possible to do this command-line using the subcommand controlvm
. See the section VBoxManage modifyvm in the VirtualBox documentation:
This command changes the properties of a registered virtual machine which is not running. [...]
These commands require that the machine is powered off (neither running nor in "saved" state). Some machine settings can also be changed while a machine is running; those settings will then have a corresponding subcommand with the VBoxManage controlvm subcommand (see the section called “VBoxManage controlvm”).
The command
VBoxManage controlvm "Windows XP" setlinkstate1 off
worked for me. I suppose this works for other NICs as well.