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 have simulated network latency with netem and It's great. Now I want to simulate unplugged network cable or when server goes down. I need this to make testing of my application easier and I couldn't find anything on the web that would help me. My servers are virtual CentOS instances and they are on Virtualbox. I want to do this from a php web page.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I assume you mean that your network cable is unplugged. You didn't specify.

Just bring the interface down. For example, with eth0:

ip link set eth0 down
share|improve this answer
    
thank you ,I'm reading about it here –  SafeY Apr 6 '13 at 8:36
    
that's working successfully but ip link set eth0 up is not working :( and I need them both –  SafeY Apr 6 '13 at 8:46
    
@NancySmith "Is not working" is not meaningful. What error messages occur? Did you assign an IP and netmask? –  Chris Down Apr 6 '13 at 8:59
    
I mean that I used ip link set eth0 down via php and ping shows that my server is unreachable . then I wanted to get it back "up" , I executed ip link set eth0 up via php and server still down . –  SafeY Apr 6 '13 at 9:05
1  
@NancySmith Create another network interface that does not have access to whatever it is connecting to (using routes, etc). SSH to the host using that interface. Bring down the interface that you are not connecting to SSH through. –  Chris Down Apr 6 '13 at 10:22

On your virtualbox console window, you should have a Machine menu pull down. Under that one there are several actions. One of which is Power off. You need to select that one for an immediate power down. This is the closest thing to yanking the power cord of a physical server.

share|improve this answer
    
I want to do this from a web page . surly I know how to power off machines . –  SafeY Apr 6 '13 at 8:22
    
and I don't want to fake it . not really shut down and boot it again . –  SafeY Apr 6 '13 at 8:23
    
Judging by the mention of netem, I assume the question is really about unplugging the network cable from a server, and not the power cable (although it is not clear). –  Chris Down Apr 6 '13 at 8:28
    
I will edit my question to make it more clear , thanks –  SafeY Apr 6 '13 at 8:33

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.