ARIE BREGMAN
Linux And Stu
This post turned out to be much longer than I planned. So I decided to split it into two
posts.
Overview
Installation
Basic commands ( add/delete bridge, add/delete ports, show con guration, etc)
http://abregman.com/2016/10/18/open-vswitch-introduction-part-1/ 1/17
12/10/2017 Open vSwitch: Introduction Part 1 Arie Bregman
The goal of the project (as speci edin the of cial documentation): Implement a
production quality switch platform that supports standard management interfaces
and opens the forwarding functions to programmatic extension and control.
It is a very popular project, used in a variety of SDN solutions. Youll probably bump
into it soon or later when deep diving into projects such as OpenStack and
OpenDaylight.
OpenvSwitch supports many of the features you already familiar with, assumingyou
worked with switches before:
VLAN tagging
LACP
STP
QOS
SPAN, RSPAN
http://abregman.com/2016/10/18/open-vswitch-introduction-part-1/ 2/17
12/10/2017 Open vSwitch: Introduction Part 1 Arie Bregman
As you cansee in the drawing, there is one bridge named my_bridge which was
created using openvswitch. You canhave more than onebridgeon your system, using
ovs-vsctl add-br command, which we will cover later.
Each bridge can havemultiple ports and each port consists of one or more interfaces.
In our example, there is one port named Bond, which is an actual bond of two
physical interfaces (eth0 and eth1).
First ovs command that well use is ovs-vsctl show. This command will print the
contents of the ovs database (in other words, your switches con guration).
Basically everything that you cansee in the drawing (note that in a fresh new
environment, you would not see anything except for ovs version and id.).
http://abregman.com/2016/10/18/open-vswitch-introduction-part-1/ 3/17
12/10/2017 Open vSwitch: Introduction Part 1 Arie Bregman
Installation
Before you can start using ovs, you need to install it on your system. The following
commands should work onFedora/CentOS/RHEL.
You should now be able to use the ovs-vsctl show command whichwe already used
in the overview section.
http://abregman.com/2016/10/18/open-vswitch-introduction-part-1/ 4/17
12/10/2017 Open vSwitch: Introduction Part 1 Arie Bregman
Im going to assume you already have a VM with eth0, so we will not cover the
creation of it, in this post.
We can then use then ovs-vsctl show command to verify our bridge was created.
7 type: internal
8 ovs_version: "2.5.0"
As you can see in the above output, there is now a new bridge named my_bridge. It
has one port, which is an internal (according to the type) and it mapped to an
interface called my_bridge.
Note thatour newly created bridge is not directly connected to our physical interface
(eth0). Lets change it.
We just lost connectivity to the external world. Check by yourself (the most popular
check today is probably pinging 8.8.8.8).
This is because eth0 is now connected to our bridge and not to the default IP stack of
the system. Our system still trying to reach the external network directly through
eth0. In order to recover our connectivity to the external network, we need to do two
things:
1. Remove eth0 address, since we no longer reach the internet directly through eth0
2. Assign my_bridge with address so we can reach the internet through it ( the ow
would be: IP stack -> my_bridge -> eth0).
Next, we will run dhclient to con gure my_bridge, so it can be allocated withan IP
address
Now that my_bridge has an IP address, we should be able to reach the internet once
again.
1 > ip a
2
3 4: my_bridge: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc no
4 link/ether ce:8b:5b:a7:a8:4f brd ff:ff:ff:ff:ff:ff
5 inet 192.168.121.195/24 brd 192.168.121.255 scope global dynamic my_bridg
6 valid_lft 3478sec preferred_lft 3478sec
7 inet6 fe80::cc8b:5bff:fea7:a84f/64 scope link
8 valid_lft forever preferred_lft forever
9
10 > ping 8.8.8.8
11
12 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
13 64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=105 ms
14 64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=105 ms
http://abregman.com/2016/10/18/open-vswitch-introduction-part-1/ 7/17
12/10/2017 Open vSwitch: Introduction Part 1 Arie Bregman
AddTAP device
Lets add a newinterface which well laterconnect to our virtual machine.
You might not be familiar with TUN, TAP interfaces, so lets take a second to explain
what they are exactly.
TUN,TAP devices are entirely virtual in contrast to other devices on your system (e.g
eth0) which associated with a physical address.
A TUN device operates in the third OSI layer (network) and used mostly for routing
traf c, while a TAP device operates in the second OSI layer (data link) and used to
process Ethernet frames.
Now lets add our newly created device to our ovs bridge
We can verify now with ovs-vsctl show that our ports are connected to my_bridge
http://abregman.com/2016/10/18/open-vswitch-introduction-part-1/ 8/17
12/10/2017 Open vSwitch: Introduction Part 1 Arie Bregman
This step implementation depends on the virtualization solution you are using.
Personally, Im using libvirt.
With libvirt, you go to the virtual machine properties (the light bulb icon) and click
atthe bottom onadd hardware button.
Next, you choose Network and in Network source you choose the virt _port device
and Bridge for Source mode as can seen in the following image
http://abregman.com/2016/10/18/open-vswitch-introduction-part-1/ 9/17
12/10/2017 Open vSwitch: Introduction Part 1 Arie Bregman
Congrats, we reached our goal. The virtual machine is now able to reach the internet,
through our ovs bridge my_bridge.
I highly recommend to test the connectivity with a simple check of ping 8.8.8.8. In
case it doesnt work, try to repeat the steps above or post a comment on this post and
Ill try to assist.
Delete a bridge
Now that we nished with our small exercise, we can cleanup the environment.
Note that it will also remove any related ports and interfaces.
Delete ports
To remove only a speci c port, you can use the following command
http://abregman.com/2016/10/18/open-vswitch-introduction-part-1/ 10/17
12/10/2017 Open vSwitch: Introduction Part 1 Arie Bregman
Command reference
I gathered all the commands we used in this post, for an easier reference
Q&A
Q: You describeda virtual switch andthe technology is called openvswitch, but the
actual commands use the wordbridge,why?
A: Switch is a bridge with multiple ports, dont let it confuse you, switch and bridge
are usually used interchangeably.
Share this:
Related
http://abregman.com/2016/10/18/open-vswitch-introduction-part-1/ 11/17
12/10/2017 Open vSwitch: Introduction Part 1 Arie Bregman
In "Linux"
Linux, Networking
OVS-VSCTL SWITCH
Leave a Reply
Your email address will not be published.
Name
Website
Post Comment
http://abregman.com/2016/10/18/open-vswitch-introduction-part-1/ 12/17
12/10/2017 Open vSwitch: Introduction Part 1 Arie Bregman
RECENT POSTS
RECENT COMMENTS
http://abregman.com/2016/10/18/open-vswitch-introduction-part-1/ 13/17
12/10/2017 Open vSwitch: Introduction Part 1 Arie Bregman
http://abregman.com/2016/10/18/open-vswitch-introduction-part-1/ 14/17
12/10/2017 Open vSwitch: Introduction Part 1 Arie Bregman
http://abregman.com/2016/10/18/open-vswitch-introduction-part-1/ 15/17
12/10/2017 Open vSwitch: Introduction Part 1 Arie Bregman
http://abregman.com/2016/10/18/open-vswitch-introduction-part-1/ 16/17
12/10/2017 Open vSwitch: Introduction Part 1 Arie Bregman
http://abregman.com/2016/10/18/open-vswitch-introduction-part-1/ 17/17