Difference between revisions of "OpenVSwitch"

From Alpine Linux
Jump to: navigation, search
m (fix > this ca be a to > this can be a)
(Caveats)
 
(One intermediate revision by the same user not shown)
Line 15: Line 15:
  
 
== Using ovs-vsctl ==
 
== Using ovs-vsctl ==
Open VSwithes are manually managed with the '''ovs-vsctl''' command.
+
Open VSwitches are manually managed with the '''ovs-vsctl''' command.
  
 
To manually create a switch named "lan":
 
To manually create a switch named "lan":
Line 23: Line 23:
 
{{Cmd|ovs-vsctl add-port lan eth0}}
 
{{Cmd|ovs-vsctl add-port lan eth0}}
  
Note that you need to set the link status to ''up'' on the added interfaces.
+
Note: You need to set the link status to ''up'' on the added interfaces.
 
{{Cmd|ip link set dev eth0 up}}
 
{{Cmd|ip link set dev eth0 up}}
  
Line 97: Line 97:
 
== Caveats ==
 
== Caveats ==
  
Beware to have OVS package files available with no hassle at next reboot! this can be a problem when running from ram with no cache...
+
Ensure you have OVS package files available at the next reboot! That can be a problem when running from RAM with no cache...

Latest revision as of 06:52, 23 July 2021

This document describes how to configure an OpenVSwitch in Alpine Linux.

Installing OVS

apk add openvswitch
rc-update add ovs-modules
rc-update add ovsdb-server
rc-update add ovs-vswitchd
rc-service ovs-modules start
rc-service ovsdb-server start
rc-service ovs-vswitchd start

Using ovs-vsctl

Open VSwitches are manually managed with the ovs-vsctl command.

To manually create a switch named "lan":

ovs-vsctl add-br lan

To add interface eth0 to the switch "lan":

ovs-vsctl add-port lan eth0

Note: You need to set the link status to up on the added interfaces.

ip link set dev eth0 up

To see what OVS are defined:

ovs-vsctl list-br

To see what interfaces are linked to the lan OVS:

ovs-vsctl list-ports lan

To enable spanning tree (if needed):

ovs-vsctl set bridge lan stp_enable=true

LACP Timer setting 'fast' mode:

ovs-vsctl set port bond0 other_config:lacp-time=fast

Using OVS appctl

ovs-appctl lacp/show bond0

Configuration file

configured in /etc/network/interfaces

auto eth0 lan
iface eth0 inet manual
 up ifconfig eth0 0.0.0.0 up
 down ifconfig eth0 down

iface lan inet dhcp

OVS and qemu

Helper scripts

ovs-ifup-

#!/bin/sh
switch=$(echo $0|/usr/bin/cut -d- -f3)
[ -z ${switch} ] && echo "Please define some symlink with suffix to use." && exit 1
[ $# -lt 1 ] && echo "Too few params. Must be 1 and is $#." && exit 2
/sbin/ifconfig $1 0.0.0.0 up
ovs-vsctl add-port ${switch} $1
logger "qemu: $1 added to ${switch} at startup of VM"

ovs-ifdown-

#!/bin/sh
switch=$(echo $0|/usr/bin/cut -d- -f3)
[ -z ${switch} ] && echo "Please define some symlink with suffix to use." && exit 1
[ $# -lt 1 ] && echo "Too few params. Must be 1 and is $#." && exit 2
/sbin/ifconfig $1 0.0.0.0 down
ovs-vsctl del-port ${switch} $1
logger "qemu: $1 removed from ${switch} at shutdown of VM"

OVS and LXC

Helper scripts

lxc-ovs-ifdown-

#!/bin/sh
switch=$(echo $0|/usr/bin/cut -d- -f4)
[ -z ${switch} ] && echo "Please define some symlink with suffix to use." && return 1
[ $# -lt 5 ] && echo "Too few params. Must be 5 and is $#." && exit 2
nic=$5
/usr/bin/ovs-vsctl del-port ${switch} ${nic}
/usr/bin/logger "lxc: ${nic} removed from ${switch} at shutdown of VM."

Caveats

Ensure you have OVS package files available at the next reboot! That can be a problem when running from RAM with no cache...