From cd89fa44190982a6db105dc18171740fb417f97e Mon Sep 17 00:00:00 2001 From: sf Date: Mon, 1 Feb 2021 12:52:38 +0100 Subject: [PATCH] initial --- 99ovsboot | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 99ovsboot diff --git a/99ovsboot b/99ovsboot new file mode 100755 index 0000000..9772580 --- /dev/null +++ b/99ovsboot @@ -0,0 +1,69 @@ +#Setup variables +#My IP address is required for the ovsdb server. +#MYIP=192.168.178.109 +MYIP=127.0.0.1 + +# This is the OpenFlow controller ID which we're going to load into the OVS +#CTLIP=192.168.178.67 +CTLIP=10.0.0.1 + +# This is our DataPath ID +DPID=0000000000000001 + +# This is the name of the bridge that we're going to be creating +SW=ovs-br0 + +mkdir -pv /var/run/openvswitch/ + +#What ports are we going to put in the OVS? +#DPPORTS="eth0.1 eth0.2 eth0.3 eth0.4 wlan0 wlan0-2 wlan0-3" +#DPPORTS="eth0.1 eth0.2 eth0.3 eth0.4 wlan1" +DPPORTS="eth0.1 eth0.2 eth0.3 eth0.4" +#Alias some variables +#VSCTL="ovs-vsctl --db=tcp:$MYIP:9999" +VSCTL="ovs-vsctl" +OVSDB=/tmp/ovs-vswitchd.conf.db + +# Kill off the servers and remove any stale lockfiles +/usr/bin/killall ovsdb-server +/usr/bin/killall ovs-vswitchd +rm /tmp/.ovs-vswitchd.conf.db.~lock~ + +# Remove the OVS Database and then recreate. +rm -f $OVSDB +ovsdb-tool create $OVSDB /usr/share/openvswitch/vswitch.ovsschema + +# Start the OVSDB server and wait until it starts +#ovsdb-server $OVSDB --remote=ptcp:9999:$MYIP & +ovsdb-server $OVSDB --detach --overwrite-pidfile --remote=punix:/var/run/openvswitch/db.sock +sleep 2 + +# Start vSwitchd +#ovs-vswitchd tcp:$MYIP:9999 --pidfile=ovs-vswitchd.pid --overwrite-pidfile -- & +ovs-vswitchd --pidfile=ovs-vswitchd.pid --overwrite-pidfile --detach + +# Create the bridge and pass in some configuration options +$VSCTL add-br $SW +$VSCTL set bridge $SW protocols=OpenFlow13 + +#Cycle through the DataPath ports adding them to the switch +C=1 +for i in $DPPORTS ; do + PORT=$i + ifconfig $PORT up + $VSCTL add-port $SW $PORT -- set interface $PORT ofport_request=$C + C=$((C+1)) +done + +#Ensure that the switch has the correct DataPath ID +$VSCTL set bridge $SW other-config:datapath-id=$DPID + +#Configure the switch to have an OpenFlow Controller. This will contact the controller. +$VSCTL set-controller $SW tcp:$CTLIP:6653 +$VSCTL set controller $SW connection-mode=out-of-band +# Turn off the fail-safe mode +$VSCTL set-fail-mode $SW secure +# +# +#$VSCTL --id=@sflow create sflow agent=192.168.178.109 target=\"$CTLIP:6653\" sampling=2 polling=20 -- -- set bridge $SW sflow=@sflow +