OpenVSwitch: Difference between revisions
m (→OVS and qemu) |
|||
Line 43: | Line 43: | ||
=== Helper scripts === | === Helper scripts === | ||
ovs-ifup- | ovs-ifup- | ||
<pre> | <pre> | ||
#!/bin/sh | #!/bin/sh | ||
switch=" | 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 | /sbin/ifconfig $1 0.0.0.0 up | ||
ovs-vsctl add-port ${switch} $1 | ovs-vsctl add-port ${switch} $1 | ||
Line 52: | Line 54: | ||
</pre> | </pre> | ||
ovs-ifdown- | ovs-ifdown- | ||
<pre> | <pre> | ||
#!/bin/sh | #!/bin/sh | ||
switch=" | 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 | /sbin/ifconfig $1 0.0.0.0 down | ||
ovs-vsctl del-port ${switch} $1 | ovs-vsctl del-port ${switch} $1 |
Revision as of 12:03, 17 April 2015
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 VSwithes 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 that you need to set the link status to up on the added interfaces.
ip link set dev eth0 up
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
Beware to have OVS package files available with no hassle at next reboot! this ca be a problem when running from ram with no cache...