I
I
IOV2019-09-24 18:09:48
KVM
IOV, 2019-09-24 18:09:48

How to properly configure kvm (libvirt) with ovs (openvswitch) on CentOS 7?

The task is to run virtual servers on a host available in a virtual local area network. That is, the host must have ip access to the guest OS, the guest OS must see each other and the host, and all must have Internet access. It is assumed that guest OSes get ip from DHCP inside the host (but this does not seem to happen).
I studied enough manuals (eng, rus) but with different configurations the result is the same.

I use the following installation algorithm
yum update -y
yum -y install epel-release
cat /proc/cpuinfo | egrep "(vmx|svm)"
mkdir -p /kvm/{images,iso,vm}
yum -y install qemu-kvm libvirt virt-install qemu-img virt-top
vi /etc/sysctl.conf
> net.ipv4.ip_forward=1
sysctl -p /etc/sysctl.conf
systemctl enable libvirtd && systemctl start libvirtd
virsh net-destroy default
virsh net-autostart --disable default
virsh net-undefine default
virsh net-list
systemctl disable NetworkManager
systemctl stop NetworkManager
systemctl enable network.service
systemctl start network.service
yum localinstall /home/ovs/rpmbuild/RPMS/x86_64/openvswitch-2.5.9-1.x86_64.rpm
ovs-vsctl -V
systemctl enable openvswitch.service
systemctl start openvswitch.service
systemctl status openvswitch.service
ovs-vsctl add-br ovs-br0
ovs-vsctl add-port ovs-br0 enp6s0 && systemctl restart network.service
systemctl restart network.service
systemctl status network.service

Network device configuration

ifcfg-enp6s0
TYPE=OVSPort
DEVICETYPE=ovs

DEVICE=enp6s0
NAME="enp6s0"
HWADDR="00:25:90:64:52:98"

ONBOOT=yes
HOTPLUG=no
#NETBOOT=yes
BOOTPROTO=none
ZONE=public

OVS_BRIDGE=ovs-br0

ifcfg-ovs-br0
TYPE=OVSBridge
DEVICETYPE=ovs

DEVICE="ovs-br0"

BOOTPROTO=none
ONBOOT="yes"
HOTPLUG=no
ZONE=public
IPV6INIT=no
IPV6_AUTOCONF=no

BOOTPROTO=static
IPADDR="XXX.XXX.247.78"
NETMASK="255.255.255.0"
GATEWAY="XXX.XXX.247.1"

Other default configurations
Starting the guest OS
virt-install --name test4 --memory 6144 --virt-type=kvm --autostart --vcpus 5 --os-variant=centos7.0 --cdrom /kvm/iso/CentOS-7-x86_64-Minimal-1611.iso --network network=ovs-network,model=virtio --graphics vnc,password=wera34 --disk path=/kvm/vm_a/test4.qcow2,size=50,bus=virtio,format=qcow2 --boot cdrom,hd,menu=on

ifconfig
enp6s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 00:25:90:64:52:98  txqueuelen 1000  (Ethernet)
        RX packets 1246684  bytes 901306695 (859.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 443026  bytes 49554746 (47.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  memory 0xfbce0000-fbd00000

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 16  bytes 4078 (3.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 16  bytes 4078 (3.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ovs-br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet XXX.XXX.247.78  netmask 255.255.255.0  broadcast XXX.XXX.247.255
        ether 00:25:90:64:52:98  txqueuelen 1000  (Ethernet)
        RX packets 1229399  bytes 877958427 (837.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 440429  bytes 45588952 (43.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether fe:54:00:cf:8c:9e  txqueuelen 1000  (Ethernet)
        RX packets 201  bytes 20062 (19.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 352962  bytes 22905957 (21.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

In this case, vnet0 is a guest OC device, ip is displayed in the manuals, but it is not.
Also, in this example, it is not visible (ipv6 was disabled, for the experiment), vnet0 displays ipv6, but not ipv4.
Tell me what could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Drno, 2019-09-24
@Drno

I don’t pretend to be correct, but my version of the
host system is cenos, it has KVM
inside KVM, its own router (Mikrotik) is already configured, it is in the role of a router
Behind the Mikrotik is already a server

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question