Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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@192.168.0.101 "ip link set dev eth0 down"',$output); //work
exec('ssh -p 22 root@192.168.0.101 "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
add comment

1 Answer

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

share|improve this answer
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.