Is there a way to simulate a network outage for running VMs VirtualBox?

12

3

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.

paxos1977

Posted 2012-12-05T22:58:10.030

Reputation: 323

Answers

15

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.

enter image description here


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.

gertvdijk

Posted 2012-12-05T22:58:10.030

Reputation: 3 396

Using the GUI to do this works, sorry forgot to mention in original post I need a CLI (I have more than 4 NICs to toggle). – paxos1977 – 2012-12-06T03:15:15.533

1@ceretullis Your question has become a lot more specific since I answered it. Anyway, I've updated my answer to support command-line way of changing NIC states for a running VM. – gertvdijk – 2012-12-06T11:27:07.823

Doh! Totally missed 'controlvm' option in the help. (Pretty much a complete newb here). Thnx for the help. – paxos1977 – 2012-12-06T16:07:46.400