===== virt KVM 8 =====
==== references ====
* https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_virtualization/getting-started-with-virtualization-in-rhel-8_configuring-and-managing-virtualization
* https://www.techotopia.com/index.php/Creating_a_RHEL_KVM_Networked_Bridge_Interface
* https://blog.programster.org/kvm-cheatsheet
* https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_virtualization/managing-virtual-machines-in-the-web-console_configuring-and-managing-virtualization#setting-up-the-rhel-8-web-console-to-manage-vms_managing-virtual-machines-in-the-web-console
===== Network brige =====
par defautl il y a un switch virtuel (bridge virtbr0) qui fit du NAT avec les VM , elles se voient entre elles mais apparaisent avec l'IP de l'Hote et non sont pas directement accessible de l'exterieur (NAT)
ici on souhaite associer un nouveau bridge où nos VM auront leur propore IP directement attaché a l'interface Ethernet de l'hote .
cf https://www.techotopia.com/index.php/Creating_a_RHEL_KVM_Networked_Bridge_Interface
==== default bridge NAT ====
[root@localhost ~]# virsh net-list --all
Nom État Démarrage automatique Persistent
-------------------------------------------------------
default actif Oui Oui
[root@localhost ~]# virsh net-dumpxml default
default
dacd1fb3-7bda-4f2f-afd6-ce27d112e453
[root@localhost ~]# nmcli con show
NAME UUID TYPE DEVICE
eno2 e80109d2-4b12-4e5a-b331-6ab602f0ed9d ethernet eno2
tun0 4047e6a5-1927-41ab-b384-95b822b2c079 tun tun0
virbr0 1d44c04e-9d67-4f68-ba2c-0983cca8beb6 bridge virbr0
==== ajout bridge ====
on ajout un autre bridge sur notre interface ethernet physique (ici eno2) et affichage des fichiers txt créés a l'occasion (pour voir ce qui est fait en background)
[root@localhost ~]# nmcli con add ifname br0 type bridge con-name br0
Connexion « br0 » (d997c203-8b07-4f8c-820b-cc60f45968ee) ajoutée avec succès.
[root@localhost ~]# ls -ltr /etc/sysconfig/network-scripts/ | tail -1
-rw-r--r-- 1 root root 311 3 sept. 16:49 ifcfg-br0
[root@localhost ~]# nmcli con add type bridge-slave ifname eno2 master br0
Connexion « bridge-slave-eno2 » (8c9f5da5-4664-40ae-9afc-3fed2b7d1db4) ajoutée avec succès.
[root@localhost ~]# ls -ltr /etc/sysconfig/network-scripts/ | tail -1
-rw-r--r-- 1 root root 113 3 sept. 16:50 ifcfg-bridge-slave-eno2
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-bridge-slave-eno2
TYPE=Ethernet
NAME=bridge-slave-eno2
UUID=8c9f5da5-4664-40ae-9afc-3fed2b7d1db4
DEVICE=eno2
ONBOOT=yes
BRIDGE=br0
puis ajout de ce bridge dans l'environement libvirt/KVM via un fichier xml
[root@localhost ~]# cat /root/kvm-bridge-br0.xml
br0
integration
[root@localhost ~]# virsh net-define /root/kvm-bridge-br0.xml
Réseau br0 défini depuis /root/kvm-bridge-br0.xml
demarrage
[root@localhost ~]# virsh net-start br0
Réseau br0 démarré
et autostart
[root@localhost ~]# virsh net-autostart br0
Réseau br0 marqué en démarrage automatique
list des reseaux libvirt
[root@localhost ~]# virsh net-list --all
Nom État Démarrage automatique Persistent
-------------------------------------------------------
br0 actif Oui Oui
default actif Oui Oui
au final tout doit etre au vert, eventullement redemarer libvirt, NetworkManager
[root@localhost ~]# nmcli con show --active
NAME UUID TYPE DEVICE
br0 d997c203-8b07-4f8c-820b-cc60f45968ee bridge br0
virbr0 62d802a0-b046-40ad-9d40-b48183ff76d8 bridge virbr0
bridge-slave-eno2 8c9f5da5-4664-40ae-9afc-3fed2b7d1db4 ethernet eno2
vnet0 4ff25561-bc3b-4d86-a5e8-0062b5e7911c tun vnet0
[root@localhost ~]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.3448ed33418e yes eno2
vnet0
virbr0 8000.52540039e660 yes virbr0-nic