So I am trying to simulate internet outage on my virtual network.

I cannot just turn off interface as suggested on the link below because I would like to simulate scenario where private network works and I can access local stuff (i.e. database) but gateway failed.

How to simulate unplugged network cable or down server?

The network is run using Docker, and all machines are separate Docker images

Is there a simple way of doing that?

  • It very much depends on how you are running the Docker network (one physical hosts, several physical hosts, where are the bridges, etc.). If there's a single physical host that forwards between the Docker network and the physical network, you just have to modify the iptables on this host to split the Docker network from the physical network. – dirkt Oct 31 '18 at 10:19

The first step would be to make sure to run each of the docker images within its own network namespace, and then populate each of those with virtual interfaces; perhaps ideally one interface for the (undisturbed) "local net", and another interface for the (disturbed) "wide area net".

Each local net interface would be "wired" to its own interface in the global namespaces, and then all those would be added to a bridge. That set up would provide to local net "cabling". You may then need to add a DHCP service on that net, or otherwise use static assignments.

Each WAN interface would likewise be wired to its own interface in the global namespace, and likewise all these would be added to another bridge, representing the cabling for the "WAN". This bridge would also have a main host IP, so as to allow the simulated WAN traffic to escape to "real" WAN. For that, you would set up iptables rules to channel the traffic, and effect disturbance by changing these rules.

If you want disturbances applied differently for different dockers, you would perhaps not bring them together in a bridge, but you would instead need to have individual channeling rules, and manipulate those for individual disturbances. Or alternatively, you do bring them into a bridge, and instead manipulate their virtual cabling (that connects each with its companion interface in a namespace)

  • So basically this cannot be done "easy" way, and changes have to be done to docker containers? – Rouz Oct 30 '18 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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