Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
docpublic:systemes:linux:virt_kvm8 [2021/09/03 14:55]
adminjp created
docpublic:systemes:linux:virt_kvm8 [2021/09/04 16:27] (current)
adminjp [ajout bridge]
Line 8: Line 8:
   * 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   * 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 ====
 +
 +
 +<code>
 +[root@localhost ~]# virsh net-list --all
 + Nom       État    Démarrage automatique   Persistent
 +-------------------------------------------------------
 + default   actif   Oui                     Oui
 +
 +[root@localhost ~]# virsh net-dumpxml default
 +<network connections='1'>
 +  <name>default</name>
 +  <uuid>dacd1fb3-7bda-4f2f-afd6-ce27d112e453</uuid>
 +  <forward mode='nat'>
 +    <nat>
 +      <port start='1024' end='65535'/>
 +    </nat>
 +  </forward>
 +  <bridge name='virbr0' stp='on' delay='0'/>
 +  <mac address='52:54:00:39:e6:60'/>
 +  <ip address='192.168.122.1' netmask='255.255.255.0'>
 +    <dhcp>
 +      <range start='192.168.122.2' end='192.168.122.254'/>
 +    </dhcp>
 +  </ip>
 +</network>
 +
 +
 +
 +[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 
 +</code>
 +
 +==== 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)  
 +
 +<code>
 +[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
 +</code>
 +
 +puis ajout de ce bridge dans l'environement libvirt/KVM via un fichier xml
 +
 +<code>
 +[root@localhost ~]# cat /root/kvm-bridge-br0.xml
 +<network>
 +  <name>br0</name>
 +  <forward mode="bridge"/>
 +  <bridge name="br0" />
 +</network>
 +</code>
 +
 +integration 
 +
 +<code>
 +[root@localhost ~]# virsh net-define /root/kvm-bridge-br0.xml
 +Réseau br0 défini depuis /root/kvm-bridge-br0.xml
 +</code>
 +
 +demarrage
 +
 +<code>
 +[root@localhost ~]# virsh net-start br0
 +Réseau br0 démarré
 +</code>
 +
 +et autostart
 +
 +<code>
 +[root@localhost ~]# virsh net-autostart br0
 +Réseau br0 marqué en démarrage automatique
 +</code>
 +
 +list des reseaux libvirt
 +
 +<code>
 + [root@localhost ~]# virsh net-list --all
 + Nom       État    Démarrage automatique   Persistent
 +-------------------------------------------------------
 + br0       actif   Oui                     Oui
 + default   actif   Oui                     Oui
 +</code>
 +
 +au final tout doit etre au vert, eventullement redemarer libvirt, NetworkManager
 +
 +<code>
 +[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
 +
 +</code>
docpublic/systemes/linux/virt_kvm8.1630680931.txt.gz · Last modified: 2021/09/03 14:55 by adminjp
[unknown link type]Back to top
CC Attribution-Noncommercial-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0