Open vSwitch (sometimes called OvS) is an open-source implementation of distributed virtual multilayer switch. The main role of OvS is to provide a switching stack for hardware virtualization and is slowly replacing Linux native bridge/bonds. Open vSwitch can operate as a network switch within VM Hypervisor, as well as in dedicated switching hardware control stack(also known as Software Defined Networking or shortly SDN). The features of OvS are numerous and it would take one blog alone to enumerate them. Therefore, we are going to stick to our domain, for which it supports Netflow, sFlow and IPFX.

Open vSwitch interface configuration

OvS interface configuration is similar to the older Linux bridging/bonding. For example, to migrate from regular configuration to OvS you would need to install an openvswitch-switch package (e.g. Debian). This configuration is usual for Proxmox VE.

The regular configuration should look like this:

auto lo
iface lo inet loopback

iface enp0s3 inet manual

auto vmbr0
iface vmbr0 inet static
    address 172.16.2.204
    netmask 255.255.255.0
    gateway 172.16.2.1
    bridge_ports enp0s3
    bridge_stp off
    bridge_fd 0

The same configuration in OvS follows:

auto lo vmbr0
iface lo inet loopback

allow-vmbr0 enp0s3
iface enp0s3 inet manual
    ovs_type OVSPort
    ovs_bridge vmbr0

allow-ovs vmbr0
iface vmbr0 inet static
    address172.16.2.204
    netmask24
    gateway172.16.2.1
    ovs_type OVSBridge
    ovs_ports enp0s3

That would be it for the basic interface configuration!

Open vSwitch NetFlow configuration

Now we can proceed to NetFlow configuration:

ovs−vsctl set Bridge vmbr0 netflow=@nf0 -- --id=@nf0 create NetFlow targets=\"172.16.0.93:2055\" add_id_to_interface=false

By completing this step we have finished the aforementioned configuration. If you would like to check whether the NetFlow is working correctly, use the following command:

ovs-vsctl list netflow

You may see the expected output on the image below: