0

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.

1

You can use Open vSwitch. It has many enterprise grade features, including port mirroring.

You will find on this documentation page the following information:

Q: How do I configure a port as a SPAN port, that is, enable mirroring of all traffic to that port?

A. The following commands configure br0 with eth0 and tap0 as trunk ports. All traffic coming in or going out on eth0 or tap0 is also mirrored to tap1; any traffic arriving on tap1 is dropped:

$ ovs-vsctl add-br br0
$ ovs-vsctl add-port br0 eth0
$ ovs-vsctl add-port br0 tap0
$ ovs-vsctl add-port br0 tap1 \
    -- --id=@p get port tap1 \
    -- --id=@m create mirror name=m0 select-all=true output-port=@p \
    -- set bridge br0 mirrors=@m

To later disable mirroring, run:

$ ovs-vsctl clear bridge br0 mirrors

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