Linux Network Simulation – How to Simulate Unplugged Network Cable or Down Server

linuxshutdown

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.

Best Answer

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

ip link set eth0 down

To bring the interface back up:

ip link set eth0 up
Related Question