Sunday 9 June 2019

How to install and configure Open vSwitch on CentOS 7 Server



Open vSwitch is a multilayer software switch which is free and open source software released under Apache 2 license. Open vSwitch is well suited and used to manage the traffic between virtual machines and physical or logical networks. Open vSwitch supports multiple Linux-based virtualization and overlay techniques.
Step 1: Install the Open vSwitch package:

[root@linuxcloudy ~]# yum install https://repos.fedorapeople.org/repos/openstack/EOL/openstack-juno/epel-7/openvswitch-2.3.1-2.el7.x86_64.rpm
Loaded plugins: fastestmirror
……………<Output trimmed>……………………
Installed:
  openvswitch.x86_64 0:2.3.1-2.el7

Complete!
[root@linuxcloudy ~]#

Step 2: Enable and start the openvswitch daemon:

[root@linuxcloudy ~]# systemctl enable openvswitch
Created symlink from /etc/systemd/system/multi-user.target.wants/openvswitch.service to /usr/lib/systemd/system/openvswitch.service.
[root@linuxloudy ~]# systemctl start openvswitch
[root@linuxcloudy ~]#

Step3: Check the OVS switch status:

[root@linuxcloudy ~]# ovs-vsctl show
c3cfad53-425a-45a1-a7e9-926c468bd7de
    ovs_version: "2.3.1"
[root@linuxcloudy ~]#

Step 4: Create an Open vSwitch bridge device called ovs-br0 and verify:

[root@linuxcloudy ~]# ovs-vsctl add-br ovs-br0
[root@linuxcloudy ~]# ovs-vsctl show
c3cfad53-425a-45a1-a7e9-926c468bd7de
    Bridge "ovs-br0"
        Port "ovs-br0"
            Interface "ovs-br0"
                type: internal
    ovs_version: "2.3.1"
[root@linuxcloudy ~]#

Step 5: Modify interface configuration file /etc/sysconfig/network-scripts/ifcfg-ens33 and Create a bridge configuration file /etc/sysconfig/network-scripts/ifcfg-ovs-br0 with the following content:

[root@linuxcloudy ~]# cp -p /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ovs-br0
[root@linuxcloudy ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=OVSPort
DEVICETYPE=ovs
OVS_BRIDGE=ovs-br0
UUID=75307236-11fd-4723-bff0-eedad999257c
DEVICE=ens33
ONBOOT=yes

[root@linuxcloudy ~]# vi /etc/sysconfig/network-scripts/ifcfg-ovs-br0
DEVICE=ovs-br0
DEVICETYPE=ovs
TYPE=OVSBridge
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.43.19
PREFIX=24
GATEWAY=192.168.43.1

Step 6: Restart the network service:

[root@linuxcloudy ~]# systemctl restart network
[root@linuxcloudy ~]#

Step 7: Finally, verify the configuration:

[root@linuxcloudy ~]# ovs-vsctl show
c3cfad53-425a-45a1-a7e9-926c468bd7de
    Bridge "ovs-br0"
        Port "ovs-br0"
            Interface "ovs-br0"
                type: internal
        Port "ens33"
            Interface "ens33"
    ovs_version: "2.3.1"
[root@linuxcloudy ~]#

[root@linuxcloudy ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:bc:89:13 brd ff:ff:ff:ff:ff:ff
3: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master ovs-system state UP group default qlen 1000
    link/ether 00:0c:29:bc:89:09 brd ff:ff:ff:ff:ff:ff
4: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 3e:66:3e:46:9e:80 brd ff:ff:ff:ff:ff:ff
7: ovs-br0: <BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
    link/ether 00:0c:29:bc:89:09 brd ff:ff:ff:ff:ff:ff
    inet 192.168.43.19/24 brd 192.168.43.255 scope global ovs-br0
       valid_lft forever preferred_lft forever
    inet6 2405:204:302e:73f7:20c:29ff:febc:8909/64 scope global mngtmpaddr dynamic
       valid_lft forever preferred_lft forever
    inet6 fe80::1008:cbff:fe98:4cb0/64 scope link
       valid_lft forever preferred_lft forever
[root@linuxcloudy ~]#

[root@linuxcloudy ~]# ping -c4 192.168.43.1
PING 192.168.43.1 (192.168.43.1) 56(84) bytes of data.
64 bytes from 192.168.43.1: icmp_seq=1 ttl=64 time=4.09 ms
64 bytes from 192.168.43.1: icmp_seq=2 ttl=64 time=3.34 ms
64 bytes from 192.168.43.1: icmp_seq=3 ttl=64 time=2.67 ms
64 bytes from 192.168.43.1: icmp_seq=4 ttl=64 time=2.92 ms

--- 192.168.43.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 2.672/3.260/4.098/0.541 ms
[root@linuxcloudy ~]#

OVS vSwitch is now configured and ready for use!!!

No comments:

Post a Comment