Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to perform a testing panel which disconnects a network cable and connect it again on a specific virtual server via a php web page.

I found that ip & ifconfig can disconnect a network, but I can't turn it back on, because I'm doing these operations via php with ssh like this:

exec('ssh -p 22 root@ "ip link set dev eth0 down"',$output); //work
exec('ssh -p 22 root@ "ip link set dev eth0 up"',$output); // doesn't work

I'm using virtual servers 'CentOS' on virtual box, is there an alternative way to do this ?

share|improve this question

You can script Virtualbox using modifyvm --cableconnected<1-N> on|off (http://www.virtualbox.org/manual/ch08.html#idp20394080).

share|improve this answer

Your Answer


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.