Configure Open vSwitch on CentOS | RHEL | Fedora

The
You can download this article in PDF format to support us through the following link.

Download the guide in PDF format

turn off
The

The
The

In a recent guide, we discussed the process of installing Open vSwitch on a CentOS/RHEL 8 Linux server. This article will continue to show you how to configure the network interface for use with Open vSwitch. I will demonstrate how to create a VLAN interface, how to create OVS Bridge and Bonds by manually editing configuration files or using auxiliary command line tools (for example, Open vSwitch). Operating system configuration.

I found using Operating system configuration Unlike manually editing configuration files in CentOS, RHEL or Fedora Linux systems, scripts are the best and efficient way to configure Open vSwitch. This is the method we will follow in this guide, but you can refer to the generated network configuration script to learn how to manually add the actual lines.

Step 1: Install Open vSwitch on CentOS | RHEL | Fedora

You may have installed Open vSwitch on the computer you want to use. If not installed, please refer to the following guide to install on RHEL/CentOS 8:

How to install Open vSwitch on CentOS 8. RHEL 8

For CentOS 7, use the following command:

sudo yum install -y epel-release centos-release-openstack-train
sudo yum install openvswitch libibverbs

On Fedora:

sudo dnf install openvswitch libibverbs

Activate and enable the openvswitch service:

sudo systemctl enable --now openvswitch

Verify by checking the service status:

$ systemctl status openvswitch
‚óŹ openvswitch.service - Open vSwitch
   Loaded: loaded (/usr/lib/systemd/system/openvswitch.service; enabled; vendor preset: disabled)
   Active: active (exited) since Sat 2020-06-06 13:56:42 UTC; 1s ago
  Process: 5826 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 5826 (code=exited, status=0/SUCCESS)

Step 2: Install the os-net-config network configuration tool

Next, let’s install the os-net-config CLI tool, which provides configuration of the host network in YAML or JSON file format.

By default, os-net-config uses the YAML configuration file located in the following location /etc/os-net-config/config.yaml. But this can be done --config-file(-c) CLI options.

Install os-net-config from OpenStack repository

If the OpenStack repository has been configured, you can install the tool from it.

sudo yum install os-net-config

View more detailed information about packaging:

$ rpm -qi os-net-config
Name        : os-net-config
Version     : 11.3.1
Release     : 1.el7
Architecture: noarch
Install Date: Sat 06 Jun 2020 02:10:08 PM UTC
Group       : Unspecified
Size        : 3848910
License     : ASL 2.0
Signature   : RSA/SHA1, Fri 17 Jan 2020 01:32:05 PM UTC, Key ID f9b9fee7764429e6
Source RPM  : os-net-config-11.3.1-1.el7.src.rpm
Build Date  : Tue 07 Jan 2020 08:43:47 AM UTC
Build Host  : c1bj.rdu2.centos.org
Relocations : (not relocatable)
Packager    : CBS <[email protected]>
Vendor      : CentOS
URL         : http://pypi.python.org/pypi/os-net-config
Summary     : Host network configuration tool
Description :
Host network configuration tool for OpenStack.

Install os-net-config using Pip

The os-net-config network configuration tool is distributed as a python package and can be installed with pip | pip3:

Fedora / CentOS 8:

sudo dnf install python3-pip

CentOS 7:

sudo yum install -y epel-release
sudo yum -y install python-pip
sudo pip install os-net-config

If the installation is successful, you should see output similar to the following at the end.

....
Downloading https://files.pythonhosted.org/packages/df/f5/9c052db7bd54d0cbf1bc0bb6554362bba1012d03e5888950a4f5c5dadc4e/scandir-1.10.0.tar.gz
Installing collected packages: pbr, anyjson, six, monotonic, dnspython, greenlet, enum34, eventlet, iso8601, netaddr, wrapt, debtcollector, stevedore, oslo.i18n, rfc3986, PyYAML, certifi, idna, chardet, urllib3, requests, oslo.config, pytz, netifaces, pyparsing, oslo.utils, fasteners, oslo.concurrency, pyrsistent, attrs, unknown, unknown, contextlib2, scandir, pathlib2, importlib-metadata, functools32, jsonschema, pyudev, os-net-config
  Running setup.py install for anyjson ... done
  Running setup.py install for wrapt ... done
  Running setup.py install for debtcollector ... done
  Running setup.py install for stevedore ... done
  Running setup.py install for oslo.i18n ... done
  Running setup.py install for PyYAML ... done
  Found existing installation: chardet 2.2.1
    Uninstalling chardet-2.2.1:
      Successfully uninstalled chardet-2.2.1
  Running setup.py install for oslo.config ... done
  Running setup.py install for oslo.utils ... done
  Running setup.py install for oslo.concurrency ... done
  Running setup.py install for pyrsistent ... done
  Running setup.py install for unknown ... done
  Running setup.py install for unknown ... done
  Running setup.py install for scandir ... done
  Running setup.py install for functools32 ... done
  Found existing installation: pyudev 0.15
    Uninstalling pyudev-0.15:
      Successfully uninstalled pyudev-0.15
  Running setup.py install for pyudev ... done
  Running setup.py install for os-net-config ... done
Successfully installed PyYAML-5.3.1 anyjson-0.3.3 attrs-19.3.0 certifi-2020.4.5.1 chardet-3.0.4 contextlib2-0.6.0.post1 debtcollector-2.1.0 dnspython-1.16.0 enum34-1.1.10 eventlet-0.25.2 fasteners-0.15 functools32-3.2.3.post2 greenlet-0.4.16 idna-2.9 importlib-metadata-1.6.1 iso8601-0.1.12 jsonschema-3.2.0 monotonic-1.5 netaddr-0.7.19 netifaces-0.10.9 os-net-config-12.3.0 oslo.concurrency-4.1.0 oslo.config-8.1.0 oslo.i18n-5.0.0 oslo.utils-4.2.0 pathlib2-2.3.5 pbr-5.4.5 pyparsing-2.4.7 pyrsistent-0.16.0 pytz-2020.1 pyudev-0.22.0 requests-2.23.0 rfc3986-1.4.0 scandir-1.10.0 six-1.15.0 stevedore-2.0.0 unknown-0.0.0 unknown-0.0.0 urllib3-1.25.9 wrapt-1.12.1
You are using pip version 8.1.2, however version 20.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

After installation, confirm that the command is in your PATH.

$ which os-net-config
/usr/bin/os-net-config

Step 3: Use os-net-config to configure an open vSwitch

After installing the openvswitch software package and the os-net-config command line tool, we can start configuring the OVS interface, bridging and binding according to your use case requirements.

Example 1: Single interface configuration with static IP address

Create a YAML configuration file:

$ vim ovs-interface.yml

Configure as follows.

network_config:
  - type: interface
    name: eth1
    use_dhcp: false
    use_dhcpv6: false
    addresses:
    - ip_netmask: 172.21.200.10/24
    routes:
      - ip_netmask: 0.0.0.0/0
        next_hop: 172.21.200.254
        default: true

This will configure the static IP address 172.21.200.10/24 and gateway 172.21.200.254 for the eth1 interface.

Application configuration:

$ sudo os-net-config -c ovs-interface.yml

Example 2: Configure OVS Bridge with a single connected interface (port)

For bridge creation, the configuration file is shown below.

$ vim ovs-bridge-single-interface.yml
network_config:
  - type: ovs_bridge
    name: br-ex
    use_dhcp: false
    use_dhcpv6: false
    addresses:
    - ip_netmask: 172.21.200.10/24
    routes:
      - ip_netmask: 0.0.0.0/0
        next_hop: 172.21.200.254
        default: true
    members:
      -
        type: interface
        name: eth1

Make changes and then apply the configuration Operating system configuration

Example 3: Configure the OVS bridge on top of the OVS binding

This is the configuration of the OVS bridge created on the OVS binding.

network_config:
  - type: ovs_bridge
     name: br-ex
     use_dhcp: true
     members:
       - type: ovs_bond
         name: bond1
         members:
           - type: interface
             name: em1
           - type: interface
             name: em2

Example 4: Configure tagged VLAN interface on top of OVS bridge

network_config:
  - type: ovs_bridge
    name: br-ctlplane
    use_dhcp: true
    members:
      - type: interface
        name: em1
      - type: vlan
        vlan_id: 20
        addresses:
          - ip_netmask: 192.0.2.1/24

Example 5: Create an OVS binding

This example will only create OVS bindings.

network_config:
  - type: ovs_bridge
    name: bond1
    use_dhcp: true
    members:
      - type: interface
        name: eno1
      - type: interface
        name: eno2

Check OVS configuration

After applying the OVS configuration, the network configuration script will be automatically added to the /etc/sysconfig/network-scripts/ directory.

$ ls /etc/sysconfig/network-scripts/

You can verify the OVS settings and port connection using the ovs-vsctl command:

$ ovs-vsctl show

Step 4: Use OVS to create a KVM network

If you use Open vSwitch with KVM virtualization, you need to define the network that the virtual machine will use.

Create a new bridge XML file.

$ vim kvm-ovs.xml

Add the bridge details to the file.


  ovs-bridge
  
  
  

where:

  • ovs-bridge Is the name of the libvirt network to be created.
  • Blakes Is the name of the OVS bridge that the created network will use.

To define a network from an XML file without starting it, use:

sudo virsh net-define  kvm-ovs.xml

To start the (previously defined) inactive network, use:

sudo virsh net-start ovs-bridge

To set the network to start automatically when the service starts:

sudo virsh net-autostart  ovs-bridge

Check to confirm that the auto start flag is set to “yes”-the persistence should also be displayed as “yes”.

$ sudo virsh net-list --all
 Name              State    Autostart   Persistent
----------------------------------------------------
 ovs-bridge        active   yes         yes
 default           active   yes         yes

Please stay tuned for more guidance on OVS. This is another interesting guide.

How to use Ansible playbook idly

Install Minikube Kubernetes on CentOS 8 using KVM

The
You can download this article in PDF format to support us through the following link.

Download the guide in PDF format

turn off
The

The
The

Sidebar