https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Alc&feedformat=atomAlpine Linux - User contributions [en]2024-03-28T11:28:02ZUser contributionsMediaWiki 1.40.0https://wiki.alpinelinux.org/w/index.php?title=OpenVSwitch&diff=14236OpenVSwitch2017-12-21T01:39:41Z<p>Alc: fix > this ca be a to > this can be a</p>
<hr />
<div>[[Category:Networking]]<br />
This document describes how to configure an OpenVSwitch in Alpine Linux.<br />
<br />
== Installing OVS ==<br />
<br />
<pre><br />
apk add openvswitch<br />
rc-update add ovs-modules<br />
rc-update add ovsdb-server<br />
rc-update add ovs-vswitchd<br />
rc-service ovs-modules start<br />
rc-service ovsdb-server start<br />
rc-service ovs-vswitchd start<br />
</pre><br />
<br />
== Using ovs-vsctl ==<br />
Open VSwithes are manually managed with the '''ovs-vsctl''' command.<br />
<br />
To manually create a switch named "lan":<br />
{{Cmd|ovs-vsctl add-br lan}}<br />
<br />
To add interface eth0 to the switch "lan":<br />
{{Cmd|ovs-vsctl add-port lan eth0}}<br />
<br />
Note that you need to set the link status to ''up'' on the added interfaces.<br />
{{Cmd|ip link set dev eth0 up}}<br />
<br />
To see what OVS are defined:<br />
{{Cmd|ovs-vsctl list-br}}<br />
<br />
To see what interfaces are linked to the lan OVS:<br />
{{Cmd|ovs-vsctl list-ports lan}}<br />
<br />
To enable spanning tree (if needed):<br />
{{Cmd|1=ovs-vsctl set bridge lan stp_enable=true}}<br />
<br />
LACP Timer setting 'fast' mode:<br />
{{Cmd|1=ovs-vsctl set port bond0 other_config:lacp-time=fast}}<br />
<br />
== Using OVS appctl ==<br />
ovs-appctl lacp/show bond0<br />
<br />
== Configuration file ==<br />
<br />
configured in ''/etc/network/interfaces''<br />
<br />
<pre><br />
auto eth0 lan<br />
iface eth0 inet manual<br />
up ifconfig eth0 0.0.0.0 up<br />
down ifconfig eth0 down<br />
<br />
iface lan inet dhcp<br />
</pre><br />
<br />
== OVS and qemu ==<br />
<br />
=== Helper scripts ===<br />
<br />
ovs-ifup-<br />
<pre><br />
#!/bin/sh<br />
switch=$(echo $0|/usr/bin/cut -d- -f3)<br />
[ -z ${switch} ] && echo "Please define some symlink with suffix to use." && exit 1<br />
[ $# -lt 1 ] && echo "Too few params. Must be 1 and is $#." && exit 2<br />
/sbin/ifconfig $1 0.0.0.0 up<br />
ovs-vsctl add-port ${switch} $1<br />
logger "qemu: $1 added to ${switch} at startup of VM"<br />
</pre><br />
<br />
ovs-ifdown-<br />
<pre><br />
#!/bin/sh<br />
switch=$(echo $0|/usr/bin/cut -d- -f3)<br />
[ -z ${switch} ] && echo "Please define some symlink with suffix to use." && exit 1<br />
[ $# -lt 1 ] && echo "Too few params. Must be 1 and is $#." && exit 2<br />
/sbin/ifconfig $1 0.0.0.0 down<br />
ovs-vsctl del-port ${switch} $1<br />
logger "qemu: $1 removed from ${switch} at shutdown of VM"<br />
</pre><br />
<br />
== OVS and LXC ==<br />
<br />
=== Helper scripts ===<br />
<br />
lxc-ovs-ifdown- <br />
<pre><br />
#!/bin/sh<br />
switch=$(echo $0|/usr/bin/cut -d- -f4)<br />
[ -z ${switch} ] && echo "Please define some symlink with suffix to use." && return 1<br />
[ $# -lt 5 ] && echo "Too few params. Must be 5 and is $#." && exit 2<br />
nic=$5<br />
/usr/bin/ovs-vsctl del-port ${switch} ${nic}<br />
/usr/bin/logger "lxc: ${nic} removed from ${switch} at shutdown of VM."<br />
</pre><br />
<br />
== Caveats ==<br />
<br />
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...</div>Alc