Openvswitch Cheat Sheet

Add libvirt network to be used with open vswitch

Create an xml file like below (it is going to be listed in networks)

<network>
<name>obr0</name>
<forward mode='bridge'/>
<bridge name='obr0'/>
<virtualport type='openvswitch'/>
</network>
  • The name of the network
  • The forward mode is set to bridge
  • The bridge name is the bridge name
  • The virtualport is set to openvswitch

Then introduce this network to libvirt using commands below:

virsh net-define <newnetworkfile.xml>
virsh net-start <newnetworkname>
virsh net-autostart <newnetworkname>
ovs-vsctl --id=@pout get port mir0 -- --id=@sport get port eno4 -- --id=@m create mirror name=obr0_mirror0 select-src-port=@sport output-port=@pout -- set bridge obr0 mirrors=@m

where obr0 is the openvswitch bridge name.

mir0 is the mirror port attached to obr0

eno4 is the port to be mirrored

obr0_mirror0 is the name of the mirror

Add More than One Mirror:

ovs-vsctl --id=@pout get port mir0 -- --id=@sport get port eno4 -- --id=@m create mirror name=obr0_mirror0 -- add bridge obr0 mirrors @m -- set mirror obr0_mirror0 select-src-port=@sport select-dst-port=@sport output-port=@pout

repeat as many as needed

Clear All Mirrors:

ovs-vsctl clear bridge ovsbr0 mirrors

List All Mirrors:

ovs-vsctl list mirror mymirror

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s