3

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?

kroiz
  • 41
  • 7

4 Answers4

3

"...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

Hagai
  • 246
  • 1
  • 2
1

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.

TomTom
  • 50,857
  • 7
  • 52
  • 134
  • 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 05:39
1

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.

roaima
  • 1,567
  • 13
  • 26
  • 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 03:44
  • No, the link is to show you how to add Port Mirroring to the standard built-n kernel switch. Have you ever used virtualisation on a Linux platform? If so, you're using the bridge tools. This _is_ your switch. – roaima Apr 17 '18 at 07:21
  • I understand this is my switch. but I need other other vms to connect to it. – kroiz Apr 17 '18 at 07:31
  • How are you managing your VMs? Have you told the management layer to use a switch/bridge? – roaima Apr 17 '18 at 19:58
  • That is just the thing I am struggling so much with. – kroiz Apr 18 '18 at 05:30
  • What area of sysadmin is your expertise? I'll try to use that as context – roaima Apr 18 '18 at 06:53
  • I have no expertise in sysadmin other than those acquired during my years of professional programmers. – kroiz Apr 18 '18 at 07:00
0

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.

SamTzu
  • 23
  • 6