I have a lab in which I have three computers connected to a switch.
two of the switch's ports are mirrored to a third port so that all the communication between the two computers is mirrored to the third computer.

I would like to create a similar lab setup but with virtual machines. I have no problem setting such virtual lab with only the computers (not the switch) (using vagrant and private network), but is there something I can use to replace the switch part?

I read about Open vSwitch but how would one go about connecting it to the other virtual machines so it acts as a switch?


"...but is there something I can use to replace the switch part?"

Yes. You could change the network adapter of the third virtual machine (the one that was the destination of the mirroring) to be in promiscuous mode. Now all the traffic of all the virtual machine will be passing through your third vm.
virtualbox configuration


Sure there is. Mikrotik CHR for example can work nicely as a switch. Do not expect switch performance, where the CPU dues the work of an ASIC, though - but then you likely run a low traffic scenario anyway.

  • indeed I run a low traffic scenario. What I don't understand is how does the other virtual machines networks are configured to connect to that switch. – kroiz Apr 17 '18 at 14:14
  • Well, what I do not undertstand is what you just asked. No question mark and the question makes no sense. – TomTom Apr 17 '18 at 14:32
  • There was no need for question mark. I was stating a statement. Maybe an elaboration is in place: When defining a virtual machine, especially one that is part of a network, there are some configuration to do. For example: how many network adapters. which kind of network adapters. what subnet each of them use. etc. This type of configuration is what I was not able to do in order to configure the virtual lab. – kroiz Apr 18 '18 at 5:39

If you're running on a Linux-based platform there's built-in kernel bridging. For just three VMs I wouldn't really suggest anything else, particularly as most - if not all - VM implementions on Linux already support it.

Port mirroring isn't native to the bridge, but using a Queuing Discipline you can add this functionality quite straightforwardly.

  • How can this be configured (say in virtualbox) so that traffic from the virtual machines will get to the virtual machine that acts as a switch. – kroiz Apr 16 '18 at 12:32
  • I must be missing something. Why would you want to have a VM acting as a switch? – roaima Apr 16 '18 at 13:05
  • I just want to have the equivalent of my physical lab - virtualized. So like a regular network has a switch to connect computers so should the virtual lab. Currently I use virtualbox and it also acts as the switch when I create a private network of virtual machines but is not good for me as it cannot do port mirroring. – kroiz Apr 16 '18 at 19:25
  • This is exactly what I'm offering you then. Create your VMs and use Linux Bridge to connect them. It's built in to the kernel already. – roaima Apr 16 '18 at 20:30
  • What I don't understand is how do I connect them? The link you provided explain how to set up the switch but the other vms need some configuration as well. Like maybe what kind of interface to use? NAT or Bridge? Because currently I am not to ping from one vm to another. – kroiz Apr 17 '18 at 3:44

Don't forget that you still need VLAN aware switch (in between) if you use more than one hardware node!

Just search Amazon for VLAN switch.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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