Skip to content

Instantly share code, notes, and snippets.

@kgrvamsi
Last active December 29, 2023 07:01
Show Gist options
  • Save kgrvamsi/39c0bd206819af5648d8 to your computer and use it in GitHub Desktop.
Save kgrvamsi/39c0bd206819af5648d8 to your computer and use it in GitHub Desktop.
Ovs Tutorials and theory
Ovs-- Open Virtual Switch
#########################
#################################
# Debian Installation of OVS #
#################################
apt-get update
apt-get install openvswitch-controller openvswitch-switch openvswitch-datapath-source
##################################
# Create Network Bridge #
##################################
## Adds a bridge inside the instance
ovs-vsctl add-br ovsbr0
## Adds a port to the bridge to eth interface
ovs-vsctl add-port ovsbr0 eth0
################################################
# Network interface setup to enable the bridge #
################################################
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
auto lo
# The loopback network interface
iface lo inet loopback
# eth0
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 0.0.0.0
# netmask 255.255.255.192
# post-up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.106.135.65
#ovsbr0
auto ovsbr0
iface ovsbr0 inet static
address 10.106.135.86
netmask 255.255.255.192
post-up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.106.135.65
bridge_ports eth0
bridge_stp off
# eth1
auto eth1
allow-hotplug eth1
iface eth1 inet static
address 192.155.236.3
netmask 255.255.255.240
gateway 192.155.236.1
'''''
Common options inside an interface stanza:
address – IP address for a static IP configured interface
netmask – netmask
gateway – The default gateway of a server. Be careful to use only one of this guy.
vlan-raw-device – On a VLAN interface, defines its "father".
bridge_ports – On a bridge interface, define its members.
down – Use the following command to down the interface instead of ifdown.
post-down – Actions taken right after the interface is down.
pre-up – Actions before the interface is up.
up – Use the following command to up the interface instead of ifup
################################################
# Ovs Gre Tunnel Setup
#
################################################
On Server1
sudo ovs-vsctl add-br br1
sudo ovs-vsctl add-br br2
sudo ovs-vsctl add-port br1 eth0
sudo ifconfig br1 $eth0ip netmask $eth0netmask
sudo ifconfig br2 10.1.1.1 netmask 255.255.255.0
sudo ovs-vsctl add-port br2 gre0 -- set interface gre0 type=gre options:remote_ip=$server2 ip
On Server2
sudo ovs-vsctl add-br br1
sudo ovs-vsctl add-br br2
sudo ovs-vsctl add-port br1 eth0
sudo ifconfig br1 $eth0ip netmask $eth0netmask
sudo ifconfig br2 10.1.1.1 netmask 255.255.255.0
sudo ovs-vsctl add-port br2 gre0 -- set interface gre0 type=gre options:remote_ip=$server1 ip
######################
# Ovs Db based commands
######################
ovsdb-client: Open vSwitch database JSON-RPC client
usage: ovsdb-client [OPTIONS] COMMAND [ARG...]
Valid commands are:
list-dbs [SERVER]
list databases available on SERVER
get-schema [SERVER] [DATABASE]
retrieve schema for DATABASE from SERVER
get-schema-version [SERVER] [DATABASE]
retrieve schema for DATABASE from SERVER and report only its
version number on stdout
list-tables [SERVER] [DATABASE]
list tables for DATABASE on SERVER
list-columns [SERVER] [DATABASE] [TABLE]
list columns in TABLE (or all tables) in DATABASE on SERVER
transact [SERVER] TRANSACTION
run TRANSACTION (a JSON array of operations) on SERVER
and print the results as JSON on stdout
monitor [SERVER] [DATABASE] TABLE [COLUMN,...]...
monitor contents of COLUMNs in TABLE in DATABASE on SERVER.
COLUMNs may include !initial, !insert, !delete, !modify
to avoid seeing the specified kinds of changes.
dump [SERVER] [DATABASE]
dump contents of DATABASE on SERVER to stdout
The default SERVER is unix:/var/run/openvswitch/db.sock.
The default DATABASE is Open_vSwitch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment