Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 8 down vote accepted

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.

share|improve this answer
    
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 Dec 6 '12 at 3:15
    
@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 Dec 6 '12 at 11:27
    
Doh! Totally missed 'controlvm' option in the help. (Pretty much a complete newb here). Thnx for the help. –  paxos1977 Dec 6 '12 at 16:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.