Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
elearning:workbooks:centos:8:avance:l104 [2021/09/02 17:00] adminelearning:workbooks:centos:8:avance:l104 [2022/02/22 15:15] (Version actuelle) – created admin
Ligne 1: Ligne 1:
 ~~PDF:LANDSCAPE~~ ~~PDF:LANDSCAPE~~
 +
 +Version : **2022.01**
  
 Dernière mise-à-jour : ~~LASTMOD~~ Dernière mise-à-jour : ~~LASTMOD~~
  
-======LCF604 - Gestion du Réseau et du Pare-feu======+======LCF604 - Présentation, Installation et Configuration de KVM======
  
 =====Contenu du Module===== =====Contenu du Module=====
  
-  * **LCF604 - Gestion du Réseaudu Pare-feu et du Serveur NFS**+  * **LCF604 - PrésentationInstallation et Configuration de KVM**
     * Contenu du Module     * Contenu du Module
     * Présentation     * Présentation
-      * La Commande nmcli +    * LAB #1 - Installation de KVM 
-    * LAB #1 - Configuration du Réseau +      * 1.1 - Installation des Paquets Requis 
-      * 1.1 - Connections et Profils +      * 1.2 - Activation et Démarrage du Service libvirtd  
-      * 1.2 - Résolution des Noms  +      * 1.3 - Modules du Noyau 
-      * 1.3 - Ajouter une Deuxième Adresse IP à un Profil +    * LAB #2 - Configuration de KVM        
-      * 1.4 - La Commande hostname +      * 2.1 - Configuration du Pare-feu 
-      * 1.5 - La Commande ip +      * 2.2 - Configuration du Réseau des VMs 
-      * 1.6 - Activer/Désactiver une Interface Manuellement +      * 2.3 - Configuration du Stockage
-      * 1.7 - Routage Statique +
-        * La commande ip +
-        * Activer/désactiver le routage sur le serveur +
-    * LAB #2 - Diagnostique du Réseau +
-      * 2.1 - ping +
-      * 2.2 - netstat -i +
-      * 2.3 - traceroute +
-    * LAB #3 - Connexions à Distance +
-      * 3.1 - Telnet +
-      * 3.2 - wget +
-      * 3.3 - ftp +
-      * 3.4 - SSH +
-        * Présentation +
-          * SSH-1 +
-          * SSH-2 +
-        * Authentification par mot de passe +
-        * Authentification par clef asymétrique +
-        * Configuration du Serveur +
-        * Configuration du Client +
-        * Tunnels SSH +
-      * 3.5 - SCP +
-        * Présentation +
-        * Utilisation +
-      * 3.6 - Mise en Place des Clefs Asymétriques +
-    * LAB #4 - La Configuration de firewalld +
-      * 4.1 - Présentation +
-      * 4.- La Configuration de Base de firewalld +
-      * 4.3 - L'Utilisation de Base de Firewalld +
-      * 4.4 - La Configuration Avancée de firewalld +
-      * 4.5 - Le mode Panic de firewalld+
  
 =====Présentation===== =====Présentation=====
  
-RHEL/CentOS 8 utilise **Network Manager** pour gérer le réseau. Network Manager est composé de deux éléments :+====La Virtualisation====
  
-  un service qui gère les connexions réseaux et rapporte leurs états, +Le système de base hébergeant les machines virtuelles est appelé l'**hôte** tandis que les machines virtuelles sont appelées les **invités**.
-  des front-ends qui passent par un API de configuration du service.+
  
-<WRAP center round important> +Il existe différentes méthodes de virtualisation :
-**Important** : Notez qu'avec cette version de NetworkManager, IPv6 est activée par défaut. +
-</WRAP>+
  
-Le service NetworkManager doit toujours être lancé :+  * **Virtualisation au niveau du système d'exploitation ou //L'Isolation//** 
 +    * **Description** : Les systèmes invités utilisent le même noyau et une partie du système de fichiers de l'hôte. 
 +    * **L'avantage principal** : Économise des ressources. 
 +    * **L'inconvénient principal** : Les OS des invités ont besoin d'être modifiés pour fonctionner en tant que machine virtuelle. L'hôte et les invités doivent utiliser le même OS. 
 +    * **Logiciels concernés** %%OpenVZ%%, Linux %%VServer%%, BSD Jails, LXC (Linux Containers), Solaris Zones, Docker.
  
-<code> +{{ :elearning:workbooks:centos:6:senior:inheritedpackageszones.png?nolink&300 |}}
-[root@centos8 ~]# systemctl status NetworkManager.service +
-● NetworkManager.service - Network Manager +
-   Loadedloaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor pr> +
-   Activeactive (running) since Thu 2021-07-22 05:05:29 EDT; 1 months 7 days ago +
-     Docsman:NetworkManager(8) +
- Main PID: 1002 (NetworkManager) +
-    Tasks: 3 (limit: 23535) +
-   Memory: 6.8M +
-   CGroup: /system.slice/NetworkManager.service +
-           └─1002 /usr/sbin/NetworkManager --no-daemon+
  
-WarningJournal has been rotated since unit was startedLog output is incomplete or> +  * **Paravirtualisation ou //Hyperviseur de type 1//** 
-lines 1-11/11 (END) +    * **Description** Le système hôte met à disposition une machine virtuelle dans laquelle les autres invités s'exécutent. Les systèmes invités sont modifiés et communiquent directement avec l'hyperviseur
-[^q] +    * **L'avantage principal** : Efficacité. 
-</code>+    * **L'inconvénient principal** : Les OS des invités ont besoin d'être modifiés pour fonctionner en tant que machine virtuelle. 
 +    * **Logiciels concernés** : Xen, VMWare(tm) ESX, Microsoft(tm) Hyper-V.
  
-===La Commande nmcli===+{{ :elearning:workbooks:centos:6:senior:hyperviseur1.png?nolink&300 |}}
  
-La commande **nmcli** (Network Manager Command Line Interfaceest utilisée pour configurer NetworkManager.+  * **Virtualisation complète ou //Hyperviseur de type 2//** 
 +    * **Description** : Le programme simule du matériel virtuel qui apparaît du point de vue de l'invité comme du matériel réellement existant. Un **hyperviseur** ou **VMM** ( //Virtual Machine Manager// contrôle l'invité et remplace certaines opérations par d'autres afin de gérer le processeur, le disque dur, la mémoire, les processus etc.. 
 +    * **L'avantage principal** : Les OS des invités n'ont pas besoin d'être modifiés pour fonctionner en tant que machine virtuelle. 
 +    * **L'inconvénient principal** : La lenteur. 
 +    * **Logiciels concernés** : VMWare(tm) Fusion, VMWare(tm) Player, VMWare(tm) Server, VMWare(tm) Fusion, Parallels Desktop, Parallels Server, Sun/Oracle %%VirtualBox%%, Microsoft(tm) VirtualPC, Microsoft(tm) VirtualServer, QEMU, BOCHS.
  
-Les options et les sous-commandes peuvent être consultées en utilisant les commandes suivantes :+{{ :elearning:workbooks:centos:6:senior:hyperviseur2.png?nolink&300 |}}
  
-<code> +  * **Paravirtualisation avec prise en charge de matériel** 
-[root@centos8 ~]# nmcli help +    * **Description** : Les processeurs Intel-VT et AMD-V contiennent des instructions matérielles pour faciliter la virtualisation. Pour déterminer si le processeur dispose des fonctionnalités de virtualisation matérielles, soit Intel-VT, soit AMD-V, lancez la commande **# egrep '^flags.*(vmx|svm)' /proc/cpuinfo [Entrée]**. Dans le cas où vous ne voyez rien, le processeur ne dispose **pas** de fonctionnalités de virtualisation matérielles. Par contre, même dans le cas de la prise en charge, vérifiez que les fonctionnalités soient activées dans le BIOS de la machine. 
-Usagenmcli [OPTIONS] OBJECT { COMMAND | help }+    * **L'avantage principal** Efficacité liée au fait que la plupart des OS des invités n'ont pas besoin d'être modifiés pour fonctionner en tant que machine virtuelle. 
 +    * **L'inconvénient principal** : Nécessite un processeur spécial. 
 +    * **Logiciels concernés** : Xen, KVM
  
-OPTIONS +{{ :elearning:workbooks:centos:6:senior:xen-schema.png?nolink&300 |}}
-  -a, --ask                                ask for missing parameters +
-  -c, --colors auto|yes|no                 whether to use colors in output +
-  -e, --escape yes|no                      escape columns separators in values +
-  -f, --fields <field,...>|all|common      specify fields to output +
-  -g, --get-values <field,...>|all|common  shortcut for -m tabular -t -f +
-  -h, --help                               print this help +
-  -m, --mode tabular|multiline             output mode +
-  -o, --overview                           overview mode +
-  -p, --pretty                             pretty output +
-  -s, --show-secrets                       allow displaying passwords +
-  -t, --terse                              terse output +
-  -v, --version                            show program version +
-  -w, --wait <seconds>                     set timeout waiting for finishing operations+
  
-OBJECT +====Xen====
-  g[eneral]       NetworkManager's general status and operations +
-  n[etworking]    overall networking control +
-  r[adio]         NetworkManager radio switches +
-  c[onnection]    NetworkManager's connections +
-  d[evice]        devices managed by NetworkManager +
-  a[gent]         NetworkManager secret agent or polkit agent +
-  m[onitor]       monitor NetworkManager changes +
-</code>+
  
-=====LAB #1 Configuration du Réseau=====+  * **[[http://www.xenproject.org/|Xen]]** a vu le jour en 2001 à l'**[[http://www.cl.cam.ac.uk/research/srg/netos/xen/index.html|Université de Cambridge]]**, 
 +  * Xen est un produit en licence GPL, 
 +  * Il existe des systèmes de virtualisation commerciaux à base de Xen dont le plus connu est actuellement **Citrix %%XenServer%%**, 
 +  * Xen est un système de virtualisation principalement destiné à la virtualisation de serveurs, 
 +  * Xen est un système de **paravirtualisation** qui nécessite un noyau Linux modifié, 
 +  * Xen ne peut pas lancé donc un système non-modifié tel Windows(tm) en mode paravirtualisation, 
 +  * Xen peut lancer des systèmes non modifiés dans des **HVM** ( //Hardware Virtual Machine// ) depuis sa version 3 en utilisant une partie du code de QEMU combinée avec l'utilisation d'un processeur de virtualisation
  
-====1.1 - Connections et Profils====+====KVM====
  
-NetworkManager inclus la notion de **connections** ou **profils** permettant des configurations différentes en fonction de la localisation. Pour voir les connections actuelles, utilisez la commande **nmcli c** avec la sous-commande **show** :+**[[http://www.linux-kvm.org|KVM]]** ou **K**ernel based **V**irtual **M**achine :
  
-<code> +  * est un hyperviseur libre sous Linux, 
-[root@centos8 ~]# nmcli c show +  * ne fonctionne que sur les architectures x86 disposant des extensions Intel-VT ou AMD-V, 
-NAME    UUID                                  TYPE      DEVICE  +  * est un projet issu de QEMU.
-ens18   fc4a4d23-b15e-47a7-bcfa-b2e08f49553e  ethernet  ens18   +
-virbr0  03f6c432-2a09-47e7-9693-208431a572ee  bridge    virbr0  +
-</code>+
  
-Créez donc un profil IP fixe rattaché au périphérique **ens18** :+<WRAP center round important 60%> 
 +Important : Le module KVM est intégré dans le noyau Linux depuis la version 2.6.20 et permet la paravirtualisation depuis le noyau **2.6.25**
 +</WRAP>
  
-<code> +**KVM** appartient à la société **Red Hat**.
-[root@centos8 ~]# nmcli connection add con-name ip_fixe ifname ens18 type ethernet ip4 10.0.2.46/24 gw4 10.0.2.1 +
-Connection 'ip_fixe' (0f48c74d-5d16-4c37-8220-24644507b589) successfully added. +
-</code>+
  
-Constatez sa présence :+KVM permet de virtualiser :
  
-<code> +  * Windows(tm) à partir de Windows(tm) 2000, 
-[root@centos8 ~]# nmcli c show +  * Toutes les distributions Linux, 
-NAME     UUID                                  TYPE      DEVICE  +  * La majorité des Unix BSD, 
-ens18    fc4a4d23-b15e-47a7-bcfa-b2e08f49553e  ethernet  ens18   +  * Solaris(tm) et openSolaris, 
-virbr0   03f6c432-2a09-47e7-9693-208431a572ee  bridge    virbr0  +  * Minux, Hurd, QNX, 
-ip_fixe  0f48c74d-5d16-4c37-8220-24644507b589  ethernet  --    +  * MSDOS.
-</code>+
  
-Notez que la sortie n'indique pas que le profil **ip_fixe** soit associé au periphérique **ens18** car le profil **ip_fixe** n'est pas activé :+KVM offre un support du matériel suivant :
  
-<code> +  * USB, 
-[root@centos8 ~]# nmcli d show +  * Ethernet, 
-GENERAL.DEVICE:                         ens18 +  * PCI Hotplug
-GENERAL.TYPE:                           ethernet +  * Carte Son
-GENERAL.HWADDR:                         4E:B1:31:BD:5D:B2 +  * **Virtuo** - un périphérique disque paravirtualisé
-GENERAL.MTU:                            1500 + 
-GENERAL.STATE:                          100 (connected) +Les avantages de KVM par rapport à Xen sont :
-GENERAL.CONNECTION:                     ens18 +
-GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnect> +
-WIRED-PROPERTIES.CARRIER:               on +
-IP4.ADDRESS[1]:                         10.0.2.45/24 +
-IP4.GATEWAY:                            10.0.2.1 +
-IP4.ROUTE[1]:                           dst = 10.0.2.0/24nh = 0.0.0.0, mt = 100 +
-IP4.ROUTE[2]:                           dst = 0.0.0.0/0nh = 10.0.2.1, mt = 100 +
-IP4.DNS[1]:                             8.8.8.8 +
-IP6.ADDRESS[1]:                         fe80::86b6:8d39:cab2:d84d/64 +
-IP6.GATEWAY                           -- +
-IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 100 +
-IP6.ROUTE[2]:                           dst = ff00::/8, nh = ::, mt = 256, table=255+
  
-GENERAL.DEVICE:                         virbr0 +  * l’utilisation de noyaux non-modifiés au niveaux des invités
-GENERAL.TYPE:                           bridge +  * l'intégration direct dans le noyau Linux.
-GENERAL.HWADDR:                         52:54:00:79:02:66 +
-GENERAL.MTU:                            1500 +
-GENERAL.STATE:                          100 (connected (externally)) +
-GENERAL.CONNECTION:                     virbr0 +
-GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnect> +
-IP4.ADDRESS[1]:                         192.168.122.1/24 +
-IP4.GATEWAY:                            -- +
-IP4.ROUTE[1]:                           dst = 192.168.122.0/24nh = 0.0.0.0, mt = 0 +
-IP6.GATEWAY:                            --+
  
-GENERAL.DEVICE:                         lo +=====LAB #1 - Installation de KVM=====
-GENERAL.TYPE:                           loopback +
-GENERAL.HWADDR:                         00:00:00:00:00:00 +
-GENERAL.MTU:                            65536 +
-GENERAL.STATE:                          10 (unmanaged) +
-GENERAL.CONNECTION:                     -- +
-GENERAL.CON-PATH:                       -- +
-IP4.ADDRESS[1]:                         127.0.0.1/8 +
-IP4.GATEWAY:                            -+
-IP6.ADDRESS[1]:                         ::1/128 +
-IP6.GATEWAY:                            -- +
-IP6.ROUTE[1]:                           dst ::1/128, nh ::, mt 256+
  
-GENERAL.DEVICE:                         virbr0-nic +====1.Installation des Paquets Requis==== 
-GENERAL.TYPE:                           tun + 
-GENERAL.HWADDR:                         52:54:00:79:02:66 +Avant d'installer KVM, il convient de savoir si le processeur de l'hôte supporte les extensions de virtualisationLes extensions necessaires sont soit **vmx** soit **svm** selon que le processeur du système hôte soit de la marque Intel(tm) ou AMD(tm) : 
-GENERAL.MTU:                            1500 +         
-GENERAL.STATE:                          10 (unmanaged) +<code>         
-GENERAL.CONNECTION                    -- +[root@centos8 ~]# egrep '(vmx|svm)' /proc/cpuinfo | wc -l  
-GENERAL.CON-PATH:                       -- +8
-lines 28-50/50 (END+
-[q]+
 </code> </code>
  
-Pour activer le profil ip_fixe, utilisez la commande suivante :+La majorité des paquets necéssaires pour la virtualisation sous KVM ont été regroupés dans un **module** dénommé **virt**. Il convient donc de l'installer avec la commande **dnf** :
  
-<code> +<code>  
-[root@centos8 ~]# nmcli connection up ip_fixe+[root@centos8 ~]# dnf module install virt -y  
 +</code> 
 + 
 +Si vous souhaitez utiliser l'interface graphique (non-recommandée) pour administrer les machines virtuelles, vous devez installer le paquet **virt-viewer** :
  
 +<code> 
 +[root@centos8 ~]# dnf install virt-install virt-viewer -y   
 </code> </code>
  
-Notez que votre terminal est bloqué à cause du changement de l'adresse IPFermez le terminal et re-connectez-vous en SSH :+Le paquet **bridge-utils** est requis pour la gestion des bridges réseauInstallez donc celui-ci :
  
 <code> <code>
-root@compute10:~# ssh -l trainee 10.0.2.46 +[root@centos8 ~]dnf install epel-release -y   
-The authenticity of host '10.0.2.46 (10.0.2.46)' can't be established. +[root@centos8 ~]# dnf install bridge-utils -y  
-ECDSA key fingerprint is SHA256:Q7T/CP0SLiMbMAIgVzTuEHegYS/spPE5zzQchCHD5Vw. +</code>
-Are you sure you want to continue connecting (yes/no)? yes +
-Warning: Permanently added '10.0.2.46' (ECDSA) to the list of known hosts. +
-trainee@10.0.2.46's password: trainee +
-Activate the web console with: systemctl enable --now cockpit.socket+
  
-Last login: Sun Aug 29 00:31:15 2021 from 10.0.2.1 +Dernièrement, les outils dont vous aurez besoin se trouvent dans les paquets **virt-top** et **libguestfs-tools** :
-[trainee@centos8 ~]$ su - +
-Passwordfenestros +
-[root@centos8 ~]#  +
-</code> +
  
-Le profil ip_fixe est maintenant activé tandis que le profil enp0s3 a été désactivé :+<code>  
 +[root@centos8 ~]# dnf install virt-top libguestfs-tools -y 
 +</code>
  
-<code> +====1.2 - Activation et Démarrage du Service libvirtd====
-[root@centos8 ~]# nmcli c show +
-NAME     UUID                                  TYPE      DEVICE  +
-ip_fixe  0f48c74d-5d16-4c37-8220-24644507b589  ethernet  ens18   +
-virbr0   03f6c432-2a09-47e7-9693-208431a572ee  bridge    virbr0  +
-ens18    fc4a4d23-b15e-47a7-bcfa-b2e08f49553e  ethernet  --   +
-    +
-[root@centos8 ~]# nmcli d show +
-GENERAL.DEVICE:                         ens18 +
-GENERAL.TYPE:                           ethernet +
-GENERAL.HWADDR:                         4E:B1:31:BD:5D:B2 +
-GENERAL.MTU:                            1500 +
-GENERAL.STATE:                          100 (connected) +
-GENERAL.CONNECTION:                     ip_fixe +
-GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnect> +
-WIRED-PROPERTIES.CARRIER:               on +
-IP4.ADDRESS[1]:                         10.0.2.46/24 +
-IP4.GATEWAY:                            10.0.2.1 +
-IP4.ROUTE[1]:                           dst 10.0.2.0/24, nh 0.0.0.0, mt 100 +
-IP4.ROUTE[2]:                           dst 0.0.0.0/0, nh = 10.0.2.1, mt = 100 +
-IP6.ADDRESS[1]:                         fe80::5223:aee1:998e:9f27/64 +
-IP6.GATEWAY:                            -+
-IP6.ROUTE[1]:                           dst fe80::/64, nh ::, mt 100 +
-IP6.ROUTE[2]:                           dst ff00::/8, nh = ::, mt = 256, table=255 +
- +
-GENERAL.DEVICE:                         virbr0 +
-GENERAL.TYPE:                           bridge +
-GENERAL.HWADDR:                         52:54:00:79:02:66 +
-GENERAL.MTU:                            1500 +
-GENERAL.STATE:                          100 (connected (externally)) +
-GENERAL.CONNECTION:                     virbr0 +
-GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnect> +
-IP4.ADDRESS[1]:                         192.168.122.1/24 +
-IP4.GATEWAY:                            -- +
-IP4.ROUTE[1]:                           dst = 192.168.122.0/24, nh = 0.0.0.0, mt = 0 +
-IP6.GATEWAY:                            --+
  
-GENERAL.DEVICE:                         lo +Activez et démarrez le service **libvirtd** pour démarrer KVMNotez l'utilisation de l'option **--now** qui permet de faire les deux actions en une seule ligne de commande :
-GENERAL.TYPE:                           loopback +
-GENERAL.HWADDR:                         00:00:00:00:00:00 +
-GENERAL.MTU:                            65536 +
-GENERAL.STATE:                          10 (unmanaged) +
-GENERAL.CONNECTION:                     -- +
-GENERAL.CON-PATH:                       -- +
-IP4.ADDRESS[1]:                         127.0.0.1/+
-IP4.GATEWAY:                            -- +
-IP6.ADDRESS[1]:                         ::1/128 +
-IP6.GATEWAY:                            -- +
-IP6.ROUTE[1]:                           dst = ::1/128, nh = ::, mt = 256+
  
-GENERAL.DEVICE:                         virbr0-nic +<code> 
-GENERAL.TYPE:                           tun +[root@centos8 ~]# systemctl enable --now libvirtd
-GENERAL.HWADDR:                         52:54:00:79:02:66 +
-GENERAL.MTU:                            1500 +
-GENERAL.STATE:                          10 (unmanaged) +
-GENERAL.CONNECTION:                     -- +
-GENERAL.CON-PATH:                       -- +
-lines 27-49/49 (END) +
-[q]+
 </code> </code>
  
-Pour consulter les paramètres du profil **ens18**, utilisez la commande suivante :+Vérifiez le statut du service avant de poursuivre :
  
 <code> <code>
-[root@centos8 ~]# nmcli -p connection show ens18 +[root@centos8 ~]# systemctl status libvirtd 
-=============================================================================== +● libvirtd.service Virtualization daemon 
-                      Connection profile details (ens18) +   Loadedloaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor presetenabled
-=============================================================================== +   Activeactive (runningsince Wed 2021-09-01 10:19:05 EDT; 11s ago 
-connection.id:                          ens18 +     Docsman:libvirtd(8
-connection.uuid:                        fc4a4d23-b15e-47a7-bcfa-b2e08f49553e +           https://libvirt.org 
-connection.stable-id                  -- + Main PID7502 (libvirtd
-connection.type                       802-3-ethernet +    Tasks19 (limit: 32768
-connection.interface-name:              ens18 +   Memory49.3M 
-connection.autoconnect:                 yes +   CGroup/system.slice/libvirtd.service 
-connection.autoconnect-priority:        0 +           ├─1942 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper 
-connection.autoconnect-retries:         -1 (default+           ├─1943 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper 
-connection.multi-connect              0 (default) +           └─7502 /usr/sbin/libvirtd --timeout 120 
-connection.auth-retries:                -+ 
-connection.timestamp                  1630224060 +Sep 01 10:19:05 centos8.ittraining.loc systemd[1]Starting Virtualization daemon... 
-connection.read-only                  no +Sep 01 10:19:05 centos8.ittraining.loc systemd[1]Started Virtualization daemon
-connection.permissions                -- +Sep 01 10:19:06 centos8.ittraining.loc dnsmasq[1942]read /etc/hosts addresses 
-connection.zone                       -- +Sep 01 10:19:06 centos8.ittraining.loc dnsmasq[1942]read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses 
-connection.master:                      -- +Sep 01 10:19:06 centos8.ittraining.loc dnsmasq-dhcp[1942]read /var/lib/libvirt/dnsmasq/default.hostsfile
-connection.slave-type:                  -- +
-connection.autoconnect-slaves:          -1 (default+
-connection.secondaries                -- +
-connection.gateway-ping-timeout:        0 +
-connection.metered                    unknown +
-connection.lldp:                        default +
-connection.mdns:                        -1 (default+
-connection.llmnr                      -1 (default+
-connection.wait-device-timeout        -1 +
-------------------------------------------------------------------------------- +
-802-3-ethernet.port:                    -- +
-802-3-ethernet.speed                  0 +
-802-3-ethernet.duplex:                  -- +
-802-3-ethernet.auto-negotiate:          no +
-802-3-ethernet.mac-address:             -- +
-802-3-ethernet.cloned-mac-address:      -- +
-802-3-ethernet.generate-mac-address-mask:-- +
-802-3-ethernet.mac-address-blacklist:   -- +
-802-3-ethernet.mtu:                     auto +
-802-3-ethernet.s390-subchannels:        -- +
-802-3-ethernet.s390-nettype:            -+
-802-3-ethernet.s390-options:            -- +
-802-3-ethernet.wake-on-lan:             default +
-802-3-ethernet.wake-on-lan-password   -- +
-------------------------------------------------------------------------------- +
-ipv4.method                           manual +
-ipv4.dns:                               8.8.8.8 +
-ipv4.dns-search:                        ittraining.loc +
-ipv4.dns-options                      -- +
-ipv4.dns-priority:                      0 +
-ipv4.addresses:                         10.0.2.45/24 +
-ipv4.gateway:                           10.0.2.1 +
-ipv4.routes                           -- +
-ipv4.route-metric                     -1 +
-ipv4.route-table:                       0 (unspec) +
-ipv4.routing-rules:                     -- +
-ipv4.ignore-auto-routes:                no +
-ipv4.ignore-auto-dns:                   no +
-ipv4.dhcp-client-id:                    -- +
-ipv4.dhcp-iaid:                         -- +
-ipv4.dhcp-timeout:                      0 (default) +
-ipv4.dhcp-send-hostname:                yes +
-ipv4.dhcp-hostname:                     -- +
-ipv4.dhcp-fqdn:                         -- +
-ipv4.dhcp-hostname-flags:               0x0 (none) +
-ipv4.never-default:                     no +
-ipv4.may-fail:                          yes +
-ipv4.dad-timeout:                       -(default) +
-ipv4.dhcp-vendor-class-identifier     -- +
-ipv4.dhcp-reject-servers:               -- +
-------------------------------------------------------------------------------- +
-ipv6.method                           auto +
-ipv6.dns                              -- +
-ipv6.dns-search:                        -- +
-ipv6.dns-options                      -+
-ipv6.dns-priority:                      0 +
-ipv6.addresses:                         -- +
-ipv6.gateway                          -- +
-ipv6.routes                           -- +
-ipv6.route-metric:                      -1 +
-ipv6.route-table                      0 (unspec) +
-ipv6.routing-rules:                     -- +
-ipv6.ignore-auto-routes:                no +
-ipv6.ignore-auto-dns:                   no +
-ipv6.never-default:                     no +
-ipv6.may-fail:                          yes +
-ipv6.ip6-privacy:                       (disabled) +
-ipv6.addr-gen-mode                    stable-privacy +
-ipv6.ra-timeout                       0 (default) +
-ipv6.dhcp-duid:                         -- +
-ipv6.dhcp-iaid:                         -- +
-ipv6.dhcp-timeout                     0 (default+
-ipv6.dhcp-send-hostname:                yes +
-ipv6.dhcp-hostname:                     -- +
-ipv6.dhcp-hostname-flags:               0x0 (none) +
-ipv6.token:                             -- +
-------------------------------------------------------------------------------- +
-proxy.method:                           none +
-proxy.browser-only:                     no +
-proxy.pac-url:                          -- +
-proxy.pac-script:                       -- +
-------------------------------------------------------------------------------- +
-lines 56-100/100 (END) +
-[q]+
 </code> </code>
  
-De même, pour consulter les paramètres du profil **ip_fixe**, utilisez la commande suivante :+====1.3 - Modules du Noyau==== 
 + 
 +Votre VM présente aux système hôte un processeur de type Intel(tm). Pour que KVM puisse fonctionner dans cet environnement il a besoin que deux modules soient chargés : 
 + 
 +  * **kvm*
 +  * **kvm-intel** 
 +   
 +Vérifiez donc le bon chargement des modules concernés :
  
 <code> <code>
-[root@centos8 ~]# nmcli -p connection show ip_fixe +[root@centos8 ~]# modinfo kvm 
-=============================================================================== +filename      /lib/modules/4.18.0-305.7.1.el8.i2tch.x86_64/kernel/arch/x86/kvm/kvm.ko.xz 
-                     Connection profile details (ip_fixe) +license:        GPL 
-=============================================================================== +author:         Qumranet 
-connection.id                         ip_fixe +rhelversion   8.4 
-connection.uuid:                        0f48c74d-5d16-4c37-8220-24644507b589 +srcversion    0B52FB25C4DD9865FC4FABA 
-connection.stable-id:                   -- +depends       irqbypass 
-connection.type:                        802-3-ethernet +intree        Y 
-connection.interface-name:              ens18 +name          kvm 
-connection.autoconnect:                 yes +vermagic      4.18.0-305.7.1.el8.i2tch.x86_64 SMP mod_unload modversions  
-connection.autoconnect-priority:        0 +sig_id        PKCS#7 
-connection.autoconnect-retries:         -1 (default) +signer:         CentOS kernel signing key 
-connection.multi-connect              0 (default) +sig_key       38:77:B1:DF:46:4F:B7:5C:99:8B:B9:BF:70:A4:10:85:91:7F:50:C1 
-connection.auth-retries:                -1 +sig_hashalgo:   sha256 
-connection.timestamp                  1630224329 +signature     24:2A:F9:57:2C:FB:D8:B1:3B:4B:FA:70:3B:FC:7E:23:E1:AC:06:5B
-connection.read-only                  no +                8D:0B:83:15:A5:56:43:04:23:FD:89:B1:BD:2C:8B:D0:0D:99:8C:9B
-connection.permissions                -- +                16:E5:E8:BB:C2:32:EE:62:18:E2:38:F9:2D:9D:1A:68:CA:63:3C:3B
-connection.zone                       -- +                B1:02:2E:46:FF:DF:6C:28:33:79:6D:FA:63:0A:B3:BA:DC:C7:FC:1D
-connection.master                     -- +                FF:14:21:6C:AC:4B:67:2E:EC:A3:B8:96:A0:02:8C:BB:34:CA:CE:23
-connection.slave-type:                  -- +                BD:34:10:B0:87:B6:55:7C:A9:24:1C:3A:94:9B:05:66:0D:E5:EE:28
-connection.autoconnect-slaves:          -1 (default) +                CF:EE:74:9C:D3:CD:96:07:92:F6:D0:6C:FF:94:67:7A:C2:BB:26:BD
-connection.secondaries:                 -- +                A9:AA:04:7C:19:64:1C:3D:9D:20:EE:1F:12:C1:D2:64:D3:36:62:22
-connection.gateway-ping-timeout:        0 +                CD:3D:F7:45:0F:E3:09:89:AC:11:54:AA:C5:56:E7:FE:CA:0C:AD:2A
-connection.metered:                     unknown +                FB:60:47:5A:70:6D:AF:F2:4D:6B:60:53:EA:95:4B:E9:BB:F0:F7:71: 
-connection.lldp:                        default +                19:6A:60:F5:12:6D:C9:E3:86:37:AF:41:88:E3:08:47:F0:C1:C4:76
-connection.mdns:                        -1 (default) +                90:FE:47:81:36:3C:CE:BD:C9:44:30:99:B8:44:3E:F6:85:B3:44:9A
-connection.llmnr                      -1 (default) +                D9:76:64:92:3A:49:5A:67:91:35:B1:C7:E0:82:AF:8F:05:2C:CB:18
-connection.wait-device-timeout:         -1 +                50:F1:4F:4E:B0:C3:D4:AE:37:9F:1B:FF:E9:AC:4C:7B:23:65:DA:0E
-------------------------------------------------------------------------------- +                FE:98:1B:5A:D3:AB:6B:6A:EA:3C:7B:EC:54:84:CB:DB:EE:CD:F1:43
-802-3-ethernet.port                   -- +                40:F0:A3:DB:9B:0A:F2:0A:1F:59:5C:88:3C:3C:CB:CF:3D:60:54:50
-802-3-ethernet.speed                  0 +                60:CC:C1:41:6A:C6:8B:7E:23:F6:D8:1B:5F:A1:73:98:D4:F8:1E:C7
-802-3-ethernet.duplex                 -- +                D0:F5:F0:DF:E7:2A:79:A1:E6:A1:EE:B4:69:4C:15:DC:A8:A1:40:54
-802-3-ethernet.auto-negotiate         no +                EC:9D:86:AF:B2:1D:DB:33:F8:63:5D:CD:58:12:F9:C2:FB:B6:19:EE
-802-3-ethernet.mac-address            -- +                7F:CC:6E:6E 
-802-3-ethernet.cloned-mac-address     -- +parm          tdp_mmu:bool 
-802-3-ethernet.generate-mac-address-mask:-- +parm          nx_huge_pages:bool 
-802-3-ethernet.mac-address-blacklist:   -- +parm:           nx_huge_pages_recovery_ratio:uint 
-802-3-ethernet.mtu                    auto +parm          flush_on_reuse:bool 
-802-3-ethernet.s390-subchannels       -- +parm          ignore_msrs:bool 
-802-3-ethernet.s390-nettype           -- +parm:           report_ignored_msrs:bool 
-802-3-ethernet.s390-options           -- +parm:           min_timer_period_us:uint 
-802-3-ethernet.wake-on-lan            default +parm          kvmclock_periodic_sync:bool 
-802-3-ethernet.wake-on-lan-password   -- +parm          tsc_tolerance_ppm:uint 
-------------------------------------------------------------------------------- +parm          lapic_timer_advance_ns:int 
-ipv4.method                           manual +parm          vector_hashing:bool 
-ipv4.dns                              -- +parm          enable_vmware_backdoor:bool 
-ipv4.dns-search                       -- +parm          force_emulation_prefix:bool 
-ipv4.dns-options                      -- +parm          pi_inject_timer:bint 
-ipv4.dns-priority                     0 +parm          halt_poll_ns:uint 
-ipv4.addresses                        10.0.2.46/24 +parm          halt_poll_ns_grow:uint 
-ipv4.gateway                          10.0.2.1 +parm          halt_poll_ns_grow_start:uint 
-ipv4.routes                           -- +parm          halt_poll_ns_shrink:uint
-ipv4.route-metric                     -1 +
-ipv4.route-table                      0 (unspec) +
-ipv4.routing-rules                    -- +
-ipv4.ignore-auto-routes               no +
-ipv4.ignore-auto-dns                  no +
-ipv4.dhcp-client-id                   -- +
-ipv4.dhcp-iaid                        -- +
-ipv4.dhcp-timeout                     0 (default) +
-ipv4.dhcp-send-hostname:                yes +
-ipv4.dhcp-hostname                    -- +
-ipv4.dhcp-fqdn                        -- +
-ipv4.dhcp-hostname-flags              0x0 (none) +
-ipv4.never-default                    no +
-ipv4.may-fail                         yes +
-ipv4.dad-timeout                      -1 (default) +
-ipv4.dhcp-vendor-class-identifier     -- +
-ipv4.dhcp-reject-servers              -- +
-------------------------------------------------------------------------------- +
-ipv6.method                           auto +
-ipv6.dns                              -- +
-ipv6.dns-search                       -- +
-ipv6.dns-options                      -- +
-ipv6.dns-priority                     0 +
-ipv6.addresses                        -- +
-ipv6.gateway                          -- +
-ipv6.routes                           -- +
-ipv6.route-metric                     -1 +
-ipv6.route-table                      0 (unspec) +
-ipv6.routing-rules                    -- +
-ipv6.ignore-auto-routes:                no +
-ipv6.ignore-auto-dns                  no +
-ipv6.never-default                    no +
-ipv6.may-fail                         yes +
-ipv6.ip6-privacy                      -1 (unknown) +
-ipv6.addr-gen-mode                    stable-privacy +
-ipv6.ra-timeout                       0 (default) +
-ipv6.dhcp-duid                        -- +
-ipv6.dhcp-iaid                        -- +
-ipv6.dhcp-timeout                     0 (default) +
-ipv6.dhcp-send-hostname               yes +
-ipv6.dhcp-hostname                    -- +
-ipv6.dhcp-hostname-flags              0x0 (none) +
-ipv6.token                            -- +
-------------------------------------------------------------------------------- +
-proxy.method                          none +
-proxy.browser-only                    no +
-proxy.pac-url                         -- +
-proxy.pac-script                      -- +
-------------------------------------------------------------------------------- +
-=============================================================================== +
-      Activate connection details (0f48c74d-5d16-4c37-8220-24644507b589) +
-=============================================================================== +
-GENERAL.NAME                          ip_fixe +
-GENERAL.UUID                          0f48c74d-5d16-4c37-8220-24644507b589 +
-GENERAL.DEVICES                       ens18 +
-GENERAL.IP-IFACE                      ens18 +
-GENERAL.STATE                         activated +
-GENERAL.DEFAULT                       yes +
-GENERAL.DEFAULT6                      no +
-GENERAL.SPEC-OBJECT                   -- +
-GENERAL.VPN                           no +
-GENERAL.DBUS-PATH                     /org/freedesktop/NetworkManager/ActiveConnection/4 +
-GENERAL.CON-PATH                      /org/freedesktop/NetworkManager/Settings/4 +
-GENERAL.ZONE                          -- +
-GENERAL.MASTER-PATH                   -- +
-------------------------------------------------------------------------------- +
-IP4.ADDRESS[1]                        10.0.2.46/24 +
-IP4.GATEWAY                           10.0.2.1 +
-IP4.ROUTE[1]                          dst = 10.0.2.0/24, nh = 0.0.0.0, mt = 100 +
-IP4.ROUTE[2]                          dst = 0.0.0.0/0, nh = 10.0.2.1, mt = 100 +
-------------------------------------------------------------------------------- +
-IP6.ADDRESS[1]                        fe80::5223:aee1:998e:9f27/64 +
-IP6.GATEWAY                           -- +
-IP6.ROUTE[1]                          dst = fe80::/64, nh = ::, mt = 100 +
-IP6.ROUTE[2]                          dst = ff00::/8, nh = ::, mt = 256, table=255 +
-------------------------------------------------------------------------------- +
-lines 83-127/127 (END) +
-[q]+
 </code> </code>
- 
-Pour consulter la liste profils associés à un périphérique, utilisez la commande suivante : 
  
 <code> <code>
-[root@centos8 ~]# nmcli -f CONNECTIONS device show ens18 +[root@centos8 ~]# modinfo kvm_intel 
-CONNECTIONS.AVAILABLE-CONNECTION-PATHS: /org/freedesktop/NetworkManager/Settings/1,/org/freedesktop/NetworkManager/Settings/4 +filename      /lib/modules/4.18.0-305.7.1.el8.i2tch.x86_64/kernel/arch/x86/kvm/kvm-intel.ko.xz 
-CONNECTIONS.AVAILABLE-CONNECTIONS[1]  fc4a4d23-b15e-47a7-bcfa-b2e08f49553e | ens18 +license:        GPL 
-CONNECTIONS.AVAILABLE-CONNECTIONS[2]:   0f48c74d-5d16-4c37-8220-24644507b589 | ip_fixe+author:         Qumranet 
 +rhelversion:    8.
 +srcversion:     E25F50CB67CEEDD925DE618 
 +alias:          cpu:type:x86,ven*fam*mod*:feature:*0085* 
 +depends:        kvm 
 +intree:         Y 
 +name:           kvm_intel 
 +vermagic:       4.18.0-305.7.1.el8.i2tch.x86_64 SMP mod_unload modversions  
 +sig_id        PKCS#7 
 +signer:         CentOS kernel signing key 
 +sig_key:        38:77:B1:DF:46:4F:B7:5C:99:8B:B9:BF:70:A4:10:85:91:7F:50:C1 
 +sig_hashalgo:   sha256 
 +signature:      7A:B3:78:ED:6D:A0:85:21:C0:5B:21:FC:7D:54:A1:04:99:38:11:3B: 
 +                11:A3:D6:05:DF:C2:DE:46:CE:CB:86:DD:1D:0E:7F:D5:6B:44:BC:DA: 
 +                91:EC:0C:D8:F1:BA:60:BF:B1:D5:3A:DE:A7:DA:9B:F0:16:FD:B1:37: 
 +                BB:DC:28:39:0D:99:92:45:1D:9B:19:42:9D:F7:9F:79:BB:31:86:8C: 
 +                E4:00:18:B8:40:85:96:D2:F3:91:11:9A:8A:CD:90:1F:2A:A6:99:3A: 
 +                2B:B1:D7:A5:52:D5:DA:5A:C9:57:23:42:7B:36:91:F1:CD:21:DC:87: 
 +                56:53:C9:2F:23:9E:E3:F2:C7:17:46:90:F0:A5:46:C4:C7:46:8A:09: 
 +                3B:17:34:8F:EB:C8:42:1C:06:E8:21:AB:D5:BA:66:3E:71:9C:0E:A1: 
 +                6C:51:7B:19:DF:02:F5:39:8A:8D:09:87:8E:F0:61:04:5E:A7:01:76: 
 +                51:E6:7A:C7:56:D5:AF:29:02:C1:0D:13:28:C1:5C:01:D9:13:44:3C: 
 +                D0:B9:58:0C:46:AF:ED:9E:BE:C2:70:48:35:5F:DE:77:F4:29:16:FA: 
 +                25:E2:FC:93:A4:8A:CC:69:DC:C1:11:0B:3A:24:D0:81:A2:2A:B8:E7: 
 +                97:4F:EB:EF:AB:75:85:63:4D:DA:C9:45:D1:AE:86:A3:B2:66:97:48: 
 +                7D:4D:2A:59:B6:AC:F7:CF:14:2A:5B:9D:40:5A:AF:DC:62:A7:EC:55: 
 +                AC:4D:5F:E6:C1:EA:51:2B:EF:59:30:67:91:39:C1:E9:9D:A9:70:30: 
 +                2E:25:37:A3:F2:3E:5A:5B:98:A6:EA:75:E7:AE:42:31:62:C1:A5:6A: 
 +                8D:CA:7F:28:A3:52:C4:65:6F:6D:BA:D1:BA:47:1A:AC:25:E0:CB:58: 
 +                D7:27:D2:85:88:45:3D:4A:AB:39:5E:FE:42:22:43:79:B4:AC:7C:39: 
 +                A3:5E:8B:8E:81:6B:18:DB:4F:F3:A4:D8:72:6D:97:9B:85:D2:18:35: 
 +                E6:C7:D9:84 
 +parm:           enable_shadow_vmcs:bool 
 +parm:           nested_early_check:bool 
 +parm:           vpid:bool 
 +parm:           vnmi:bool 
 +parm:           flexpriority:bool 
 +parm:           ept:bool 
 +parm:           unrestricted_guest:bool 
 +parm:           eptad:bool 
 +parm:           emulate_invalid_guest_state:bool 
 +parm:           fasteoi:bool 
 +parm:           enable_apicv:bool 
 +parm:           nested:bint 
 +parm:           pml:bool 
 +parm:           dump_invalid_vmcs:bool 
 +parm:           preemption_timer:bool 
 +parm:           allow_smaller_maxphyaddr:bool 
 +parm:           ple_gap:uint 
 +parm:           ple_window:uint 
 +parm:           ple_window_grow:uint 
 +parm:           ple_window_shrink:uint 
 +parm:           ple_window_max:uint 
 +parm:           pt_mode:int 
 +parm:           enlightened_vmcs:bool
 </code> </code>
  
-Les fichiers de configuration pour le periphérique **ens18** se trouvent dans le répertoire **/etc/sysconfig/network-scripts/** :+=====LAB #2 - Configuration de KVM====== 
 + 
 +====2.1 - Configuration du Pare-feu==== 
 + 
 +Si vous souhaitez vous connecter aux machines virtuelles créées sous KVM en utilisant le protocole VNC, vous devez ouvrir le port **5900/tcp** dans le système hôte :
  
 <code> <code>
-[root@centos8 ~]# ls -l /etc/sysconfig/network-scripts/ | grep ifcfg +[root@centos8 ~]# firewall-cmd --permanent --add-port=5901/tcp 
--rw-r--r--. 1 root root 417 Jun 16 06:39 ifcfg-ens18 +success 
--rw-r--r--. 1 root root 326 Aug 29 03:58 ifcfg-ip_fixe+ 
 +[root@centos8 ~]# firewall-cmd --reload 
 +success
 </code> </code>
  
-====1.2 - Résolution des Noms====+====2.2 - Configuration du Réseau des VMs====
  
-L'étude du fichier **/etc/sysconfig/network-scripts/ifcfg-ip_fixe** démontre l'abscence de directives concernant les DNS :+Lors de l'installation de KVM un pont a été créé ayant le nom **virbr0** et l'adresse IP **192.168.122.1/24** : 
 + 
 +  * La plage des adresses IP disponible pour les machines virtuelles KVM va de **192.168.122.2/24** à **192.168.122.254/24**,  
 +  * Ce pont met en place une connectivité de type **NAT** pour les machines virtuelles,  
 +  * Une interface réseau fictive, **virbr0-nic** et appelée une esclave, a été ajoutée à ce pont principalement pour fournir une adresse MAC stable,  
 +  * Normalement au fur et au mesure que d'autres VMs soient créées, d'autres interfaces fictives seraient ajoutées, une par VM. 
 +   
 +Les configurations ci-dessus peuvent être visualisées grâce à la commande **ip a ** :
  
 <code> <code>
-[root@centos8 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ip_fixe +[root@centos8 ~]# ip a 
-TYPE=Ethernet +... 
-PROXY_METHOD=none +4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 
-BROWSER_ONLY=no +    link/ether 52:54:00:79:02:66 brd ff:ff:ff:ff:ff:ff 
-BOOTPROTO=none +    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 
-IPADDR=10.0.2.46 +       valid_lft forever preferred_lft forever 
-PREFIX=24 +5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000 
-GATEWAY=10.0.2.+    link/ether 52:54:00:79:02:66 brd ff:ff:ff:ff:ff:ff
-DEFROUTE=yes +
-IPV4_FAILURE_FATAL=no +
-IPV6INIT=yes +
-IPV6_AUTOCONF=yes +
-IPV6_DEFROUTE=yes +
-IPV6_FAILURE_FATAL=no +
-IPV6_ADDR_GEN_MODE=stable-privacy +
-NAME=ip_fixe +
-UUID=0f48c74d-5d16-4c37-8220-24644507b589 +
-DEVICE=ens18 +
-ONBOOT=yes+
 </code> </code>
 +  
 +Dans le cas où on ne souhaite pas ou on ne peut pas utiliser le pont créé par défaut, il convient de créer un autre pont. Dans notre cas, l'hôte KVM possède deux interfaces **ens18** et **ens19**. Nous allons donc dédier l'interface **ens19** au trafic réseau des machines virtuelles. Actuellement cette interface ne possède pas d'adresse IP : 
  
-La résolution des noms est donc inactive :+<code> 
 +[root@centos8 ~]# ip a show ens19 
 +3: ens19: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 
 +    link/ether 46:de:37:c0:55:6c brd ff:ff:ff:ff:ff:ff 
 +</code> 
 + 
 +Elle n'est pas visible dans la sortie de la commande **nmcli c show** : 
 +   
 +<code>   
 +[root@centos8 ~]# nmcli c show 
 +NAME     UUID                                  TYPE      DEVICE  
 +ip_fixe  0f48c74d-5d16-4c37-8220-24644507b589  ethernet  ens18   
 +virbr0   d330b8f4-d08b-4b15-93cc-45c61e26ca6a  bridge    virbr0  
 +ens18    fc4a4d23-b15e-47a7-bcfa-b2e08f49553e  ethernet  --   
 +</code>   
 + 
 +Créez donc une adresse IP de 192.168.56.2/24 pour l'interface **ens19** :
  
 <code> <code>
-[root@centos8 ~]# ping www.free.fr +[root@centos8 ~]# nmcli connection add con-name ip_kvm ifname ens19 type ethernet ip4 192.168.56.2/24 gw4 192.168.56.1 
-ping: www.free.fr: Name or service not known+Connection 'ip_kvm' (afc8b175-f2cb-47b2-baca-66454058c36f) successfully added. 
 +[root@centos8 ~]# nmcli c show 
 +NAME     UUID                                  TYPE      DEVICE  
 +ip_fixe  0f48c74d-5d16-4c37-8220-24644507b589  ethernet  ens18   
 +ip_kvm   afc8b175-f2cb-47b2-baca-66454058c36f  ethernet  ens19   
 +virbr0   d330b8f4-d08b-4b15-93cc-45c61e26ca6a  bridge    virbr0  
 +ens18    fc4a4d23-b15e-47a7-bcfa-b2e08f49553e  ethernet  -- 
 </code> </code>
  
-Modifiez donc la configuration du profil **ip_fixe** :+Utilisez la commande **ip** pour vérifier la prise en compte de la configuration :
  
 <code> <code>
-[root@centos8 ~]# nmcli connection mod ip_fixe ipv4.dns 8.8.8.8+[root@centos8 ~]# ip a show ens19 
 +3: ens19: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 
 +    link/ether 46:de:37:c0:55:6c brd ff:ff:ff:ff:ff:ff 
 +    inet 192.168.56.2/24 brd 192.168.56.255 scope global noprefixroute ens19 
 +       valid_lft forever preferred_lft forever 
 +    inet6 fe80::4b01:d543:147:dd6d/64 scope link noprefixroute  
 +       valid_lft forever preferred_lft forever
 </code> </code>
  
-L'étude du fichier **/etc/sysconfig/network-scripts/ifcfg-ip_fixe** démontre que la directive concernant le serveur DNS a été ajoutée :+Notez que cette configuration a été stockée dans le fichier **/etc/sysconfig/network-scripts/ifcfg-ip_kvm** :
  
 <code> <code>
-[root@centos8 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ip_fixe+[root@centos8 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ip_kvm 
 TYPE=Ethernet TYPE=Ethernet
 PROXY_METHOD=none PROXY_METHOD=none
 BROWSER_ONLY=no BROWSER_ONLY=no
 BOOTPROTO=none BOOTPROTO=none
-IPADDR=10.0.2.46+IPADDR=192.168.56.2
 PREFIX=24 PREFIX=24
-GATEWAY=10.0.2.1+GATEWAY=192.168.56.1
 DEFROUTE=yes DEFROUTE=yes
 IPV4_FAILURE_FATAL=no IPV4_FAILURE_FATAL=no
Ligne 606: Ligne 397:
 IPV6_FAILURE_FATAL=no IPV6_FAILURE_FATAL=no
 IPV6_ADDR_GEN_MODE=stable-privacy IPV6_ADDR_GEN_MODE=stable-privacy
-NAME=ip_fixe +NAME=ip_kvm 
-UUID=0f48c74d-5d16-4c37-8220-24644507b589 +UUID=afc8b175-f2cb-47b2-baca-66454058c36f 
-DEVICE=ens18+DEVICE=ens19
 ONBOOT=yes ONBOOT=yes
-DNS1=8.8.8.8 
 </code> </code>
  
-Afin que la modification du serveur DNS soit prise en compte, re-démarrez le service NetworkManager :+Vérifiez maintenant que vous pouvez communiquer avec la passerelle par défaut **192.168.56.1/24** :
  
 <code> <code>
-root@centos8 ~]# systemctl restart NetworkManager.service +[root@centos8 ~]# ping 192.168.56.1 
-[root@centos8 ~]# systemctl status NetworkManager.service +PING 192.168.56.1 (192.168.56.1) 56(84bytes of data. 
-● NetworkManager.service - Network Manager +64 bytes from 192.168.56.1icmp_seq=1 ttl=64 time=14.6 ms 
-   Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled) +64 bytes from 192.168.56.1icmp_seq=2 ttl=64 time=0.209 ms 
-   Active: active (running) since Sun 2021-08-29 04:15:11 EDT; 8s ago +64 bytes from 192.168.56.1icmp_seq=3 ttl=64 time=0.160 ms 
-     Docs: man:NetworkManager(8) +^C 
- Main PID: 973390 (NetworkManager) +--- 192.168.56.1 ping statistics --
-    Tasks: 4 (limit: 23535) +3 packets transmitted3 received, 0% packet loss, time 2002ms 
-   Memory: 4.6M +rtt min/avg/max/mdev = 0.160/4.990/14.601/6.796 ms
-   CGroup: /system.slice/NetworkManager.service +
-           └─973390 /usr/sbin/NetworkManager --no-daemon +
- +
-Aug 29 04:15:12 centos8.ittraining.loc NetworkManager[973390]: <info>  [1630224912.2235] device (ens18): state change: ip-check -> secondaries (reas> +
-Aug 29 04:15:12 centos8.ittraining.loc NetworkManager[973390]<info>  [1630224912.2237] device (virbr0): state change: secondaries -> activated (re> +
-Aug 29 04:15:12 centos8.ittraining.loc NetworkManager[973390]: <info>  [1630224912.2241] managerNetworkManager state is now CONNECTED_LOCAL +
-Aug 29 04:15:12 centos8.ittraining.loc NetworkManager[973390]: <info>  [1630224912.2251] policy: set 'ip_fixe' (ens18) as default for IPv4 routing a> +
-Aug 29 04:15:12 centos8.ittraining.loc NetworkManager[973390]: <info>  [1630224912.3090] device (virbr0)Activation: successful, device activated+
-Aug 29 04:15:12 centos8.ittraining.loc NetworkManager[973390]: <info>  [1630224912.3098] device (ens18): state change: secondaries -> activated (rea> +
-Aug 29 04:15:12 centos8.ittraining.loc NetworkManager[973390]: <info>  [1630224912.3102] manager: NetworkManager state is now CONNECTED_SITE +
-Aug 29 04:15:12 centos8.ittraining.loc NetworkManager[973390]: <info>  [1630224912.3111] device (ens18): Activation: successfuldevice activated. +
-Aug 29 04:15:12 centos8.ittraining.loc NetworkManager[973390]: <info>  [1630224912.3116] manager: NetworkManager state is now CONNECTED_GLOBAL +
-Aug 29 04:15:12 centos8.ittraining.loc NetworkManager[973390]: <info>  [1630224912.3121] manager: startup complete +
-lines 1-20/20 (END) +
-[q]+
 </code> </code>
  
-Vérifiez que le fichier **/etc/resolv.conf** ait été modifié par NetworkManager :+Pour pouvoir gérer l'esclave par le pont qui va être créé, il faut modifier le fichier  **/etc/sysconfig/network-scripts/ifcfg-ip_kvm** :
  
 <code> <code>
-[root@centos8 ~]# cat /etc/resolv.conf +[root@centos8 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ip_kvm  
-Generated by NetworkManager +[root@centos8 ~]cat /etc/sysconfig/network-scripts/ifcfg-ip_kvm  
-search ittraining.loc +TYPE=Ethernet 
-nameserver 8.8.8.8+BOOTPROTO=none 
 +NAME=ip_kvm 
 +UUID=afc8b175-f2cb-47b2-baca-66454058c36f 
 +DEVICE=ens19 
 +ONBOOT=yes 
 +BRIDGE=virbr0
 </code> </code>
  
-Dernièrement vérifiez la resolution des noms :+Pour créer le pont, il convient de créer le fichier **/etc/sysconfig/network-scripts/ifcfg-virbr0** :
  
 <code> <code>
-[root@centos8 ~]# ping www.free.fr +[root@centos8 ~]# ls -l /etc/sysconfig/network-scripts/ifcfg-virbr0 
-PING www.free.fr (212.27.48.10) 56(84) bytes of data. +ls: cannot access '/etc/sysconfig/network-scripts/ifcfg-virbr0': No such file or directory 
-64 bytes from www.free.fr (212.27.48.10): icmp_seq=1 ttl=47 time=29.3 ms + 
-64 bytes from www.free.fr (212.27.48.10): icmp_seq=2 ttl=47 time=29.4 ms +[root@centos8 ~]# vi /etc/sysconfig/network-scripts/ifcfg-virbr0 
-64 bytes from www.free.fr (212.27.48.10): icmp_seq=3 ttl=47 time=29.4 ms +[root@centos8 ~]# cat /etc/sysconfig/network-scripts/ifcfg-virbr0 
-64 bytes from www.free.fr (212.27.48.10): icmp_seq=4 ttl=47 time=29.4 ms +TYPE=BRIDGE 
-^C +DEVICE=virbr0 
---- www.free.fr ping statistics --- +BOOTPROTO=non 
-4 packets transmitted, 4 received, 0% packet loss, time 3005ms +ONBOOT=yes 
-rtt min/avg/max/mdev 29.266/29.377/29.428/0.183 ms+IPADDR=192.168.56.2 
 +NETMASK=255.255.255.0 
 +GATEWAY=192.168.56.1
 </code> </code>
  
-<WRAP center round important> +<WRAP center round important 60%
-**Important** : Notez qu'il existe un front-end graphique en mode texte, **nmtui**pour configurer NetworkManager.+**Important** : Notez que le nom du pont est identique au pont existant. Ceci n'a pas d'importance. Notez aussi que l'adresse IPle masque du réseau ainsi que la passerelle sont configurés dans le fichier décrivant le pont.
 </WRAP> </WRAP>
  
-====1.3 - Ajouter une Deuxième Adresse IP à un Profil==== +Pour que la configuration puisse fonctionner, il est necéssaire d'activer le routage entre les interfaces dans l'hôte KVM :
- +
-Pour ajouter une deuxième adresse IP à un profil sous RHEL/CentOS 8, il convient d'utiliser la commande suivante :+
  
 <code> <code>
-[root@centos8 ~]# nmcli connection mod ip_fixe +ipv4.addresses 192.168.1.2/24+[root@centos8 ~]# echo net.ipv4.ip_forward = 1 >> /usr/lib/sysctl.d/60-libvirtd.conf  
 +[root@centos8 ~]# cat /usr/lib/sysctl.d/60-libvirtd.conf  
 +# The kernel allocates aio memory on demand, and this number limits the 
 +# number of parallel aio requests; the only drawback of a larger limit is 
 +# that a malicious guest could issue parallel requests to cause the kernel 
 +# to set aside memory.  Set this number at least as large as 
 +#   128 * (number of virtual disks on the host) 
 +# Libvirt uses a default of 1M requests to allow 8k disks, with at most 
 +# 64M of kernel memory if all disks hit an aio request at the same time. 
 +fs.aio-max-nr = 1048576 
 +net.ipv4.ip_forward = 1
 </code> </code>
  
-Rechargez la configuration du profil :+En utilisant la commande **sysctl**, appliquez la nouvelle configuration :
  
 <code> <code>
-[root@centos8 ~]# nmcli con up ip_fixe+[root@centos8 ~]# /sbin/sysctl -p /usr/lib/sysctl.d/60-libvirtd.conf  
 +fs.aio-max-nr = 1048576 
 +net.ipv4.ip_forward = 1
 </code> </code>
  
-Saisissez ensuite la commande suivante :+Dernièrement, il est important de configurer le pare-feu pour le pont :
  
 <code> <code>
-[root@centos8 ~]# nmcli connection show ip_fixe +[root@centos8 ~]# firewall-cmd --permanent --direct --passthrough ipv4 -I FORWARD -o virbr0 -j ACCEPT 
-connection.id:                          ip_fixe +success 
-connection.uuid:                        0f48c74d-5d16-4c37-8220-24644507b589 +[root@centos8 ~]# firewall-cmd --permanent --direct --passthrough ipv4 -I FORWARD -i virbr0 -j ACCEPT 
-connection.stable-id:                   -- +success
-connection.type:                        802-3-ethernet +
-connection.interface-name:              ens18 +
-connection.autoconnect:                 yes +
-connection.autoconnect-priority:        0 +
-connection.autoconnect-retries:         -1 (default) +
-connection.multi-connect:               0 (default) +
-connection.auth-retries:                -1 +
-connection.timestamp:                   1630225792 +
-connection.read-only:                   no +
-connection.permissions:                 -- +
-connection.zone:                        -- +
-connection.master:                      -- +
-connection.slave-type:                  -- +
-connection.autoconnect-slaves:          -1 (default) +
-connection.secondaries:                 -- +
-connection.gateway-ping-timeout:        0 +
-connection.metered:                     unknown +
-connection.lldp:                        default +
-connection.mdns:                        -1 (default) +
-connection.llmnr:                       -1 (default) +
-connection.wait-device-timeout:         -1 +
-802-3-ethernet.port:                    -- +
-802-3-ethernet.speed:                   0 +
-802-3-ethernet.duplex:                  -- +
-802-3-ethernet.auto-negotiate:          no +
-802-3-ethernet.mac-address:             -- +
-802-3-ethernet.cloned-mac-address:      -- +
-802-3-ethernet.generate-mac-address-mask:-- +
-802-3-ethernet.mac-address-blacklist:   -- +
-802-3-ethernet.mtu:                     auto +
-802-3-ethernet.s390-subchannels:        -- +
-802-3-ethernet.s390-nettype:            -- +
-802-3-ethernet.s390-options:            -- +
-802-3-ethernet.wake-on-lan:             default +
-802-3-ethernet.wake-on-lan-password:    -- +
-ipv4.method:                            manual +
-ipv4.dns:                               8.8.8.8 +
-ipv4.dns-search:                        -- +
-ipv4.dns-options:                       -- +
-ipv4.dns-priority:                      0 +
-ipv4.addresses:                         10.0.2.46/24, 192.168.1.2/24 +
-ipv4.gateway:                           10.0.2.1 +
-ipv4.routes:                            -- +
-ipv4.route-metric:                      -+
-ipv4.route-table:                       0 (unspec) +
-ipv4.routing-rules:                     -- +
-ipv4.ignore-auto-routes:                no +
-ipv4.ignore-auto-dns:                   no +
-ipv4.dhcp-client-id:                    -- +
-ipv4.dhcp-iaid:                         -- +
-ipv4.dhcp-timeout:                      0 (default) +
-ipv4.dhcp-send-hostname:                yes +
-ipv4.dhcp-hostname:                     -- +
-ipv4.dhcp-fqdn:                         -- +
-ipv4.dhcp-hostname-flags:               0x0 (none) +
-ipv4.never-default:                     no +
-ipv4.may-fail:                          yes +
-ipv4.dad-timeout:                       -1 (default) +
-ipv4.dhcp-vendor-class-identifier:      -- +
-ipv4.dhcp-reject-servers:               -- +
-ipv6.method:                            auto +
-ipv6.dns:                               -- +
-ipv6.dns-search:                        -- +
-ipv6.dns-options:                       -- +
-ipv6.dns-priority:                      0 +
-ipv6.addresses:                         -- +
-ipv6.gateway:                           -- +
-ipv6.routes:                            -- +
-ipv6.route-metric:                      -1 +
-ipv6.route-table:                       0 (unspec) +
-ipv6.routing-rules:                     -- +
-ipv6.ignore-auto-routes:                no +
-ipv6.ignore-auto-dns:                   no +
-ipv6.never-default:                     no +
-ipv6.may-fail:                          yes +
-ipv6.ip6-privacy:                       -1 (unknown) +
-ipv6.addr-gen-mode:                     stable-privacy +
-ipv6.ra-timeout:                        0 (default) +
-ipv6.dhcp-duid:                         -- +
-ipv6.dhcp-iaid:                         -- +
-ipv6.dhcp-timeout:                      0 (default) +
-ipv6.dhcp-send-hostname:                yes +
-ipv6.dhcp-hostname:                     -- +
-ipv6.dhcp-hostname-flags:               0x0 (none) +
-ipv6.token:                             -- +
-proxy.method:                           none +
-proxy.browser-only:                     no +
-proxy.pac-url:                          -- +
-proxy.pac-script:                       -- +
-GENERAL.NAME:                           ip_fixe +
-GENERAL.UUID:                           0f48c74d-5d16-4c37-8220-24644507b589 +
-GENERAL.DEVICES:                        ens18 +
-GENERAL.IP-IFACE:                       ens18 +
-GENERAL.STATE:                          activated +
-GENERAL.DEFAULT:                        yes +
-GENERAL.DEFAULT6:                       no +
-GENERAL.SPEC-OBJECT:                    -- +
-GENERAL.VPN:                            no +
-GENERAL.DBUS-PATH:                      /org/freedesktop/NetworkManager/ActiveConnection/+
-GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/Settings/+
-GENERAL.ZONE:                           -- +
-GENERAL.MASTER-PATH:                    -- +
-IP4.ADDRESS[1]:                         10.0.2.46/24 +
-IP4.ADDRESS[2]:                         192.168.1.2/24 +
-IP4.GATEWAY:                            10.0.2.1 +
-IP4.ROUTE[1]:                           dst = 10.0.2.0/24, nh = 0.0.0.0, mt = 100 +
-IP4.ROUTE[2]:                           dst = 192.168.1.0/24, nh = 0.0.0.0, mt = 100 +
-IP4.ROUTE[3]:                           dst = 0.0.0.0/0, nh = 10.0.2.1, mt = 100 +
-IP4.DNS[1]:                             8.8.8.8 +
-IP6.ADDRESS[1]:                         fe80::5223:aee1:998e:9f27/64 +
-IP6.GATEWAY:                            -- +
-IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 100 +
-IP6.ROUTE[2]:                           dst = ff00::/8, nh = ::, mt = 256, table=255 +
-lines 72-116/116 (END) +
-[q]+
 </code> </code>
- 
-<WRAP center round important> 
-**Important** : Notez l'ajout de l'adresse secondaire à la ligne **ipv4.addresses: ** ainsi que l'ajout de la ligne **IP4.ADDRESS[2]:**. 
-</WRAP> 
- 
-Consultez maintenant le contenu du fichier **/etc/sysconfig/network-scripts/ifcfg-ip_fixe** : 
  
 <code> <code>
-[root@centos8 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ip_fixe +[root@centos8 ~]# firewall-cmd --reload 
-TYPE=Ethernet +success
-PROXY_METHOD=none +
-BROWSER_ONLY=no +
-BOOTPROTO=none +
-IPADDR=10.0.2.46 +
-PREFIX=24 +
-GATEWAY=10.0.2.1 +
-DEFROUTE=yes +
-IPV4_FAILURE_FATAL=no +
-IPV6INIT=yes +
-IPV6_AUTOCONF=yes +
-IPV6_DEFROUTE=yes +
-IPV6_FAILURE_FATAL=no +
-IPV6_ADDR_GEN_MODE=stable-privacy +
-NAME=ip_fixe +
-UUID=0f48c74d-5d16-4c37-8220-24644507b589 +
-DEVICE=ens18 +
-ONBOOT=yes +
-DNS1=8.8.8.8 +
-IPADDR1=192.168.1.2 +
-PREFIX1=24+
 </code> </code>
  
-<WRAP center round important> +La configuration faite, vérifiez la prise en charge en utilisant la commande **ip** :
-**Important** : Notez l'ajout de la ligne **IPADDR1=192.168.1.2**. +
-</WRAP> +
- +
-====1.4 - La Commande hostname==== +
- +
-La procédure de la modification du hostname est simplifiée et sa prise en compte est immédiate : +
- +
-<code> +
-[root@centos8 ~]# hostname +
-centos8.ittraining.loc +
- +
-[root@centos8 ~]# nmcli general hostname centos.ittraining.loc +
- +
-[root@centos8 ~]# cat /etc/hostname +
-centos.ittraining.loc +
- +
-[root@centos8 ~]# hostname +
-centos.ittraining.loc +
- +
-[root@centos8 ~]# nmcli general hostname centos8.ittraining.loc +
- +
-[root@centos8 ~]# cat /etc/hostname +
-centos8.ittraining.loc +
- +
-[root@centos8 ~]# hostname +
-centos8.ittraining.loc +
-</code> +
- +
-====1.5 - La Commande ip==== +
- +
-Sous RHEL/CentOS 8 la commande **ip** est préférée par rapport à la commande ifconfig :+
  
 <code> <code>
-[root@centos8 ~]# ip address+[root@centos8 ~]# ip a
 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 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     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
Ligne 888: Ligne 508:
     inet6 fe80::5223:aee1:998e:9f27/64 scope link noprefixroute      inet6 fe80::5223:aee1:998e:9f27/64 scope link noprefixroute 
        valid_lft forever preferred_lft forever        valid_lft forever preferred_lft forever
-3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000+3: ens19: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 
 +    link/ether 46:de:37:c0:55:6c brd ff:ff:ff:ff:ff:ff 
 +    inet 192.168.56.2/24 brd 192.168.56.255 scope global noprefixroute ens19 
 +       valid_lft forever preferred_lft forever 
 +    inet6 fe80::4b01:d543:147:dd6d/64 scope link noprefixroute  
 +       valid_lft forever preferred_lft forever 
 +4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
     link/ether 52:54:00:79:02:66 brd ff:ff:ff:ff:ff:ff     link/ether 52:54:00:79:02:66 brd ff:ff:ff:ff:ff:ff
     inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0     inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
        valid_lft forever preferred_lft forever        valid_lft forever preferred_lft forever
-4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000+5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
     link/ether 52:54:00:79:02:66 brd ff:ff:ff:ff:ff:ff     link/ether 52:54:00:79:02:66 brd ff:ff:ff:ff:ff:ff
 </code> </code>
  
-===Options de la Commande ip=== +<WRAP center round important 60%
- +**Important** : Notez que la configuration n'as **pas** été prise en compte. En effet, l'adresse IP de **virbr0** est toujours **192.168.122.1**.
-Les options de cette commande sont : +
- +
-<code> +
-[root@centos8 ~]# ip --help +
-Usage: ip [ OPTIONS ] OBJECT { COMMAND | help } +
-       ip [ -force ] -batch filename +
-where  OBJECT := { link | address | addrlabel | route | rule | neigh | ntable | +
-                   tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm | +
-                   netns | l2tp | fou | macsec | tcp_metrics | token | netconf | ila | +
-                   vrf | sr | nexthop | mptcp } +
-       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] | +
-                    -h[uman-readable] | -iec | -j[son] | -p[retty] | +
-                    -f[amily] { inet | inet6 | mpls | bridge | link } | +
-                    -4 | -6 | -I | -D | -M | -B | -0 | +
-                    -l[oops] { maximum-addr-flush-attempts } | -br[ief] | +
-                    -o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] | +
-                    -rc[vbuf] [size] | -n[etns] name | -N[umeric] | -a[ll] | +
-                    -c[olor]} +
- +
-</code> +
- +
-====1.6 - Activer/Désactiver une Interface Manuellement==== +
- +
-Deux commandes existent pour désactiver et activer manuellement une interface réseau : +
- +
-<code> +
-# nmcli device disconnect enp0s3 +
-# nmcli device connect enp0s3 +
-</code> +
- +
-<WRAP center round important> +
-**Important** : Veuillez ne **PAS** exécuter ces deux commandes.+
 </WRAP> </WRAP>
  
-====1.7 - Routage Statique==== +Consultez maintenant la list des réseaux configurés pour KVM :
- +
-===La commande ip=== +
- +
-Sous RHEL/CentOS 8, pour supprimer la route vers le réseau 192.168.1.0 il convient d'utiliser la commande ip et non pas la commande route :+
  
 <code> <code>
-[root@centos8 ~]# ip route +[root@centos8 ~]# virsh net-list 
-default via 10.0.2.1 dev ens18 proto static metric 100  + Name      State    Autostart   Persistent 
-10.0.2.0/24 dev ens18 proto kernel scope link src 10.0.2.46 metric 100  +-------------------------------------------- 
-192.168.1.0/24 dev ens18 proto kernel scope link src 192.168.1.2 metric 100  + default   active   yes         yes
-192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown +
- +
-root@centos8 ~]# ip route del 192.168.1.0/24 via 0.0.0.0 +
-[root@centos8 ~]# ip route +
-default via 10.0.2.1 dev ens18 proto static metric 100  +
-10.0.2.0/24 dev ens18 proto kernel scope link src 10.0.2.46 metric 100  +
-192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown +
 </code> </code>
  
-Pour ajouter la route vers le réseau 192.168.1.0 :+En utilisant la commande **virsh net-dumpxml**, il est possible de constater la configuration **actuelle** du pont :
  
 <code> <code>
-[root@centos8 ~]# ip route add 192.168.1.0/24 via 10.0.2.1 +[root@centos8 ~]# virsh net-dumpxml default 
-[root@centos8 ~]# ip route +<network> 
-default via 10.0.2.1 dev ens18 proto static metric 100  +  <name>default</name> 
-10.0.2.0/24 dev ens18 proto kernel scope link src 10.0.2.46 metric 100  +  <uuid>0679ee40-befd-4f48-841e-7fc64885eb49</uuid> 
-192.168.1.0/24 via 10.0.2.1 dev ens18  +  <forward mode='nat'> 
-192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown +    <nat> 
 +      <port start='1024' end='65535'/> 
 +    </nat> 
 +  </forward> 
 +  <bridge name='virbr0' stp='on' delay='0'/
 +  <mac address='52:54:00:79:02:66'/> 
 +  <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>
 </code> </code>
  
-<WRAP center round important> +Il est donc nécessaire d'éditer cette configuration pour refléter les modifications déjà apportées en utilisant la commande **virsh net-edit** :
-**Important** - La commande utilisée pour ajouter une passerelle par défaut prend la forme suivante **ip route add default via //adresse ip//**+
-</WRAP> +
- +
-===Désactiver/Activer le routage sur le serveur=== +
- +
-Pour désactiver le routage sur le serveur, il convient de désactiver la retransmission des paquets:+
  
 <code> <code>
-[root@centos8 ~]# cat /proc/sys/net/ipv4/ip_forward +[root@centos8 ~]# virsh net-edit default
-+
-[root@centos8 ~]# echo 0 > /proc/sys/net/ipv4/ip_forward +
-[root@centos8 ~]# cat /proc/sys/net/ipv4/ip_forward +
-0+
 </code> </code>
  
-Pour activer le routage sur le serveur, il convient d'activer la retransmission des paquets: +l'issu de votre éditionvotre fichier doit correspondre à l'exemple suivant :
- +
-<code> +
-[root@centos8 ~]# echo 1 > /proc/sys/net/ipv4/ip_forward +
-[root@centos8 ~]# cat /proc/sys/net/ipv4/ip_forward +
-+
-</code> +
- +
-=====LAB #2 - Diagnostique du Réseau===== +
- +
-====2.1 - ping==== +
- +
-Pour tester l'accessibilité d'une machine, vous devez utiliser la commande **ping** : +
- +
-<code> +
-[root@centos8 ~]# ping -c4 10.0.2.1 +
-PING 10.0.2.1 (10.0.2.1) 56(84) bytes of data. +
-64 bytes from 10.0.2.1: icmp_seq=1 ttl=64 time=0.104 ms +
-64 bytes from 10.0.2.1: icmp_seq=2 ttl=64 time=0.325 ms +
-64 bytes from 10.0.2.1: icmp_seq=3 ttl=64 time=0.250 ms +
-64 bytes from 10.0.2.1: icmp_seq=4 ttl=64 time=0.123 ms +
- +
---- 10.0.2.1 ping statistics --- +
-4 packets transmitted, 4 received, 0% packet loss, time 3083ms +
-rtt min/avg/max/mdev = 0.104/0.200/0.325/0.092 ms +
-</code> +
- +
-===Options de la commande ping=== +
- +
-Les options de cette commande sont : +
- +
-<code> +
-[root@centos8 ~]# ping --help +
-ping: invalid option -- '-' +
-Usage: ping [-aAbBdDfhLnOqrRUvV64] [-c count] [-i interval] [-I interface] +
-            [-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos] +
-            [-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option] +
-            [-w deadline] [-W timeout] [hop1 ...] destination +
-Usage: ping -6 [-aAbBdDfhLnOqrRUvV] [-c count] [-i interval] [-I interface] +
-             [-l preload] [-m mark] [-M pmtudisc_option] +
-             [-N nodeinfo_option] [-p pattern] [-Q tclass] [-s packetsize] +
-             [-S sndbuf] [-t ttl] [-T timestamp_option] [-w deadline] +
-             [-W timeout] destination +
-</code> +
- +
-====2.2 - netstat -i==== +
- +
-Pour visualiser les statistiques réseauxvous disposez de la commande **netstat** : +
- +
-<code> +
-[root@centos8 ~]# netstat -i +
-Kernel Interface table +
-Iface             MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg +
-ens18            1500   476056      0      0 0        363562      0      0      0 BMRU +
-lo              65536    10936      0      0 0         10936      0      0      0 LRU +
-virbr0           1500        0      0      0 0                  0      0      0 BMU +
-</code> +
- +
-===Options de la commande netstat=== +
- +
-Les options de cette commande sont : +
- +
-<code> +
-[root@centos8 ~]# netstat --help +
-usage: netstat [-vWeenNcCF] [<Af>] -r         netstat {-V|--version|-h|--help} +
-       netstat [-vWnNcaeol] [<Socket> ...] +
-       netstat { [-vWeenNac] -I[<Iface>] | [-veenNac] -i | [-cnNe] -M | -s [-6tuw] } [delay] +
- +
-        -r, --route              display routing table +
-        -I, --interfaces=<Iface> display interface table for <Iface> +
-        -i, --interfaces         display interface table +
-        -g, --groups             display multicast group memberships +
-        -s, --statistics         display networking statistics (like SNMP) +
-        -M, --masquerade         display masqueraded connections +
- +
-        -v, --verbose            be verbose +
-        -W, --wide               don't truncate IP addresses +
-        -n, --numeric            don't resolve names +
-        --numeric-hosts          don't resolve host names +
-        --numeric-ports          don't resolve port names +
-        --numeric-users          don't resolve user names +
-        -N, --symbolic           resolve hardware names +
-        -e, --extend             display other/more information +
-        -p, --programs           display PID/Program name for sockets +
-        -o, --timers             display timers +
-        -c, --continuous         continuous listing +
- +
-        -l, --listening          display listening server sockets +
-        -a, --all                display all sockets (default: connected) +
-        -F, --fib                display Forwarding Information Base (default) +
-        -C, --cache              display routing cache instead of FIB +
-        -Z, --context            display SELinux security context for sockets +
- +
-  <Socket>={-t|--tcp} {-u|--udp} {-U|--udplite} {-S|--sctp} {-w|--raw} +
-           {-x|--unix} --ax25 --ipx --netrom +
-  <AF>=Use '-6|-4' or '-A <af>' or '--<af>'; default: inet +
-  List of possible address families (which support routing): +
-    inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25)  +
-    netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP)  +
-    x25 (CCITT X.25) +
-</code> +
- +
-====2.3 - traceroute==== +
- +
-La commande ping est à la base de la commande **traceroute**. Cette commande sert à découvrir la route empruntée pour accéder à un site donné : +
- +
-<code> +
-[root@centos8 ~]# traceroute www.ittraining.network +
-bash: traceroute: command not found... +
-Install package 'traceroute' to provide command 'traceroute'? [N/y] y +
- +
- +
- * Waiting in queue...  +
-The following packages have to be installed: +
- traceroute-3:2.1.0-6.el8.x86_64        Traces the route taken by packets over an IPv4/IPv6 network +
-Proceed with changes? [N/y] y +
- +
- +
- * Waiting in queue...  +
- * Waiting for authentication...  +
- * Waiting in queue...  +
- * Downloading packages...  +
- * Requesting data...  +
- * Testing changes...  +
- * Installing packages...  +
-traceroute to www.ittraining.network (109.228.56.52), 30 hops max, 60 byte packets +
-  _gateway (10.0.2.1)  0.132 ms  0.101 ms  0.078 ms +
-  79.137.68.252 (79.137.68.252)  0.542 ms  0.656 ms  0.809 ms +
-  10.50.24.61 (10.50.24.61)  0.238 ms  0.219 ms 10.50.24.60 (10.50.24.60)  0.239 ms +
-  10.50.0.16 (10.50.0.16)  0.172 ms 10.50.0.22 (10.50.0.22)  0.194 ms  0.173 ms +
-  10.73.248.192 (10.73.248.192)  0.766 ms 10.73.248.194 (10.73.248.194)  0.730 ms 10.73.248.192 (10.73.248.192)  0.757 ms +
-  waw-wa2-sbb1-nc5.pl.eu (91.121.131.150)  1.102 ms  1.396 ms  1.099 ms +
-  fra-fr5-sbb1-nc5.de.eu (213.251.128.113)  18.309 ms fra-fr5-sbb2-nc5.de.eu (54.36.50.116)  21.881 ms fra-fr5-sbb1-nc5.de.eu (213.251.128.113)  16.764 ms +
-  10.200.0.6 (10.200.0.6)  20.922 ms 10.200.0.0 (10.200.0.0)  16.959 ms 10.200.0.4 (10.200.0.4)  21.143 ms +
-  decix.bb-a.fra3.fra.de.oneandone.net (80.81.192.123)  18.789 ms decix.bb-c.act.fra.de.oneandone.net (80.81.193.123)  20.310 ms decix.bb-a.fra3.fra.de.oneandone.net (80.81.192.123)  18.693 ms +
-10  ae-14.bb-b.fr7.fra.de.oneandone.net (212.227.120.149)  22.222 ms  22.206 ms  22.257 ms +
-11  port-channel-3.gw-ngcs-1.dc1.con.glo.gb.oneandone.net (88.208.255.131)  39.660 ms  39.679 ms ae-19.bb-b.thn.lon.gb.oneandone.net (212.227.120.33)  33.973 ms +
-12  109.228.63.209 (109.228.63.209)  37.363 ms port-channel-3.gw-ngcs-1.dc1.con.glo.gb.oneandone.net (88.208.255.131)  39.534 ms 109.228.63.209 (109.228.63.209)  37.901 ms +
-13  * 109.228.63.209 (109.228.63.209)  38.014 ms  37.991 ms +
-14  * * * +
-15  * * * +
-16  * * * +
-17  * * * +
-18  * * * +
-19  * * * +
-20  * * * +
-21  * * * +
-22  * * * +
-23  * * * +
-24  * * * +
-25  * * * +
-26  * * * +
-27  * * * +
-28  * * * +
-29  * * *^C +
-</code> +
- +
-===Options de la commande traceroute=== +
- +
-Les options de cette commande sont : +
- +
-<code> +
-[root@centos8 ~]# traceroute --help +
-Usage: +
-  traceroute [ -46dFITnreAUDV ] [ -f first_ttl ] [ -g gate,... ] [ -i device ] [ -m max_ttl ] [ -N squeries ] [ -p port ] [ -t tos ] [ -flow_label ] [ -w MAX,HERE,NEAR ] [ -q nqueries ] [ -s src_addr ] [ -z sendwait ] [ --fwmark=num ] host [ packetlen ] +
-Options: +
-  -4                          Use IPv4 +
-  -6                          Use IPv6 +
-  -d  --debug                 Enable socket level debugging +
-  -F  --dont-fragment         Do not fragment packets +
-  -f first_ttl  --first=first_ttl +
-                              Start from the first_ttl hop (instead from 1) +
-  -g gate,...  --gateway=gate,... +
-                              Route packets through the specified gateway +
-                              (maximum 8 for IPv4 and 127 for IPv6) +
-  -I  --icmp                  Use ICMP ECHO for tracerouting +
-  -T  --tcp                   Use TCP SYN for tracerouting (default port is 80) +
-  -i device  --interface=device +
-                              Specify a network interface to operate with +
-  -m max_ttl  --max-hops=max_ttl +
-                              Set the max number of hops (max TTL to be +
-                              reached). Default is 30 +
-  -N squeries  --sim-queries=squeries +
-                              Set the number of probes to be tried +
-                              simultaneously (default is 16) +
-  -n                          Do not resolve IP addresses to their domain names +
-  -p port  --port=port        Set the destination port to use. It is either +
-                              initial udp port value for "default" method +
-                              (incremented by each probe, default is 33434), or +
-                              initial seq for "icmp" (incremented as well, +
-                              default from 1), or some constant destination +
-                              port for other methods (with default of 80 for +
-                              "tcp", 53 for "udp", etc.) +
-  -t tos  --tos=tos           Set the TOS (IPv4 type of service) or TC (IPv6 +
-                              traffic class) value for outgoing packets +
-  -l flow_label  --flowlabel=flow_label +
-                              Use specified flow_label for IPv6 packets +
-  -w MAX,HERE,NEAR  --wait=MAX,HERE,NEAR +
-                              Wait for a probe no more than HERE (default 3) +
-                              times longer than a response from the same hop, +
-                              or no more than NEAR (default 10) times than some +
-                              next hop, or MAX (default 5.0) seconds (float +
-                              point values allowed too) +
-  -q nqueries  --queries=nqueries +
-                              Set the number of probes per each hop. Default is +
-                              3 +
-  -r                          Bypass the normal routing and send directly to a +
-                              host on an attached network +
-  -s src_addr  --source=src_addr +
-                              Use source src_addr for outgoing packets +
-  -z sendwait  --sendwait=sendwait +
-                              Minimal time interval between probes (default 0). +
-                              If the value is more than 10, then it specifies a +
-                              number in milliseconds, else it is a number of +
-                              seconds (float point values allowed too) +
-  -e  --extensions            Show ICMP extensions (if present), including MPLS +
-  -A  --as-path-lookups       Perform AS path lookups in routing registries and +
-                              print results directly after the corresponding +
-                              addresses +
-  -M name  --module=name      Use specified module (either builtin or external) +
-                              for traceroute operations. Most methods have +
-                              their shortcuts (`-Imeans `-M icmp' etc.) +
-  -O OPTS,...  --options=OPTS,... +
-                              Use module-specific option OPTS for the +
-                              traceroute module. Several OPTS allowed, +
-                              separated by comma. If OPTS is "help", print info +
-                              about available options +
-  --sport=num                 Use source port num for outgoing packets. Implies +
-                              `-N 1' +
-  --fwmark=num                Set firewall mark for outgoing packets +
-  -U  --udp                   Use UDP to particular port for tracerouting +
-                              (instead of increasing the port per each probe), +
-                              default port is 53 +
-  -UL                         Use UDPLITE for tracerouting (default dest port +
-                              is 53) +
-  -D  --dccp                  Use DCCP Request for tracerouting (default port +
-                              is 33434) +
-  -P prot  --protocol=prot    Use raw packet of protocol prot for tracerouting +
-  --mtu                       Discover MTU along the path being traced. Implies +
-                              `-F -N 1' +
-  --back                      Guess the number of hops in the backward path and +
-                              print if it differs +
-  -V  --version               Print version info and exit +
-  --help                      Read this help and exit +
- +
-Arguments: +
-+     host          The host to traceroute to +
-      packetlen     The full packet length (default is the length of an IP +
-                    header plus 40). Can be ignored or increased to a minimal +
-                    allowed value +
-</code> +
- +
-=====LAB #3 - Connexions à Distance===== +
- +
-==== 3.1 - Telnet ==== +
- +
-WRAP center round important> +
-**Important** - Si la commande **telnet** n'est pas installée sous CentOS 8, installez-le à l'aide de la commande **dnf install telnet** en tant que root. +
-</WRAP> +
- +
-La commande **telnet** est utilisée pour établir une connexion à distance avec un serveur telnet :+
  
 <file> <file>
-  # telnet numero_ip+<network> 
 +  <name>default</name> 
 +  <uuid>0679ee40-befd-4f48-841e-7fc64885eb49</uuid> 
 +  <forward mode='nat'/> 
 +  <bridge name='virbr0' stp='on' delay='0'/> 
 +  <mac address='52:54:00:79:02:66'/> 
 +  <ip address='192.168.56.10' netmask='255.255.255.0'> 
 +    <dhcp> 
 +      <range start='192.168.56.11' end='192.168.56.254'/> 
 +    </dhcp> 
 +  </ip> 
 +</network>
 </file> </file>
  
-<WRAP center round important> +Sortez du mode éditionVous noterez que la commande vous indique que le fichier a été modifié :
-**Important** - Le service telnet revient à une redirection des canaux standards d'entrée et de sortieNotez que la connexion n'est **pas** sécurisée. Pour fermer la connexion, il faut saisir la commande **exit**. La commande telnet n'offre pas de services de transfert de fichiers. Pour cela, il convient d'utiliser la command **ftp**. +
-</WRAP> +
- +
-===Options de la commande telnet=== +
- +
-Les options de cette commande sont :+
  
 <code> <code>
-[[root@centos8 ~]# telnet --help +[ESC]:q 
-telnet: invalid option -- '-' +[root@centos8 ~]# virsh net-edit default 
-Usage: telnet [-4] [-6] [-8] [-E] [-L] [-S tos] [-a] [-c] [-d] [-e char] [-l user] +Network default XML configuration edited.
-        [-n tracefile] [-b hostalias ] [-r]  +
- [host-name [port]]+
 </code> </code>
  
-==== 3.2 - wget ==== +Par contrela simple édition du fichier n'a pas modifiée la configuration en cours :
- +
-La commande **wget** est utilisée pour récupérer un fichier via httphttps ou ftp +
  
 <code> <code>
-[root@centos8 ~]# wget https://www.dropbox.com/s/lqtl47jpj2qu5od/wget_file.txt +[root@centos8 ~]# virsh net-dumpxml default 
---2021-08-29 06:22:26--  https://www.dropbox.com/s/lqtl47jpj2qu5od/wget_file.txt +<network> 
-Resolving www.dropbox.com (www.dropbox.com)... 162.125.67.18, 2620:100:6023:18::a27d:4312 +  <name>default</name> 
-Connecting to www.dropbox.com (www.dropbox.com)|162.125.67.18|:443... connected. +  <uuid>0679ee40-befd-4f48-841e-7fc64885eb49</uuid> 
-HTTP request sent, awaiting response... 301 Moved Permanently +  <forward mode='nat'> 
-Location: /s/raw/lqtl47jpj2qu5od/wget_file.txt [following] +    <nat> 
---2021-08-29 06:22:27--  https://www.dropbox.com/s/raw/lqtl47jpj2qu5od/wget_file.txt +      <port start='1024' end='65535'/
-Reusing existing connection to www.dropbox.com:443. +    </nat> 
-HTTP request sent, awaiting response... 302 Found +  </forward> 
-Location: https://uc8a5f475f4a5f849fd1055f560f.dl.dropboxusercontent.com/cd/0/inline/BVLLQHvou_Z6M6ahJQIL0h_F294OM7CU4q_am-_dpLy8Ifk66MQQSSe66akMc1yzJ_gMMBw0rHAsccFgTriPPpRvY9gMEBBB9FP3gyf2eT1b7SeonjZZshyppFw9-KxrWTJN_3bRB4Rx_t6DXaozZVnV/file# [following] +  <bridge name='virbr0' stp='on' delay='0'/> 
---2021-08-29 06:22:27--  https://uc8a5f475f4a5f849fd1055f560f.dl.dropboxusercontent.com/cd/0/inline/BVLLQHvou_Z6M6ahJQIL0h_F294OM7CU4q_am-_dpLy8Ifk66MQQSSe66akMc1yzJ_gMMBw0rHAsccFgTriPPpRvY9gMEBBB9FP3gyf2eT1b7SeonjZZshyppFw9-KxrWTJN_3bRB4Rx_t6DXaozZVnV/file +  <mac address='52:54:00:79:02:66'/> 
-Resolving uc8a5f475f4a5f849fd1055f560f.dl.dropboxusercontent.com (uc8a5f475f4a5f849fd1055f560f.dl.dropboxusercontent.com)... 162.125.67.15, 2620:100:6023:15::a27d:430f +  <ip address='192.168.122.1' netmask='255.255.255.0'> 
-Connecting to uc8a5f475f4a5f849fd1055f560f.dl.dropboxusercontent.com (uc8a5f475f4a5f849fd1055f560f.dl.dropboxusercontent.com)|162.125.67.15|:443... connected. +    <dhcp> 
-HTTP request sent, awaiting response... 200 OK +      <range start='192.168.122.2' end='192.168.122.254'/> 
-Length: 46 [text/plain] +    </dhcp> 
-Saving to: ‘wget_file.txt’ +  </ip> 
- +</network>
-wget_file.txt       100%[===================>     46  --.-KB/s    in 0s       +
- +
-2021-08-29 06:22:27 (26.9 MB/s) - ‘wget_file.txt’ saved [46/46] +
- +
-[root@centos8 ~]# cat wget_file.txt  +
-This is a file retrieved by the wget command.+
 </code> </code>
  
-===Options de la commande wget=== +Notez que même en cas de re-démarrage du service, la configuration actuelle est persistante 
- +
-Les options de cette commande sont :+
  
 <code> <code>
-[root@centos8 ~]# wget --help +[root@centos8 ~]# systemctl restart libvirtd 
-GNU Wget 1.19.5, a non-interactive network retriever. +[root@centos8 ~]# systemctl status libvirtd 
-Usagewget [OPTION]... [URL]...+● libvirtd.service Virtualization daemon 
 +   Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled) 
 +   Active: active (running) since Thu 2021-09-02 10:27:41 EDT; 7s ago 
 +     Docs: man:libvirtd(8) 
 +           https://libvirt.org 
 + Main PID: 4037 (libvirtd) 
 +    Tasks: 19 (limit: 32768) 
 +   Memory: 57.5M 
 +   CGroup/system.slice/libvirtd.service 
 +           ├─1950 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper 
 +           ├─1951 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper 
 +           └─4037 /usr/sbin/libvirtd --timeout 120
  
-Mandatory arguments to long options are mandatory for short options too.+Sep 02 10:27:41 centos8.ittraining.loc systemd[1]: Starting Virtualization daemon... 
 +Sep 02 10:27:41 centos8.ittraining.loc systemd[1]: Started Virtualization daemon. 
 +Sep 02 10:27:41 centos8.ittraining.loc dnsmasq[1950]: read /etc/hosts - 2 addresses 
 +Sep 02 10:27:41 centos8.ittraining.loc dnsmasq[1950]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses 
 +Sep 02 10:27:41 centos8.ittraining.loc dnsmasq-dhcp[1950]: read /var/lib/libvirt/dnsmasq/default.hostsfile
  
-Startup: +[root@centos8 ~]# virsh net-dumpxml default 
-  -V,  --version                   display the version of Wget and exit +<network> 
-  -h,  --help                      print this help +  <name>default</name> 
-  -b,  --background                go to background after startup +  <uuid>0679ee40-befd-4f48-841e-7fc64885eb49</uuid> 
-  -e,  --execute=COMMAND           execute a `.wgetrc'-style command +  <forward mode='nat'> 
- +    <nat> 
-Logging and input file: +      <port start='1024end='65535'/> 
-  -o,  --output-file=FILE          log messages to FILE +    </nat> 
-  -a,  --append-output=FILE        append messages to FILE +  </forward> 
-  -d,  --debug                     print lots of debugging information +  <bridge name='virbr0' stp='on' delay='0'/> 
-  -q,  --quiet                     quiet (no output) +  <mac address='52:54:00:79:02:66'/> 
-  -v,  --verbose                   be verbose (this is the default) +  <ip address='192.168.122.1netmask='255.255.255.0'> 
-  -nv, --no-verbose                turn off verboseness, without being quiet +    <dhcp> 
-       --report-speed=TYPE         output bandwidth as TYPE.  TYPE can be bits +      <range start='192.168.122.2' end='192.168.122.254'/> 
-  -i,  --input-file=FILE           download URLs found in local or external FILE +    </dhcp> 
-       --input-metalink=FILE       download files covered in local Metalink FILE +  </ip> 
-  -F,  --force-html                treat input file as HTML +</network>
-  -B,  --base=URL                  resolves HTML input-file links (-i -F) +
-                                     relative to URL +
-       --config=FILE               specify config file to use +
-       --no-config                 do not read any config file +
-       --rejected-log=FILE         log reasons for URL rejection to FILE +
- +
-Download: +
-  -t,  --tries=NUMBER              set number of retries to NUMBER (0 unlimits) +
-       --retry-connrefused         retry even if connection is refused +
-       --retry-on-http-error=ERRORS    comma-separated list of HTTP errors to retry +
-  -O,  --output-document=FILE      write documents to FILE +
-  -nc, --no-clobber                skip downloads that would download to +
-                                     existing files (overwriting them) +
-       --no-netrc                  don't try to obtain credentials from .netrc +
-  -c,  --continue                  resume getting a partially-downloaded file +
-       --start-pos=OFFSET          start downloading from zero-based position OFFSET +
-       --progress=TYPE             select progress gauge type +
-       --show-progress             display the progress bar in any verbosity mode +
-  -N,  --timestamping              don't re-retrieve files unless newer than +
-                                     local +
-       --no-if-modified-since      don't use conditional if-modified-since get +
-                                     requests in timestamping mode +
-       --no-use-server-timestamps  don't set the local file's timestamp by +
-                                     the one on the server +
-  -S,  --server-response           print server response +
-       --spider                    don't download anything +
-  -T,  --timeout=SECONDS           set all timeout values to SECONDS +
-       --dns-timeout=SECS          set the DNS lookup timeout to SECS +
-       --connect-timeout=SECS      set the connect timeout to SECS +
-       --read-timeout=SECS         set the read timeout to SECS +
-  -w,  --wait=SECONDS              wait SECONDS between retrievals +
-       --waitretry=SECONDS         wait 1..SECONDS between retries of a retrieval +
-       --random-wait               wait from 0.5*WAIT...1.5*WAIT secs between retrievals +
-       --no-proxy                  explicitly turn off proxy +
-  -Q,  --quota=NUMBER              set retrieval quota to NUMBER +
-       --bind-address=ADDRESS      bind to ADDRESS (hostname or IP) on local host +
-       --limit-rate=RATE           limit download rate to RATE +
-       --no-dns-cache              disable caching DNS lookups +
-       --restrict-file-names=OS    restrict chars in file names to ones OS allows +
-       --ignore-case               ignore case when matching files/directories +
-  -4,  --inet4-only                connect only to IPv4 addresses +
-  -6,  --inet6-only                connect only to IPv6 addresses +
-       --prefer-family=FAMILY      connect first to addresses of specified family, +
-                                     one of IPv6, IPv4, or none +
-       --user=USER                 set both ftp and http user to USER +
-       --password=PASS             set both ftp and http password to PASS +
-       --ask-password              prompt for passwords +
-       --use-askpass=COMMAND       specify credential handler for requesting  +
-                                     username and password.  If no COMMAND is  +
-                                     specified the WGET_ASKPASS or the SSH_ASKPASS  +
-                                     environment variable is used. +
-       --no-iri                    turn off IRI support +
-       --local-encoding=ENC        use ENC as the local encoding for IRIs +
-       --remote-encoding=ENC       use ENC as the default remote encoding +
-       --unlink                    remove file before clobber +
-       --keep-badhash              keep files with checksum mismatch (append .badhash) +
-       --metalink-index=NUMBER     Metalink application/metalink4+xml metaurl ordinal NUMBER +
-       --metalink-over-http        use Metalink metadata from HTTP response headers +
-       --preferred-location        preferred location for Metalink resources +
-       --xattr                     turn on storage of metadata in extended file attributes +
- +
-Directories: +
-  -nd, --no-directories            don't create directories +
-  -x,  --force-directories         force creation of directories +
-  -nH, --no-host-directories       don't create host directories +
-       --protocol-directories      use protocol name in directories +
-  -P,  --directory-prefix=PREFIX   save files to PREFIX/.. +
-       --cut-dirs=NUMBER           ignore NUMBER remote directory components +
- +
-HTTP options: +
-       --http-user=USER            set http user to USER +
-       --http-password=PASS        set http password to PASS +
-       --no-cache                  disallow server-cached data +
-       --default-page=NAME         change the default page name (normally +
-                                     this is 'index.html'.) +
-  -E,  --adjust-extension          save HTML/CSS documents with proper extensions +
-       --ignore-length             ignore 'Content-Length' header field +
-       --header=STRING             insert STRING among the headers +
-       --compression=TYPE          choose compression, one of auto, gzip and none. (default: none) +
-       --max-redirect              maximum redirections allowed per page +
-       --proxy-user=USER           set USER as proxy username +
-       --proxy-password=PASS       set PASS as proxy password +
-       --referer=URL               include 'RefererURLheader in HTTP request +
-       --save-headers              save the HTTP headers to file +
-  -U,  --user-agent=AGENT          identify as AGENT instead of Wget/VERSION +
-       --no-http-keep-alive        disable HTTP keep-alive (persistent connections) +
-       --no-cookies                don't use cookies +
-       --load-cookies=FILE         load cookies from FILE before session +
-       --save-cookies=FILE         save cookies to FILE after session +
-       --keep-session-cookies      load and save session (non-permanent) cookies +
-       --post-data=STRING          use the POST method; send STRING as the data +
-       --post-file=FILE            use the POST method; send contents of FILE +
-       --method=HTTPMethod         use method "HTTPMethod" in the request +
-       --body-data=STRING          send STRING as data--method MUST be set +
-       --body-file=FILE            send contents of FILE--method MUST be set +
-       --content-disposition       honor the Content-Disposition header when +
-                                     choosing local file names (EXPERIMENTAL) +
-       --content-on-error          output the received content on server errors +
-       --auth-no-challenge         send Basic HTTP authentication information +
-                                     without first waiting for the server'+
-                                     challenge +
- +
-HTTPS (SSL/TLS) options: +
-       --secure-protocol=PR        choose secure protocol, one of auto, SSLv2, +
-                                     SSLv3, TLSv1, TLSv1_1, TLSv1_2 and PFS +
-       --https-only                only follow secure HTTPS links +
-       --no-check-certificate      don't validate the server's certificate +
-       --certificate=FILE          client certificate file +
-       --certificate-type=TYPE     client certificate type, PEM or DER +
-       --private-key=FILE          private key file +
-       --private-key-type=TYPE     private key type, PEM or DER +
-       --ca-certificate=FILE       file with the bundle of CAs +
-       --ca-directory=DIR          directory where hash list of CAs is stored +
-       --crl-file=FILE             file with bundle of CRLs +
-       --pinnedpubkey=FILE/HASHES  Public key (PEM/DER) file, or any number +
-                                   of base64 encoded sha256 hashes preceded by +
-                                   'sha256//' and separated by ';', to verify +
-                                   peer against +
- +
-       --ciphers=STR           Set the priority string (GnuTLS) or cipher list string (OpenSSL) directly. +
-                                   Use with careThis option overrides --secure-protocol. +
-                                   The format and syntax of this string depend on the specific SSL/TLS engine. +
-HSTS options: +
-       --no-hsts                   disable HSTS +
-       --hsts-file                 path of HSTS database (will override default) +
- +
-FTP options: +
-       --ftp-user=USER             set ftp user to USER +
-       --ftp-password=PASS         set ftp password to PASS +
-       --no-remove-listing         don't remove '.listingfiles +
-       --no-glob                   turn off FTP file name globbing +
-       --no-passive-ftp            disable the "passive" transfer mode +
-       --preserve-permissions      preserve remote file permissions +
-       --retr-symlinks             when recursing, get linked-to files (not dir) +
- +
-FTPS options: +
-       --ftps-implicit                 use implicit FTPS (default port is 990) +
-       --ftps-resume-ssl               resume the SSL/TLS session started in the control connection when +
-                                         opening a data connection +
-       --ftps-clear-data-connection    cipher the control channel only; all the data will be in plaintext +
-       --ftps-fallback-to-ftp          fall back to FTP if FTPS is not supported in the target server +
-WARC options: +
-       --warc-file=FILENAME        save request/response data to a .warc.gz file +
-       --warc-header=STRING        insert STRING into the warcinfo record +
-       --warc-max-size=NUMBER      set maximum size of WARC files to NUMBER +
-       --warc-cdx                  write CDX index files +
-       --warc-dedup=FILENAME       do not store records listed in this CDX file +
-       --no-warc-compression       do not compress WARC files with GZIP +
-       --no-warc-digests           do not calculate SHA1 digests +
-       --no-warc-keep-log          do not store the log file in a WARC record +
-       --warc-tempdir=DIRECTORY    location for temporary files created by the +
-                                     WARC writer +
- +
-Recursive download: +
-  -r,  --recursive                 specify recursive download +
-  -l,  --level=NUMBER              maximum recursion depth (inf or 0 for infinite) +
-       --delete-after              delete files locally after downloading them +
-  -k,  --convert-links             make links in downloaded HTML or CSS point to +
-                                     local files +
-       --convert-file-only         convert the file part of the URLs only (usually known as the basename) +
-       --backups=N                 before writing file X, rotate up to N backup files +
-  -K,  --backup-converted          before converting file X, back up as X.orig +
-  -m,  --mirror                    shortcut for -N -r -l inf --no-remove-listing +
-  -p,  --page-requisites           get all images, etc. needed to display HTML page +
-       --strict-comments           turn on strict (SGML) handling of HTML comments +
- +
-Recursive accept/reject: +
-  -A,  --accept=LIST               comma-separated list of accepted extensions +
-  -R,  --reject=LIST               comma-separated list of rejected extensions +
-       --accept-regex=REGEX        regex matching accepted URLs +
-       --reject-regex=REGEX        regex matching rejected URLs +
-       --regex-type=TYPE           regex type (posix) +
-  -D,  --domains=LIST              comma-separated list of accepted domains +
-       --exclude-domains=LIST      comma-separated list of rejected domains +
-       --follow-ftp                follow FTP links from HTML documents +
-       --follow-tags=LIST          comma-separated list of followed HTML tags +
-       --ignore-tags=LIST          comma-separated list of ignored HTML tags +
-  -H,  --span-hosts                go to foreign hosts when recursive +
-  -L,  --relative                  follow relative links only +
-  -I,  --include-directories=LIST  list of allowed directories +
-       --trust-server-names        use the name specified by the redirection +
-                                     URL's last component +
-  -X,  --exclude-directories=LIST  list of excluded directories +
-  -np, --no-parent                 don't ascend to the parent directory +
- +
-Email bug reports, questions, discussions to <bug-wget@gnu.org> +
-and/or open issues at https://savannah.gnu.org/bugs/?func=additem&group=wget.+
 </code> </code>
  
-==== 3.3 ftp ==== +Re-démarrez donc votre VM :
- +
-<WRAP center round important> +
-**Important** - Si la commande **ftp** n'est pas installée sous CentOS 8, installez-le à l'aide de la commande **dnf install ftp** en tant que root. +
-</WRAP> +
- +
-La commande **ftp** est utilisée pour le transfert de fichiers. Une fois connecté, il convient d'utiliser la commande **help** pour afficher la liste des commandes disponibles :+
  
 <code> <code>
-ftp> help +[root@centos8 ~]# reboot
-Commands may be abbreviated.  Commands are: +
- +
-! debug mdir sendport site +
-$ dir mget put size +
-account disconnect mkdir pwd status +
-append exit mls quit struct +
-ascii form mode quote system +
-bell get modtime recv sunique +
-binary glob mput reget tenex +
-bye hash newer rstatus tick +
-case help nmap rhelp trace +
-cd idle nlist rename type +
-cdup image ntrans reset user +
-chmod lcd open restart umask +
-close ls prompt rmdir verbose +
-cr macdef passive runique ? +
-delete mdelete proxy send +
-ftp> +
 </code> </code>
  
-Le caractère **!** permet d'exécuter une commande sur la machine cliente+Connectez-vous de nouveau à votre VM et contrôler la sortie de la commande **nmcli c show** :
  
 <code> <code>
-ftp> !pwd +[root@centos8 ~]# nmcli c show 
-/root+NAME     UUID                                  TYPE      DEVICE  
 +ip_fixe  0f48c74d-5d16-4c37-8220-24644507b589  ethernet  ens18   
 +virbr0   289e0fdd-2eb5-4dd3-811a-65a878926e56  bridge    virbr0  
 +ip_kvm   afc8b175-f2cb-47b2-baca-66454058c36f  ethernet  ens19   
 +ens18    fc4a4d23-b15e-47a7-bcfa-b2e08f49553e  ethernet  --   
 </code> </code>
  
-Pour transférer un fichier vers le serveur, il convient d'utiliser la commande **put** +Utilisez ensuite la commande **ip** pour vérifier l'adresse IP de **virbr0** :
- +
-<file> +
-ftp> put nom_fichier_local nom_fichier_distant +
-</file> +
- +
-Vous pouvez également transférer plusieurs fichiers à la fois grâce à la commande **mput**. Dans ce cas précis, il convient de saisir la commande suivante: +
- +
-<file> +
-ftp> mput nom*.* +
-</file> +
- +
-Pour transférer un fichier du serveur, il convient d'utiliser la commande **get** : +
- +
-<file> +
-ftp> get nom_fichier +
-</file> +
- +
-Vous pouvez également transférer plusieurs fichiers à la fois grâce à la commande **mget** ( voir la commande **mput** ci-dessus ). +
- +
-Pour supprimer un fichier sur le serveur, il convient d'utiliser la commande **del** : +
- +
-<file> +
-ftp> del nom_fichier +
-</file> +
- +
-Pour fermer la session, il convient d'utiliser la commande **quit** :+
  
 <code> <code>
-ftp> quit +[root@centos8 ~]# ip a 
-[root@centos7 ~]# +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: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 
 +    link/ether 4e:b1:31:bd:5d:b2 brd ff:ff:ff:ff:ff:ff 
 +    inet 10.0.2.46/24 brd 10.0.2.255 scope global noprefixroute ens18 
 +       valid_lft forever preferred_lft forever 
 +    inet 192.168.1.2/24 brd 192.168.1.255 scope global noprefixroute ens18 
 +       valid_lft forever preferred_lft forever 
 +    inet6 fe80::5223:aee1:998e:9f27/64 scope link noprefixroute  
 +       valid_lft forever preferred_lft forever 
 +3: ens19: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master virbr0 state UP group default qlen 1000 
 +    link/ether 46:de:37:c0:55:6c brd ff:ff:ff:ff:ff:ff 
 +4: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 
 +    link/ether 52:54:00:79:02:66 brd ff:ff:ff:ff:ff:ff 
 +    inet 192.168.56.10/24 brd 192.168.56.255 scope global virbr0 
 +       valid_lft forever preferred_lft forever 
 +5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000 
 +    link/ether 52:54:00:79:02:66 brd ff:ff:ff:ff:ff:ff
 </code> </code>
  
-====3.4 - SSH==== +Dernièrementvérifier la connectivité avec la passerelle **192.162.56.1/24** :
- +
-===Présentation=== +
- +
-La commande **[[wpfr>Ssh|ssh]]** est le successeur et la remplaçante de la commande **[[wpfr>Rlogin|rlogin]]**. Il permet d'établir des connexions sécurisées avec une machine distante. SSH comporte cinq acteurs : +
- +
-  * Le **serveur SSH** +
-    * le démon sshd, qui s'occupe des authentifications et autorisations des clients,  +
-  * Le **client SSH** +
-    * ssh ou scpqui assure la connexion et le dialogue avec le serveur, +
-  * La **session** qui représente la connexion courante et qui commence juste après l'authentification réussie, +
-  Les **clefs** +
-    * **Couple de clef utilisateur asymétriques** et persistantes qui assurent l'identité d'un utilisateur et qui sont stockés sur disque dur, +
-    * **Clef hôte asymétrique et persistante** garantissant l'identité du serveur er qui est conservé sur disque dur +
-    * **Clef serveur asymétrique et temporaire** utilisée par le protocole SSH1 qui sert au chiffrement de la clé de session, +
-    * **Clef de session symétrique qui est générée aléatoirement** et qui permet le chiiffrement de la communication entre le client et le serveurElle est détruite en fin de sessionSSH-1 utilise une seule clef tandis que SSH-2 utilise une clef par direction de la communication, +
-  * La **base de données des hôtes connus** qui stocke les clés des connexions précédentes. +
- +
-SSH fonctionne de la manière suivante pour la la mise en place d'un canal sécurisé: +
- +
-  * Le client contacte le serveur sur son port 22, +
-  * Les client et le serveur échangent leur version de SSH. En cas de non-compatibilité de versions, l'un des deux met fin au processus, +
-  * Le serveur SSH s'identifie auprès du client en lui fournissant : +
-    * Sa clé hôte, +
-    * Sa clé serveur, +
-    * Une séquence aléatoire de huit octets à inclure dans les futures réponses du client, +
-    * Une liste de méthodes de chiffrage, compression et authentification, +
-  * Le client et le serveur produisent un identifiant identique, un haché MD5 long de 128 bits contenant la clé hôte, la clé serveur et la séquence aléatoire, +
-  * Le client génère sa clé de session symétrique et la chiffre deux fois de suite, une fois avec la clé hôte du serveur et la deuxième fois avec la clé serveur. Le client envoie cette clé au serveur accompagnée de la séquence aléatoire et un choix d'algorithmes supportés, +
-  * Le serveur déchiffre la clé de session, +
-  * Le client et le serveur mettent en place le canal sécurisé. +
- +
-==SSH-1== +
- +
-SSH-1 utilise une paire de clefs de type RSA1. Il assure l'intégrité des données par une **[[wpfr>Contrôle_de_redondance_cyclique|Contrôle de Redondance Cyclique]]** (CRC) et est un bloc dit **monolithique**. +
- +
-Afin de s'identifier, le client essaie chacune des six méthodes suivantes : +
- +
-  * **Kerberos**, +
-  * **Rhosts**, +
-  * **%%RhostsRSA%%**, +
-  * Par **clef asymétrique**, +
-  * **TIS**, +
-  * Par **mot de passe**. +
- +
-==SSH-2== +
- +
-SSH-2 utilise **DSA** ou **RSA**. Il assure l'intégrité des données par l'algorithme **HMAC**. SSH-2 est organisé en trois **couches** : +
- +
-  * **SSH-TRANS** – Transport Layer Protocol, +
-  * **SSH-AUTH** – Authentification Protocol, +
-  * **SSH-CONN** – Connection Protocol. +
- +
-SSH-2 diffère de SSH-1 essentiellement dans la phase authentification.  +
- +
-Trois méthodes d'authentification : +
- +
-  * Par **clef asymétrique**, +
-    * Identique à SSH-1 sauf avec l'algorithme DSA, +
-  * **%%RhostsRSA%%**, +
-  * Par **mot de passe**. +
- +
-==Options de la commande== +
- +
-Les options de cette commande sont :+
  
 <code> <code>
-[root@centos8 ~]# ssh --help +[root@centos8 ~]# ping 192.168.56.1 
-unknown option -- - +PING 192.168.56.1 (192.168.56.1) 56(84) bytes of data. 
-usagessh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] +64 bytes from 192.168.56.1icmp_seq=1 ttl=64 time=14.8 ms 
-           [-b bind_address] [-c cipher_spec] [-D [bind_address:]port] +64 bytes from 192.168.56.1icmp_seq=2 ttl=64 time=0.154 ms 
-           [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11] +64 bytes from 192.168.56.1icmp_seq=3 ttl=64 time=0.153 ms 
-           [-i identity_file] [-J [user@]host[:port]] [-L address] +^C 
-           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] +--- 192.168.56.1 ping statistics --- 
-           [-Q query_option] [-R address] [-S ctl_path] [-W host:port] +3 packets transmitted, 3 received, 0% packet loss, time 2023ms 
-           [-w local_tun[:remote_tun]] destination [command]+rtt min/avg/max/mdev = 0.153/5.030/14.785/6.897 ms
 </code> </code>
  
-===Authentification par mot de passe===+====2.3 - Configuration du Stockage====
  
-L'utilisateur fournit un mot de passe au client sshLe client ssh le transmet de façon sécurisée au serveur ssh puis  le serveur vérifie le mot de passe et l'accepte ou non. +KVM a besoin d'un emplacement pour stocker les VMs créées. L'hôte KVM a été configuré avec un disque supplémentaire **sdd** d'une taille de **32 Go** à cet effet :
- +
-Avantage: +
-  * Aucune configuration de clef asymétrique n'est nécessaire. +
- +
-Inconvénients: +
-  * L'utilisateur doit fournir à chaque connexion un identifiant et un mot de passe, +
-  Moins sécurisé qu'un système par clef asymétrique. +
- +
-===Authentification par clef asymétrique=== +
- +
-  Le **client** envoie au serveur une requête d'authentification par clé asymétrique qui contient le module de la clé à utiliser, +
-  Le **serveur** recherche une correspondance pour ce module dans le fichier des clés autorisés **~/.ssh/authorized_keys**, +
-    * Dans le cas où une correspondance n'est pas trouvée, le serveur met fin à la communication, +
-    * Dans le cas contraire le serveur génère une chaîne aléatoire de 256 bits appelée un **challenge** et la chiffre avec la **clé publique du client**, +
-  * Le **client** reçoit le challenge et le décrypte avec la partie privée de sa clé. Il combine le challenge avec l'identifiant de session et chiffre le résultat. Ensuite il envoie le résultat chiffré au serveur. +
-  * Le **serveur** génère le même haché et le compare avec celui reçu du client. Si les deux hachés sont identiques, l'authentification est réussie. +
- +
-===Configuration du Serveur=== +
- +
-La configuration du serveur s'effectue dans le fichier **/etc/ssh/sshd_config** :+
  
 <code> <code>
-[root@centos8 ~]# cat /etc/ssh/sshd_config +[root@centos8 ~]# lsblk 
-#       $OpenBSDsshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $ +NAME                MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT 
- +sda                   8:0    0   32G  0 disk  
-# This is the sshd server system-wide configuration file.  See +├─sda1                8:1    0    1G  0 part /boot 
-# sshd_config(5) for more information. +└─sda2                8:2    0   31G  0 part  
- +  ├─cl_centos8-root 253:   27.8G  lvm  
-# This sshd was compiled with PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin +  └─cl_centos8-swap 253:1    0  3.2G  0 lvm  [SWAP] 
- +sdb                   8:16      4G  0 disk  
-# The strategy used for options in the default sshd_config shipped with +sdc                   8:32     64G  0 disk  
-# OpenSSH is to specify options with their default value where +└─sdc1                8:33     64G  0 part /home 
-# possible, but leave them commented.  Uncommented options override the +sdd                   8:48     32G  0 disk  
-# default value. +sr0                  11:   1 1024M  0 rom   
- +
-# If you want to change the port on a SELinux system, you have to tell +
-# SELinux about this change. +
-# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER +
-+
-#Port 22 +
-#AddressFamily any +
-#ListenAddress 0.0.0.0 +
-#ListenAddress :: +
- +
-HostKey /etc/ssh/ssh_host_rsa_key +
-HostKey /etc/ssh/ssh_host_ecdsa_key +
-HostKey /etc/ssh/ssh_host_ed25519_key +
- +
-# Ciphers and keying +
-#RekeyLimit default none +
- +
-# This system is following system-wide crypto policyThe changes to +
-# crypto properties (Ciphers, MACs, ...) will not have any effect here. +
-# They will be overridden by command-line options passed to the server +
-# on command line. +
-# Please, check manual pages for update-crypto-policies(8) and sshd_config(5). +
- +
-# Logging +
-#SyslogFacility AUTH +
-SyslogFacility AUTHPRIV +
-#LogLevel INFO +
- +
-# Authentication: +
- +
-#LoginGraceTime 2m +
-PermitRootLogin yes +
-#StrictModes yes +
-#MaxAuthTries 6 +
-#MaxSessions 10 +
- +
-#PubkeyAuthentication yes +
- +
-# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2 +
-# but this is overridden so installations will only check .ssh/authorized_keys +
-AuthorizedKeysFile      .ssh/authorized_keys +
- +
-#AuthorizedPrincipalsFile none +
- +
-#AuthorizedKeysCommand none +
-#AuthorizedKeysCommandUser nobody +
- +
-# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts +
-#HostbasedAuthentication no +
-# Change to yes if you don't trust ~/.ssh/known_hosts for +
-# HostbasedAuthentication +
-#IgnoreUserKnownHosts no +
-# Don't read the user's ~/.rhosts and ~/.shosts files +
-#IgnoreRhosts yes +
- +
-# To disable tunneled clear text passwords, change to no here! +
-#PasswordAuthentication yes +
-#PermitEmptyPasswords no +
-PasswordAuthentication yes +
- +
-# Change to no to disable s/key passwords +
-#ChallengeResponseAuthentication yes +
-ChallengeResponseAuthentication no +
- +
-# Kerberos options +
-#KerberosAuthentication no +
-#KerberosOrLocalPasswd yes +
-#KerberosTicketCleanup yes +
-#KerberosGetAFSToken no +
-#KerberosUseKuserok yes +
- +
-# GSSAPI options +
-GSSAPIAuthentication yes +
-GSSAPICleanupCredentials no +
-#GSSAPIStrictAcceptorCheck yes +
-#GSSAPIKeyExchange no +
-#GSSAPIEnablek5users no +
- +
-# Set this to 'yes' to enable PAM authentication, account processing, +
-# and session processing. If this is enabled, PAM authentication will +
-# be allowed through the ChallengeResponseAuthentication and +
-# PasswordAuthentication.  Depending on your PAM configuration, +
-# PAM authentication via ChallengeResponseAuthentication may bypass +
-# the setting of "PermitRootLogin without-password"+
-# If you just want the PAM account and session checks to run without +
-# PAM authentication, then enable this but set PasswordAuthentication +
-# and ChallengeResponseAuthentication to 'no'+
-# WARNING'UsePAM no' is not supported in Fedora and may cause several +
-# problems. +
-UsePAM yes +
- +
-#AllowAgentForwarding yes +
-#AllowTcpForwarding yes +
-#GatewayPorts no +
-X11Forwarding yes +
-#X11DisplayOffset 10 +
-#X11UseLocalhost yes +
-#PermitTTY yes +
- +
-# It is recommended to use pam_motd in /etc/pam.d/sshd instead of PrintMotd, +
-# as it is more configurable and versatile than the built-in version. +
-PrintMotd no +
- +
-#PrintLastLog yes +
-#TCPKeepAlive yes +
-#PermitUserEnvironment no +
-#Compression delayed +
-#ClientAliveInterval +
-#ClientAliveCountMax 3 +
-#UseDNS no +
-#PidFile /var/run/sshd.pid +
-#MaxStartups 10:30:100 +
-#PermitTunnel no +
-#ChrootDirectory none +
-#VersionAddendum none +
- +
-# no default banner path +
-#Banner none +
- +
-# Accept locale-related environment variables +
-AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES +
-AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT +
-AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE +
-AcceptEnv XMODIFIERS +
- +
-# override default of no subsystems +
-Subsystem       sftp    /usr/libexec/openssh/sftp-server +
- +
-# Example of overriding settings on a per-user basis +
-#Match User anoncvs +
-#       X11Forwarding no +
-#       AllowTcpForwarding no +
-#       PermitTTY no +
-#       ForceCommand cvs server+
 </code> </code>
  
-Pour ôter les lignes de commentaires dans ce fichier, utilisez la commande suivante :+Créez donc sur **/dev/sdd** un volume physique ainsi qu'un groupe de volumes appelé **kvm_storage** :
  
 <code> <code>
-[root@centos8 ~]# cd /tmp ; grep -E -v '^(#|$)'  /etc/ssh/sshd_config > sshd_config +[root@centos8 ~]# pvcreate /dev/sdd 
-[root@centos8 tmp]# cat sshd_config  +  Physical volume "/dev/sdd" successfully created. 
-HostKey /etc/ssh/ssh_host_rsa_key +[root@centos8 ~]# vgcreate kvm_storage /dev/sdd 
-HostKey /etc/ssh/ssh_host_ecdsa_key +  Volume group "kvm_storage" successfully created
-HostKey /etc/ssh/ssh_host_ed25519_key +
-SyslogFacility AUTHPRIV +
-PermitRootLogin yes +
-AuthorizedKeysFile      .ssh/authorized_keys +
-PasswordAuthentication yes +
-ChallengeResponseAuthentication no +
-GSSAPIAuthentication yes +
-GSSAPICleanupCredentials no +
-UsePAM yes +
-X11Forwarding yes +
-PrintMotd no +
-AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES +
-AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT +
-AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE +
-AcceptEnv XMODIFIERS +
-Subsystem       sftp    /usr/libexec/openssh/sftp-server+
 </code> </code>
- 
-Pour sécuriser le serveur ssh, ajoutez ou modifiez les directives suivantes : 
- 
-<file> 
-AllowGroups adm 
-Banner /etc/issue.net 
-HostbasedAuthentication no 
-IgnoreRhosts yes 
-LoginGraceTime 60 
-LogLevel INFO 
-PermitEmptyPasswords no 
-PermitRootLogin no 
-PrintLastLog yes 
-Protocol 2 
-StrictModes yes 
-X11Forwarding no 
-</file> 
- 
-Votre fichier ressemblera à celui-ci : 
  
 <code> <code>
-[root@centos8 tmp]# vi sshd_config  +[root@centos8 ~]# vgs 
-[root@centos8 tmp]cat sshd_config  +  VG          #PV #LV #SN Attr   VSize   VFree   
-AllowGroups adm +  cl_centos8    1     0 wz--n- <31.00g       
-Banner /etc/issue.net +  kvm_storage       0 wz--n- <32.00g <32.00g
-HostbasedAuthentication no +
-IgnoreRhosts yes +
-LoginGraceTime 60 +
-LogLevel INFO +
-PermitEmptyPasswords no +
-PermitRootLogin no +
-PrintLastLog yes +
-Protocol 2 +
-StrictModes yes +
-X11Forwarding no +
-HostKey /etc/ssh/ssh_host_rsa_key +
-HostKey /etc/ssh/ssh_host_ecdsa_key +
-HostKey /etc/ssh/ssh_host_ed25519_key +
-SyslogFacility AUTHPRIV +
-PermitRootLogin yes +
-AuthorizedKeysFile      .ssh/authorized_keys +
-PasswordAuthentication yes +
-ChallengeResponseAuthentication no +
-GSSAPIAuthentication yes +
-GSSAPICleanupCredentials no +
-UsePAM yes +
-PrintMotd no +
-AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES +
-AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT +
-AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE +
-AcceptEnv XMODIFIERS +
-Subsystem       sftp    /usr/libexec/openssh/sftp-server+
 </code> </code>
  
-Renommez le fichier **/etc/ssh/sshd_config** en **/etc/ssh/sshd_config.old** :+Créez ensuite un volume logique, dénommé **kvm_lv**, occupant toute l'espace disponible dans le groupe de volumes :
  
 <code> <code>
-[root@centos8 tmp]# cp /etc/ssh/sshd_config /etc/ssh/sshd_config.old+[root@centos8 ~]# lvcreate -l +100%FREE -n kvm_lv kvm_storage 
 +  Logical volume "kvm_lv" created. 
 +   
 +[root@centos8 ~]# lvs 
 +  LV     VG          Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert 
 +  root   cl_centos8  -wi-ao----  27.79g                                                     
 +  swap   cl_centos8  -wi-ao----   3.20g                                                     
 +  kvm_lv kvm_storage -wi-a----- <32.00g
 </code> </code>
  
-Copiez le fichier **/tmp/sshd_config** vers **/etc/ssh/** : +Créez ensuite un système de fichiers de type **xfs** sur le volume logique **kvm_lv** : 
 +  
 <code> <code>
-[root@centos8 tmp]# cp /tmp/sshd_config /etc/ssh +[root@centos8 ~]# mkfs.xfs /dev/mapper/kvm_storage-kvm_lv 
-cp: overwrite '/etc/ssh/sshd_config'? y+meta-data=/dev/mapper/kvm_storage-kvm_lv isize=512    agcount=4, agsize=2096896 blks 
 +                               sectsz=512   attr=2, projid32bit=1 
 +                               crc=1        finobt=1, sparse=1, rmapbt=0 
 +                               reflink=1 
 +data                           bsize=4096   blocks=8387584, imaxpct=25 
 +                               sunit=0      swidth=0 blks 
 +naming   =version 2              bsize=4096   ascii-ci=0, ftype=1 
 +log      =internal log           bsize=4096   blocks=4095, version=2 
 +                               sectsz=512   sunit=0 blks, lazy-count=1 
 +realtime =none                   extsz=4096   blocks=0, rtextents=0 
 +Discarding blocks...Done.
 </code> </code>
  
-Redémarrez le service sshd :+Éditez ensuite le fichier **/etc/fstab** afin de monter automatiquement le volume logique sur **/var/lib/libvirt/images** :
  
 <code> <code>
-[root@centos8 tmp]# systemctl restart sshd +[root@centos8 ~]# vi /etc/fstab 
-[root@centos8 tmp]# systemctl status sshd +[root@centos8 ~]# cat /etc/fstab
-● sshd.service - OpenSSH server daemon +
-   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) +
-   Active: active (running) since Mon 2021-08-30 02:17:00 EDT; 11s ago +
-     Docs: man:sshd(8) +
-           man:sshd_config(5) +
- Main PID: 1042039 (sshd) +
-    Tasks: 1 (limit: 23535) +
-   Memory: 1.1M +
-   CGroup: /system.slice/sshd.service +
-           └─1042039 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,a>+
  
-Aug 30 02:17:00 centos8.ittraining.loc systemd[1]: Starting OpenSSH server daemon..+
-Aug 30 02:17:00 centos8.ittraining.loc sshd[1042039]: Server listening on 0.0.0.0 port 22. +# /etc/fstab 
-Aug 30 02:17:00 centos8.ittraining.loc sshd[1042039]: Server listening on :: port 22. +# Created by anaconda on Wed Jun 16 06:21:32 2021 
-Aug 30 02:17:00 centos8.ittraining.loc systemd[1]: Started OpenSSH server daemon. +
-[q] +# Accessible filesystems, by reference, are maintained under '/dev/disk/'. 
-</code>+# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info. 
 +
 +# After editing this file, run 'systemctl daemon-reload' to update systemd 
 +# units generated from this file
 +
 +/dev/mapper/cl_centos8-root /                       xfs     defaults        0 0 
 +UUID=1c04981e-5317-4b73-9695-3ce25246835d /boot                   ext4    defaults        2 
 +/dev/mapper/cl_centos8-swap swap                    swap    defaults        0 0 
 +UUID=f76d6b66-985b-4a91-af9c-4987e8c1443c /home     ext4          defaults,usrquota,grpquota            1 2
  
-Mettez l'utilisateur **trainee** dans le groupe **adm** : +## KVM Guest Image Store 
- +/dev/mapper/kvm_storage-kvm_lv   /var/lib/libvirt/images xfs defaults 0 0
-<code> +
-[root@centos8 tmp]groups trainee +
-trainee : trainee +
-[root@centos8 tmp]# usermod -aG adm trainee +
-[root@centos8 tmp]# groups trainee +
-trainee : trainee adm+
 </code> </code>
  
-Pour générer les clefs du serveur, saisissez la commande suivante en tant que **root**. Notez que la passphrase doit être **vide**.+Montez ensuite le volume logique :
  
 <code> <code>
-[root@centos8 tmp]# ssh-keygen -t dsa +[root@centos8 ~]# df -h 
-Generating public/private dsa key pair. +Filesystem                   Size  Used Avail Use% Mounted on 
-Enter file in which to save the key (/root/.ssh/id_dsa):  +devtmpfs                     1.8G      1.8G   0% /dev 
-Created directory '/root/.ssh'. +tmpfs                        1.9G      1.9G   0% /dev/shm 
-Enter passphrase (empty for no passphrase):  +tmpfs                        1.9G  9.5M  1.9G   1% /run 
-Enter same passphrase again:  +tmpfs                        1.9G      1.9G   0% /sys/fs/cgroup 
-Your identification has been saved in /root/.ssh/id_dsa. +/dev/mapper/cl_centos8-root   28G   17G   12G  58% / 
-Your public key has been saved in /root/.ssh/id_dsa.pub. +/dev/sda1                    976M  453M  457M  50% /boot 
-The key fingerprint is: +/dev/sdc1                     63G   22G   39G  36% /home 
-SHA256:dywC6jKyIMaTxsaEamz1kmthEmuG18HxmS22qRICOYk root@centos8.ittraining.loc +tmpfs                        374M   20K  374M   1% /run/user/1000 
-The key's randomart image is: +tmpfs                        374M  1.2M  373M   1% /run/user/42
-+---[DSA 1024]----+ +
-|                 | +
-|    .            | +
-|.o . o.+         | +
-|E.  o.*..  .     | +
-|+ooo.o +S o o    | +
-|X==++ o  o o     | +
-|B/=+oo           | +
-|Ooo++            | +
-|.o             | +
-+----[SHA256]-----+ +
-</code>+
  
-Le chemin à indiquer pour le fichier est **/etc/ssh/ssh_host_dsa_key**. +[root@centos8 ~]# mount -a
  
-De la même façon, il est possible de générer les clefs au format **[[https://fr.wikipedia.org/wiki/Chiffrement_RSA|RSA]]**, **[[https://fr.wikipedia.org/wiki/Elliptic_curve_digital_signature_algorithm|ECDSA]]** et **[[https://fr.wikipedia.org/wiki/EdDSA|ED25519]]** : +[root@centos8 ~]# df -h 
- +Filesystem                      Size  Used Avail Use% Mounted on 
-<code> +devtmpfs                        1.8G      1.8G   0% /dev 
-[root@centos8 tmp]# ssh-keygen -t rsa +tmpfs                           1.9G      1.9G   0% /dev/shm 
-Generating public/private rsa key pair. +tmpfs                           1.9G  9.5M  1.9G   1% /run 
-Enter file in which to save the key (/root/.ssh/id_rsa):  +tmpfs                           1.9G      1.9G   0% /sys/fs/cgroup 
-Enter passphrase (empty for no passphrase):  +/dev/mapper/cl_centos8-root      28G   17G   12G  58% 
-Enter same passphrase again:  +/dev/sda1                       976M  453M  457M  50% /boot 
-Your identification has been saved in /root/.ssh/id_rsa. +/dev/sdc1                        63G   22G   39G  36/home 
-Your public key has been saved in /root/.ssh/id_rsa.pub. +tmpfs                           374M   20K  374M   1% /run/user/1000 
-The key fingerprint is: +tmpfs                           374M  1.2M  373M   1% /run/user/42 
-SHA256:8jXFK50NnoJCz9E7aPKpFYSYCstCPfRsdmlLBTNUnKg root@centos8.ittraining.loc +/dev/mapper/kvm_storage-kvm_lv   32G  261M   32G   1% /var/lib/libvirt/images
-The key's randomart image is: +
-+---[RSA 3072]----+ +
-|   .  .==o.      | +
- o oo o=+     | +
-|.. oo=+=o . +    | +
-|oo .+E++.+ = *   | +
-|o..   +.S B * .  | +
-|.      B + =     | +
-|        =        | +
-|               | +
-|      .          | +
-+----[SHA256]-----+ +
-[root@centos8 tmp]# ssh-keygen -t ecdsa +
-Generating public/private ecdsa key pair. +
-Enter file in which to save the key (/root/.ssh/id_ecdsa):  +
-Enter passphrase (empty for no passphrase):  +
-Enter same passphrase again:  +
-Your identification has been saved in /root/.ssh/id_ecdsa. +
-Your public key has been saved in /root/.ssh/id_ecdsa.pub. +
-The key fingerprint is: +
-SHA256:AMqFUJKGqnUEPh/IYda0wnbW1kXK+lnprpHsOo4UMbI root@centos8.ittraining.loc +
-The key's randomart image is: +
-+---[ECDSA 256]---+ +
-|++*=+    .o      | +
-|oX.=o+ o o       | +
-|o %.B + +        | +
-|...O.= o   .     | +
-|..E.o . S o      | +
-|.    . o =       | +
-|    .   * .      | +
-|   . ... o       | +
-|    ..ooo..      | +
-+----[SHA256]-----+ +
-[root@centos8 tmp]# ssh-keygen -t ed25519 +
-Generating public/private ed25519 key pair. +
-Enter file in which to save the key (/root/.ssh/id_ed25519):  +
-Enter passphrase (empty for no passphrase):  +
-Enter same passphrase again:  +
-Your identification has been saved in /root/.ssh/id_ed25519. +
-Your public key has been saved in /root/.ssh/id_ed25519.pub. +
-The key fingerprint is: +
-SHA256:CtbcN9iXv00PfbHFGf2bEW7iRibOFwRctyqM5hmlhwE root@centos8.ittraining.loc +
-The key's randomart image is: +
-+--[ED25519 256]--+ +
-|        .... . | +
-|        .  .. . o| +
-|         . . . +.| +
-|     o . oB ..o.=| +
-|    o o S*+=o* *+| +
-  . . .o.*o*.+.B| +
-|      .  o o +o++| +
-|            o  =o| +
-|              . o| +
-+----[SHA256]-----++
 </code> </code>
  
-Les clefs publiques générées possèdent l'extension **.pub**. Les clefs privées n'ont pas d'extension :+Notez que ce volume est actuellement vide :
  
 <code> <code>
-[root@centos8 tmp]# ls /etc/ssh +[root@centos8 ~]# ls -l /var/lib/libvirt/images
-moduli      ssh_config.d  sshd_config.old     ssh_host_ecdsa_key.pub  ssh_host_ed25519_key.pub  ssh_host_rsa_key.pub +total 0
-ssh_config  sshd_config   ssh_host_ecdsa_key  ssh_host_ed25519_key    ssh_host_rsa_key+
 </code> </code>
  
-Re-démarrez ensuite le service sshd :+Utilisez la commande **virsh pool-list** pour voir les pools de stockage déjà configurés. Cette liste devrait être vide :
  
 <code> <code>
-[root@centos8 tmp]# systemctl restart sshd.service +[root@centos8 ~]# virsh pool-list 
-[root@centos8 tmp]# systemctl status sshd.service + Name   State   Autostart 
-● sshd.service OpenSSH server daemon +---------------------------
-   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) +
-   Active: active (running) since Mon 2021-08-30 02:24:57 EDT; 9s ago +
-     Docs: man:sshd(8) +
-           man:sshd_config(5) +
- Main PID: 1042204 (sshd) +
-    Tasks: 1 (limit: 23535) +
-   Memory: 1.1M +
-   CGroup: /system.slice/sshd.service +
-           └─1042204 /usr/sbin/sshd --oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,a>+
  
-Aug 30 02:24:57 centos8.ittraining.loc systemd[1]: Starting OpenSSH server daemon... 
-Aug 30 02:24:57 centos8.ittraining.loc sshd[1042204]: Server listening on 0.0.0.0 port 22. 
-Aug 30 02:24:57 centos8.ittraining.loc sshd[1042204]: Server listening on :: port 22. 
-Aug 30 02:24:57 centos8.ittraining.loc systemd[1]: Started OpenSSH server daemon. 
-[q] 
 </code> </code>
  
-===Configuration du Client=== +Définissez le pool de stockage **kvm-storagepool** dans KVM grâce à la commande **virsh pool-define-as** :
- +
-Saisissez maintenant les commandes suivantes en tant que **trainee** +
- +
-<WRAP center round important> +
-**Important** - Lors de la génération des clefs, la passphrase doit être **vide**. +
-</WRAP>+
  
 <code> <code>
-[root@centos8 tmp]# exit +[root@centos8 ~]# virsh pool-define-as kvm-storagepool --type=dir --target /var/lib/libvirt/images
-logout +Pool kvm-storagepool defined
-[trainee@centos8 ~]$ ssh-keygen -t dsa +
-Generating public/private dsa key pair. +
-Enter file in which to save the key (/home/trainee/.ssh/id_dsa):  +
-Created directory '/home/trainee/.ssh'+
-Enter passphrase (empty for no passphrase):  +
-Enter same passphrase again:  +
-Your identification has been saved in /home/trainee/.ssh/id_dsa. +
-Your public key has been saved in /home/trainee/.ssh/id_dsa.pub. +
-The key fingerprint is: +
-SHA256:Qd17X1iROjk5rLOQBbyVg1hNXkUdTeiFtEpn3rgPKc4 trainee@centos8.ittraining.loc +
-The key's randomart image is: +
-+---[DSA 1024]----+ +
-|        =o+o.o+OB| +
-|       o +o=o oo=| +
-|        . +.+oB+ | +
-|         o o.&+o.| +
-|        S o o.*.o| +
-|         o o   o.| +
-|          . + +  | +
-|           + . o | +
-|            E   .| +
-+----[SHA256]-----+ +
-[trainee@centos8 ~]$ ssh-keygen -t rsa +
-Generating public/private rsa key pair. +
- +
-Enter file in which to save the key (/home/trainee/.ssh/id_rsa): Enter passphrase (empty for no passphrase):  +
-Enter same passphrase again:  +
-Your identification has been saved in /home/trainee/.ssh/id_rsa. +
-Your public key has been saved in /home/trainee/.ssh/id_rsa.pub. +
-The key fingerprint is: +
-SHA256:BgEjoWQrGCzdJfyZczVZYVoafiHsz9GK5PDWuywG/z0 trainee@centos8.ittraining.loc +
-The key's randomart image is: +
-+---[RSA 3072]----+ +
-|o+o++oo  .oo*.   | +
-|=+o.oo . .=B .   | +
-|=.   ..o o+...   | +
-|.     =.o o.. .  | +
-|       oS= = o   | +
-|       .. = =    | +
-|             | +
-|          +...E  | +
-|         . o+... | +
-+----[SHA256]-----+ +
-[trainee@centos8 ~]$ ssh-keygen -t ecdsa +
-Generating public/private ecdsa key pair. +
-Enter file in which to save the key (/home/trainee/.ssh/id_ecdsa):  +
-Enter passphrase (empty for no passphrase):  +
-Enter same passphrase again:  +
-Your identification has been saved in /home/trainee/.ssh/id_ecdsa. +
-Your public key has been saved in /home/trainee/.ssh/id_ecdsa.pub. +
-The key fingerprint is: +
-SHA256:mpBDgsCxP2DqRPkmGvXHpNnvm5B+Cl7MSiiZKfDjWLk trainee@centos8.ittraining.loc +
-The key's randomart image is: +
-+---[ECDSA 256]---+ +
-|o..              | +
-|.oo              | +
-|.*o . .          | +
-|+.++ B           | +
-|+o =B + S        | +
-|=*oo.* =         | +
-|B.* o O .        | +
-|.= = = o..       | +
-|. E o oo+.       | +
-+----[SHA256]-----+ +
-[trainee@centos8 ~]$ ssh-keygen -t ed25519 +
-Generating public/private ed25519 key pair. +
-Enter file in which to save the key (/home/trainee/.ssh/id_ed25519):  +
-Enter passphrase (empty for no passphrase):  +
-Enter same passphrase again:  +
-Your identification has been saved in /home/trainee/.ssh/id_ed25519. +
-Your public key has been saved in /home/trainee/.ssh/id_ed25519.pub. +
-The key fingerprint is: +
-SHA256:JfFxG2mg9feAvFGxoxZ8uSsON3sXvtYQYYg5iVxzZS4 trainee@centos8.ittraining.loc +
-The key's randomart image is: +
-+--[ED25519 256]--+ +
-|       ..o*=++=. | +
-|        o==O+Boo | +
-|        o ooE.O. | +
-|           O.= | +
-|        S   + ...| +
-|            .o | +
-|          . + o.o| +
-|           + +.oo| +
-|            o..o.| +
-+----[SHA256]-----++
 </code> </code>
  
-Les clés générées seront placées dans le répertoire **~/.ssh/** : +<WRAP center round important 60%> 
- +**Important** : Consultez **[[https://libvirt.org/storage.html#StorageBackendDir|cette page]]** pour connaître les types de pool utilisés par libvirt.
-<code> +
-[trainee@centos8 ~]$ ls .ssh +
-id_dsa  id_dsa.pub  id_ecdsa  id_ecdsa.pub  id_ed25519  id_ed25519.pub  id_rsa  id_rsa.pub +
-</code> +
- +
-===Tunnels SSH=== +
- +
-Le protocole SSH peut être utilisé pour sécuriser les protocoles tels telnet, pop3 etc.. En effet, on peut créer un //tunnel// SSH dans lequel passe les communications du protocole non-sécurisé. +
- +
-La commande pour créer un tunnel ssh prend la forme suivante : +
- +
-  ssh -N -f compte@hôte -Lport-local:localhost:port_distant +
- +
-Dans votre cas, vous allez créer un tunnel dans votre propre vm entre le port 15023 et le port 23 : +
- +
-<code> +
-[root@centos8 ~]# ssh -N -f trainee@localhost -L15023:localhost:23 +
-\S +
-Kernel \r on an \m +
-trainee@localhost's password: trainee +
-</code> +
- +
-Installez maintenant le serveur telnet : +
- +
-<code> +
-[root@centos8 ~]# dnf install telnet-server +
-</code> +
- +
-Telnet n'est ni démarré ni activéIl convient donc de le démarrer et de l'activer : +
- +
-<code> +
-[root@centos8 ~]# systemctl status telnet.socket +
-● telnet.socket - Telnet Server Activation Socket +
-   Loaded: loaded (/usr/lib/systemd/system/telnet.socket; disabled; vendor preset: disabled) +
-   Active: inactive (dead) +
-     Docs: man:telnetd(8) +
-   Listen: [::]:23 (Stream) +
- Accepted: 0; Connected: 0; +
-  +
-[root@centos8 ~]systemctl start telnet.socket +
- +
-[root@centos8 ~]# systemctl status telnet.socket +
-● telnet.socket - Telnet Server Activation Socket +
-   Loaded: loaded (/usr/lib/systemd/system/telnet.socket; disabled; vendor preset: disabled) +
-   Active: active (listening) since Mon 2021-08-30 02:44:01 EDT; 4s ago +
-     Docs: man:telnetd(8) +
-   Listen: [::]:23 (Stream) +
- Accepted: 0; Connected: 0; +
-   CGroup: /system.slice/telnet.socket +
- +
-Aug 30 02:44:01 centos8.ittraining.loc systemd[1]: Listening on Telnet Server Activation Socket. +
- +
-[root@centos8 ~]# systemctl enable telnet.socket +
-Created symlink /etc/systemd/system/sockets.target.wants/telnet.socket → /usr/lib/systemd/system/telnet.socket. +
-</code> +
- +
-Connectez-vous ensuite via telnet sur le port 15023, vous constaterez que votre connexion n'aboutit pas : +
- +
-<code> +
-[root@centos8 ~]# telnet localhost 15023 +
-Trying ::1... +
-Connected to localhost. +
-Escape character is '^]'+
- +
-Kernel 4.18.0-305.7.1.el8.i2tch.x86_64 on an x86_64 +
-centos8 login: trainee +
-Password:  +
-Last login: Mon Aug 30 02:37:00 from ::1 +
-[trainee@centos8 ~]$ whoami +
-trainee +
-[trainee@centos8 ~]$ pwd +
-/home/trainee +
-</code> +
- +
-<WRAP center round important> +
-**Important** - Notez bien que votre communication telnet passe par le tunnel SSH.+
 </WRAP> </WRAP>
  
-====3.5 - SCP====+Consultez **[[https://libvirt.org/storage.html#StorageBackendDir|cette page]]** pour connaître les types de pool utilisés par libvirt.
  
-===Présentation=== +Démarrez maintenant le pool **kvm-storagepool** :
- +
-La commande **scp** est le successeur et la remplaçante de la commande **rcp** de la famille des commandes **remote**. Il permet de faire des transferts sécurisés à partir d'une machine distante : +
- +
-  $ scp compte@numero_ip(nom_de_machine):/chemin_distant/fichier_distant /chemin_local/fichier_local +
- +
-ou vers une machine distante : +
- +
-  $ scp /chemin_local/fichier_local compte@numero_ip(nom_de_machine):/chemin_distant/fichier_distant +
- +
-===Utilisation=== +
- +
-Nous allons maintenant utiliser **scp** pour chercher un fichier sur le <<serveur>>+
- +
-Créez le fichier **/home/trainee/scp_test** :+
  
 <code> <code>
-[trainee@centos8 ~]$ touch scp-test +[root@centos8 ~]# virsh pool-start kvm-storagepool 
-[trainee@centos8 ~]$ exit +Pool kvm-storagepool started
-logout +
-Connection closed by foreign host. +
-[root@centos8 ~]# +
 </code> </code>
  
-Récupérez le fichier **scp_test** en utilisant scp :+Contrôlez l'état du pool **kvm-storagepool** :
  
 <code> <code>
-[root@centos8 ~]# scp trainee@127.0.0.1:/home/trainee/scp-test . +[root@centos8 ~]# virsh pool-list 
-The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established. + Name              State    Autostart 
-ECDSA key fingerprint is SHA256:Q7T/CP0SLiMbMAIgVzTuEHegYS/spPE5zzQchCHD5Vw. +--------------------------------------- 
-Are you sure you want to continue connecting (yes/no/[fingerprint])? yes + kvm-storagepool   active   no
-Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts. +
-\S +
-Kernel \r on an \m +
-trainee@127.0.0.1's password: trainee +
-scp-test                                                                                                           100%    0     0.0KB/  00:00     +
- +
-[root@centos8 ~]# ls -+
-total 32 +
--rw-------. 1 root root 1358 Jun 16 06:40 anaconda-ks.cfg +
-drwxr-xr-x. 3 root root   21 Jun 16 06:39 home +
--rw-r--r--. 1 root root 1749 Aug 24 11:20 I2TCH.asc +
--rw-r--r--. 1 root root 1853 Jun 16 06:54 initial-setup-ks.cfg +
--rw-r--r--. 1 root root   31 Aug 24 11:22 message.txt +
--rw-r--r--. 1 root root  561 Aug 24 11:32 message.txt.asc +
--rw-r--r--. 1 root root  367 Aug 24 11:30 message.txt.gpg +
--rw-r--r--. 1 root root  329 Aug 24 11:23 message.txt.sig +
--rw-r--r--. 1 root root    0 Aug 30 03:55 scp-test +
--rw-r--r--. 1 root root   46 Aug 29 06:22 wget_file.txt +
-</code> +
- +
-====3.6 - Mise en Place des Clefs Asymétriques==== +
- +
-Il convient maintenant de se connecter sur le <<serveur>> en utilisant ssh et vérifiez la présence du répertoire ~/.ssh : +
- +
-<code> +
-[root@centos8 ~]# ssh -l trainee 127.0.0.1 +
-\S +
-Kernel \r on an \m +
-trainee@127.0.0.1's password: trainee +
-Activate the web console with: systemctl enable --now cockpit.socket +
- +
-[trainee@centos8 ~]$ ls -la | grep .ssh +
-drwx------.  2 trainee trainee      4096 Aug 30 02:26 .ssh+
 </code> </code>
  
-<WRAP center round important> +<WRAP center round important 60%
-**Important** - Si le dossier distant .ssh n'existe pas dans le répertoire personnel de l'utilisateur connecté, il faut le créer avec des permissions de 700. Dans votre cas, puisque votre machine joue le rôle de serveur **et** du client, le dossier /home/trainee/.ssh existe **déjà**.+**Important** : Notez que le pool ne sera pas démarré automatiquement parce que la valeur d**'autostart** est **no**.
 </WRAP> </WRAP>
  
-Ensuite, il convient de transférer le fichier local **.ssh/id_ecdsa.pub** du <<client>> vers le <<serveur>> en le renommant en **authorized_keys** :+Fixez la valeur d'autostart à **yes** grâce à la commande **virsh pool-autostart** :
  
 <code> <code>
-[trainee@centos8 ~]$ exit +[root@centos8 ~]# virsh pool-autostart kvm-storagepool 
-logout +Pool kvm-storagepool marked as autostarted
-Connection to 127.0.0.1 closed.+
  
-[root@centos8 ~]# exit +[root@centos8 ~]# virsh pool-list 
-logout + Name              State    Autostart 
- +--------------------------------------- 
-[trainee@centos8 ~]$ scp .ssh/id_ecdsa.pub trainee@127.0.0.1:/home/trainee/.ssh/authorized_keys + kvm-storagepool   active   yes
-The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established. +
-ECDSA key fingerprint is SHA256:Q7T/CP0SLiMbMAIgVzTuEHegYS/spPE5zzQchCHD5Vw. +
-Are you sure you want to continue connecting (yes/no/[fingerprint])? yes +
-Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts. +
-\S +
-Kernel \r on an \m +
-trainee@127.0.0.1's password: trainee +
-id_ecdsa.pub                                                                                                       100%  192   497.6KB/  00:00+
 </code> </code>
  
-Connectez-vous via telnet :+Dernièrement, constatez les détails du pool configuré :
  
 <code> <code>
-[trainee@centos8 ~]$ ssh -l trainee localhost +[root@centos8 ~]# virsh pool-list --all --details 
-The authenticity of host 'localhost (::1)' can't be established. + Name              State     Autostart   Persistent   Capacity    Allocation   Available 
-ECDSA key fingerprint is SHA256:Q7T/CP0SLiMbMAIgVzTuEHegYS/spPE5zzQchCHD5Vw. +------------------------------------------------------------------------------------------ 
-Are you sure you want to continue connecting (yes/no/[fingerprint])? yes + kvm-storagepool   running   yes         yes          31.98 GiB   260.61 MiB   31.73 GiB
-Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. +
-\S +
-Kernel \r on an \m +
-Activate the web console with: systemctl enable --now cockpit.socket +
- +
-Last login: Mon Aug 30 03:57:14 2021 from 127.0.0.+
-[trainee@centos8 ~]$+
 </code> </code>
- 
-<WRAP center round important> 
-**Important** - Lors de la connexion au serveur, l'authentification utilise le couple de clefs asymétrique au format ecdsa et aucun mot de passe n'est requis. 
-</WRAP> 
- 
-Insérez maintenant les clefs publiques restantes dans le fichier .ssh/authorized_keys : 
  
 <code> <code>
-[trainee@centos8 ~]$ cd .ssh +[root@centos8 ~]# df -/var/lib/libvirt/images
-[trainee@centos8 .ssh]$ ls +Filesystem                      Size  Used Avail Use% Mounted on 
-authorized_keys  id_dsa  id_dsa.pub  id_ecdsa  id_ecdsa.pub  id_ed25519  id_ed25519.pub  id_rsa  id_rsa.pub  known_hosts +/dev/mapper/kvm_storage-kvm_lv   32G  261M   32G   1% /var/lib/libvirt/images
-[trainee@centos8 .ssh]$ cat authorized_keys  +
-ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHDrzSXP+Ecxf/sQ18VwCRNm7rrSrrsaJmuIw/RgTH5puKF5E+Yy15cvAAKBXpJPxUmrOaOyhab84PevV7XSHcI= trainee@centos8.ittraining.loc +
- +
-[trainee@centos8 .ssh]$ cat id_rsa.pub >> authorized_keys +
-[trainee@centos8 .ssh]$ cat id_dsa.pub >> authorized_keys +
-[trainee@centos8 .ssh]$ cat id_ed25519.pub >> authorized_keys +
- +
-[trainee@centos8 .ssh]$ cat authorized_keys +
-ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHDrzSXP+Ecxf/sQ18VwCRNm7rrSrrsaJmuIw/RgTH5puKF5E+Yy15cvAAKBXpJPxUmrOaOyhab84PevV7XSHcI= trainee@centos8.ittraining.loc +
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD3ZSMn/GIAHtaDFc6ZNnKJam9hzq8TxqMN5IopUr8QhwODyPadbB+FgH4r50qTux4ubwr1BlymgIdqRVWy32mE15M8tdtKc3j8DNMpUwPGEh+s/PT7GW+3E3shoyPvpLc1kKaKXKGl/JwfCK/8IYsubk2BmiiJYkzLECotPlaaxm4w1K0AtlnZQuLHt1HK3/rHChxo2o2w1t59/QwNcMLiKve1Z+zQ1POKo8VJ/DDrf90y2QWC28ejUs/ZjP6f6C4bn5Jjol4TbHls3ArMsbU6C1Ev5jqbzZ0kmognQ2CnRjeNM51YdFo6nRsLoPQKpeLRMBpT/87HK1bPUOBVCyhXxSkqkVhMlgg8tgcD/MRlBaUVFoZ1wQ0L26Fe+q7c2Oykj54pdXCAK2ZTpCXGfhd/FxrfqGw7cSeKlGX4QUzHMjMk2oHFC9h30BUk1gGN21KJPTh7/S1OZVrnCc3GUi5fXPvEpral0IU0sws+j03dj0sWm5ICQFKRkmZN11HCyT0= trainee@centos8.ittraining.loc +
-ssh-dss AAAAB3NzaC1kc3MAAACBALIdwEEqHrMWSUdzARm9ldsZK9ebbtZShtmwgdjphOk77fxymK0y6wV7QEmLL25LOcLb12uZ1F0LtRt/t2oqgrwqk3vUSpCPLr09AXpcD/nxL9kc+rUxHyl6u1mHtyfCVLCPSvavCMR8TaA8egVMk3EwGRfHTiuDOKi7Iwus7gXPAAAAFQDHEQPGVRI7gVYKzCT6nrjDsQQ6jwAAAIEAhhhH7fEjdldASXY0qTWkCvcs3cfK9/Ff315zByn47O02y9Vdo3QG5nOr1Oo8fc2xEkIBNmFr8Rr2g60cpvEev5hy4XZ1ghxnQ53iwKuiS72ZATwhD6bZBrsiH0k1Et25gRcj5KCvDe/jHhbxCxsCuHUH2qvWsQNVwztE7hD0sxkAAACAQ8Dkpy8zXj7jW8o1txxf2W6J4r2+1lPldymA45ywZokN4SCwvXlpPAuyBt0/HiU0R2PI9aqOAMosCLcy9WmnSwLQ2Z7QcD2i3XlAih2+1q9NJP22sPT3jSK9UZcdRjoZ/eNiz84sXZucNape32tFxjvcV4txobH/vD53q8g63fA= trainee@centos8.ittraining.loc +
-ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOfFQULLU8IZyKiSU63D2Zz6yGLqyHcBHnCRdSR9JSmc trainee@centos8.ittraining.loc+
 </code> </code>
- 
-=====LAB #4 - La Configuration de firewalld===== 
- 
-====4.1 - Présentation==== 
- 
-firewalld utilise **[[https://wiki.nftables.org/wiki-nftables/index.php/Main_Page|nftables]]** en tant que **//backend//**. firewalld utilise des **zones** - des jeux de règles pré-définis dans lesquels sont placés les interfaces : 
- 
-  * **trusted** - un réseau fiable. Dans ce cas tous les ports sont autorisés, 
-  * **work**, **home**, **internal** - un réseau partiellement fiable. Dans ce cas quelques ports sont autorisés, 
-  * **dmz**, **public**, **external** - un réseau non fiable. Dans ce cas peu de ports sont autorisés, 
-  * **block**, **drop** - tout est interdit. La zone drop n'envoie pas de messages d'erreurs. 
- 
-<WRAP center round important> 
-**Important** - Une interface ne peut être que dans une zone à la fois tandis que plusieurs interfaces peuvent être dans la même zone. 
-</WRAP> 
- 
-Le service firewalld doit toujours être lancé : 
- 
-<code> 
-[trainee@centos8 .ssh]$ exit 
-logout 
-Connection to localhost closed. 
-[trainee@centos8 ~]$ su -  
-Password: fenestros  
- 
-[root@centos8 ~]# systemctl status firewalld 
-● firewalld.service - firewalld - dynamic firewall daemon 
-   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) 
-   Active: inactive (dead) since Thu 2021-07-22 06:14:27 EDT; 1 months 8 days ago 
-     Docs: man:firewalld(1) 
- Main PID: 960 (code=exited, status=0/SUCCESS) 
- 
-Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable. 
- 
-[root@centos8 ~]# systemctl start firewalld 
-[root@centos8 ~]# systemctl status firewalld 
-● firewalld.service - firewalld - dynamic firewall daemon 
-   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) 
-   Active: active (running) since Mon 2021-08-30 04:13:51 EDT; 10s ago 
-     Docs: man:firewalld(1) 
- Main PID: 1045271 (firewalld) 
-    Tasks: 2 (limit: 23535) 
-   Memory: 28.7M 
-   CGroup: /system.slice/firewalld.service 
-           └─1045271 /usr/libexec/platform-python -s /usr/sbin/firewalld --nofork --nopid 
- 
-Aug 30 04:13:49 centos8.ittraining.loc systemd[1]: Starting firewalld - dynamic firewall daemon... 
-Aug 30 04:13:51 centos8.ittraining.loc systemd[1]: Started firewalld - dynamic firewall daemon. 
-Aug 30 04:13:51 centos8.ittraining.loc firewalld[1045271]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration optio> 
-[q] 
-</code> 
- 
-====4.2 - La Configuration de Base de firewalld==== 
- 
-La configuration par défaut de firewalld se trouve dans **/usr/lib/firewalld** : 
- 
-<code> 
-[root@centos8 ~]# ls -l /usr/lib/firewalld/ 
-total 16 
-drwxr-xr-x. 2 root root  224 Jul 19 10:39 helpers 
-drwxr-xr-x. 2 root root 4096 Jul 19 10:39 icmptypes 
-drwxr-xr-x. 2 root root   20 Jul 19 10:39 ipsets 
-drwxr-xr-x. 2 root root 8192 Jul 19 10:39 services 
-drwxr-xr-x. 2 root root  203 Jul 19 10:39 zones 
- 
-[root@centos8 ~]# ls -l /usr/lib/firewalld/helpers/ 
-total 52 
--rw-r--r--. 1 root root 125 Jun 29 13:27 amanda.xml 
--rw-r--r--. 1 root root 119 Jun 29 13:27 ftp.xml 
--rw-r--r--. 1 root root  85 Jun 29 13:27 h323.xml 
--rw-r--r--. 1 root root 134 Jun 29 13:27 irc.xml 
--rw-r--r--. 1 root root 141 Jun 29 13:27 netbios-ns.xml 
--rw-r--r--. 1 root root 136 Jun 29 13:27 pptp.xml 
--rw-r--r--. 1 root root  90 Jun 29 13:27 proto-gre.xml 
--rw-r--r--. 1 root root 122 Jun 29 13:27 Q.931.xml 
--rw-r--r--. 1 root root 122 Jun 29 13:27 RAS.xml 
--rw-r--r--. 1 root root 122 Jun 29 13:27 sane.xml 
--rw-r--r--. 1 root root 158 Jun 29 13:27 sip.xml 
--rw-r--r--. 1 root root 135 Jun 29 13:27 snmp.xml 
--rw-r--r--. 1 root root 120 Jun 29 13:27 tftp.xml 
- 
-[root@centos8 ~]# ls -l /usr/lib/firewalld/icmptypes/ 
-total 180 
--rw-r--r--. 1 root root 385 Jun 29 13:27 address-unreachable.xml 
--rw-r--r--. 1 root root 258 Jun 29 13:27 bad-header.xml 
--rw-r--r--. 1 root root 294 Jun 29 13:27 beyond-scope.xml 
--rw-r--r--. 1 root root 279 Jun 29 13:27 communication-prohibited.xml 
--rw-r--r--. 1 root root 222 Jun 29 13:27 destination-unreachable.xml 
--rw-r--r--. 1 root root 173 Jun 29 13:27 echo-reply.xml 
--rw-r--r--. 1 root root 210 Jun 29 13:27 echo-request.xml 
--rw-r--r--. 1 root root 261 Jun 29 13:27 failed-policy.xml 
--rw-r--r--. 1 root root 280 Jun 29 13:27 fragmentation-needed.xml 
--rw-r--r--. 1 root root 266 Jun 29 13:27 host-precedence-violation.xml 
--rw-r--r--. 1 root root 257 Jun 29 13:27 host-prohibited.xml 
--rw-r--r--. 1 root root 242 Jun 29 13:27 host-redirect.xml 
--rw-r--r--. 1 root root 239 Jun 29 13:27 host-unknown.xml 
--rw-r--r--. 1 root root 247 Jun 29 13:27 host-unreachable.xml 
--rw-r--r--. 1 root root 229 Jun 29 13:27 ip-header-bad.xml 
--rw-r--r--. 1 root root 355 Jun 29 13:27 neighbour-advertisement.xml 
--rw-r--r--. 1 root root 457 Jun 29 13:27 neighbour-solicitation.xml 
--rw-r--r--. 1 root root 250 Jun 29 13:27 network-prohibited.xml 
--rw-r--r--. 1 root root 248 Jun 29 13:27 network-redirect.xml 
--rw-r--r--. 1 root root 239 Jun 29 13:27 network-unknown.xml 
--rw-r--r--. 1 root root 247 Jun 29 13:27 network-unreachable.xml 
--rw-r--r--. 1 root root 239 Jun 29 13:27 no-route.xml 
--rw-r--r--. 1 root root 328 Jun 29 13:27 packet-too-big.xml 
--rw-r--r--. 1 root root 225 Jun 29 13:27 parameter-problem.xml 
--rw-r--r--. 1 root root 233 Jun 29 13:27 port-unreachable.xml 
--rw-r--r--. 1 root root 256 Jun 29 13:27 precedence-cutoff.xml 
--rw-r--r--. 1 root root 249 Jun 29 13:27 protocol-unreachable.xml 
--rw-r--r--. 1 root root 185 Jun 29 13:27 redirect.xml 
--rw-r--r--. 1 root root 244 Jun 29 13:27 reject-route.xml 
--rw-r--r--. 1 root root 241 Jun 29 13:27 required-option-missing.xml 
--rw-r--r--. 1 root root 227 Jun 29 13:27 router-advertisement.xml 
--rw-r--r--. 1 root root 223 Jun 29 13:27 router-solicitation.xml 
--rw-r--r--. 1 root root 248 Jun 29 13:27 source-quench.xml 
--rw-r--r--. 1 root root 236 Jun 29 13:27 source-route-failed.xml 
--rw-r--r--. 1 root root 253 Jun 29 13:27 time-exceeded.xml 
--rw-r--r--. 1 root root 233 Jun 29 13:27 timestamp-reply.xml 
--rw-r--r--. 1 root root 228 Jun 29 13:27 timestamp-request.xml 
--rw-r--r--. 1 root root 258 Jun 29 13:27 tos-host-redirect.xml 
--rw-r--r--. 1 root root 257 Jun 29 13:27 tos-host-unreachable.xml 
--rw-r--r--. 1 root root 272 Jun 29 13:27 tos-network-redirect.xml 
--rw-r--r--. 1 root root 269 Jun 29 13:27 tos-network-unreachable.xml 
--rw-r--r--. 1 root root 293 Jun 29 13:27 ttl-zero-during-reassembly.xml 
--rw-r--r--. 1 root root 256 Jun 29 13:27 ttl-zero-during-transit.xml 
--rw-r--r--. 1 root root 259 Jun 29 13:27 unknown-header-type.xml 
--rw-r--r--. 1 root root 249 Jun 29 13:27 unknown-option.xml 
- 
-[root@centos8 ~]# ls -l /usr/lib/firewalld/ipsets 
-total 4 
--rw-r--r--. 1 root root 29 Jun 29 13:27 README 
- 
-[root@centos8 ~]# ls -l /usr/lib/firewalld/services/ 
-total 688 
--rw-r--r--. 1 root root  399 Jun 29 13:27 amanda-client.xml 
--rw-r--r--. 1 root root  427 Jun 29 13:27 amanda-k5-client.xml 
--rw-r--r--. 1 root root  283 Jun 29 13:27 amqps.xml 
--rw-r--r--. 1 root root  273 Jun 29 13:27 amqp.xml 
--rw-r--r--. 1 root root  285 Jun 29 13:27 apcupsd.xml 
--rw-r--r--. 1 root root  301 Jun 29 13:27 audit.xml 
--rw-r--r--. 1 root root  320 Jun 29 13:27 bacula-client.xml 
--rw-r--r--. 1 root root  346 Jun 29 13:27 bacula.xml 
--rw-r--r--. 1 root root  429 Jun 29 13:27 bb.xml 
--rw-r--r--. 1 root root  339 Jun 29 13:27 bgp.xml 
--rw-r--r--. 1 root root  275 Jun 29 13:27 bitcoin-rpc.xml 
--rw-r--r--. 1 root root  307 Jun 29 13:27 bitcoin-testnet-rpc.xml 
--rw-r--r--. 1 root root  281 Jun 29 13:27 bitcoin-testnet.xml 
--rw-r--r--. 1 root root  244 Jun 29 13:27 bitcoin.xml 
--rw-r--r--. 1 root root  410 Jun 29 13:27 bittorrent-lsd.xml 
--rw-r--r--. 1 root root  294 Jun 29 13:27 ceph-mon.xml 
--rw-r--r--. 1 root root  329 Jun 29 13:27 ceph.xml 
--rw-r--r--. 1 root root  168 Jun 29 13:27 cfengine.xml 
--rw-r--r--. 1 root root  211 Jun 29 13:27 cockpit.xml 
--rw-r--r--. 1 root root  296 Jun 29 13:27 collectd.xml 
--rw-r--r--. 1 root root  260 Jun 29 13:27 condor-collector.xml 
--rw-r--r--. 1 root root  296 Jun 29 13:27 ctdb.xml 
--rw-r--r--. 1 root root  305 Jun 29 13:27 dhcpv6-client.xml 
--rw-r--r--. 1 root root  234 Jun 29 13:27 dhcpv6.xml 
--rw-r--r--. 1 root root  227 Jun 29 13:27 dhcp.xml 
--rw-r--r--. 1 root root  205 Jun 29 13:27 distcc.xml 
--rw-r--r--. 1 root root  318 Jun 29 13:27 dns-over-tls.xml 
--rw-r--r--. 1 root root  346 Jun 29 13:27 dns.xml 
--rw-r--r--. 1 root root  374 Jun 29 13:27 docker-registry.xml 
--rw-r--r--. 1 root root  391 Jun 29 13:27 docker-swarm.xml 
--rw-r--r--. 1 root root  228 Jun 29 13:27 dropbox-lansync.xml 
--rw-r--r--. 1 root root  338 Jun 29 13:27 elasticsearch.xml 
--rw-r--r--. 1 root root  304 Jun 29 13:27 etcd-client.xml 
--rw-r--r--. 1 root root  304 Jun 29 13:27 etcd-server.xml 
--rw-r--r--. 1 root root  224 Jun 29 13:27 finger.xml 
--rw-r--r--. 1 root root  709 Jun 29 13:27 freeipa-4.xml 
--rw-r--r--. 1 root root  489 Jun 29 13:27 freeipa-ldaps.xml 
--rw-r--r--. 1 root root  488 Jun 29 13:27 freeipa-ldap.xml 
--rw-r--r--. 1 root root  242 Jun 29 13:27 freeipa-replication.xml 
--rw-r--r--. 1 root root  657 Jun 29 13:27 freeipa-trust.xml 
--rw-r--r--. 1 root root  361 Jun 29 13:27 ftp.xml 
--rw-r--r--. 1 root root  292 Jun 29 13:27 galera.xml 
--rw-r--r--. 1 root root  184 Jun 29 13:27 ganglia-client.xml 
--rw-r--r--. 1 root root  176 Jun 29 13:27 ganglia-master.xml 
--rw-r--r--. 1 root root  212 Jun 29 13:27 git.xml 
--rw-r--r--. 1 root root  218 Jun 29 13:27 grafana.xml 
--rw-r--r--. 1 root root  119 Jun 29 13:27 gre.xml 
--rw-r--r--. 1 root root  608 Jun 29 13:27 high-availability.xml 
--rw-r--r--. 1 root root  448 Jun 29 13:27 https.xml 
--rw-r--r--. 1 root root  353 Jun 29 13:27 http.xml 
--rw-r--r--. 1 root root  372 Jun 29 13:27 imaps.xml 
--rw-r--r--. 1 root root  327 Jun 29 13:27 imap.xml 
--rw-r--r--. 1 root root  454 Jun 29 13:27 ipp-client.xml 
--rw-r--r--. 1 root root  427 Jun 29 13:27 ipp.xml 
--rw-r--r--. 1 root root  894 Jun 29 13:27 ipsec.xml 
--rw-r--r--. 1 root root  255 Jun 29 13:27 ircs.xml 
--rw-r--r--. 1 root root  247 Jun 29 13:27 irc.xml 
--rw-r--r--. 1 root root  264 Jun 29 13:27 iscsi-target.xml 
--rw-r--r--. 1 root root  358 Jun 29 13:27 isns.xml 
--rw-r--r--. 1 root root  213 Jun 29 13:27 jenkins.xml 
--rw-r--r--. 1 root root  182 Jun 29 13:27 kadmin.xml 
--rw-r--r--. 1 root root  272 Jun 29 13:27 kdeconnect.xml 
--rw-r--r--. 1 root root  233 Jun 29 13:27 kerberos.xml 
--rw-r--r--. 1 root root  384 Jun 29 13:27 kibana.xml 
--rw-r--r--. 1 root root  249 Jun 29 13:27 klogin.xml 
--rw-r--r--. 1 root root  221 Jun 29 13:27 kpasswd.xml 
--rw-r--r--. 1 root root  182 Jun 29 13:27 kprop.xml 
--rw-r--r--. 1 root root  242 Jun 29 13:27 kshell.xml 
--rw-r--r--. 1 root root  308 Jun 29 13:27 kube-apiserver.xml 
--rw-r--r--. 1 root root  232 Jun 29 13:27 ldaps.xml 
--rw-r--r--. 1 root root  199 Jun 29 13:27 ldap.xml 
--rw-r--r--. 1 root root  385 Jun 29 13:27 libvirt-tls.xml 
--rw-r--r--. 1 root root  389 Jun 29 13:27 libvirt.xml 
--rw-r--r--. 1 root root  269 Jun 29 13:27 lightning-network.xml 
--rw-r--r--. 1 root root  324 Jun 29 13:27 llmnr.xml 
--rw-r--r--. 1 root root  349 Jun 29 13:27 managesieve.xml 
--rw-r--r--. 1 root root  432 Jun 29 13:27 matrix.xml 
--rw-r--r--. 1 root root  424 Jun 29 13:27 mdns.xml 
--rw-r--r--. 1 root root  245 Jun 29 13:27 memcache.xml 
--rw-r--r--. 1 root root  343 Jun 29 13:27 minidlna.xml 
--rw-r--r--. 1 root root  237 Jun 29 13:27 mongodb.xml 
--rw-r--r--. 1 root root  473 Jun 29 13:27 mosh.xml 
--rw-r--r--. 1 root root  211 Jun 29 13:27 mountd.xml 
--rw-r--r--. 1 root root  296 Jun 29 13:27 mqtt-tls.xml 
--rw-r--r--. 1 root root  287 Jun 29 13:27 mqtt.xml 
--rw-r--r--. 1 root root  170 Jun 29 13:27 mssql.xml 
--rw-r--r--. 1 root root  190 Jun 29 13:27 ms-wbt.xml 
--rw-r--r--. 1 root root  242 Jun 29 13:27 murmur.xml 
--rw-r--r--. 1 root root  171 Jun 29 13:27 mysql.xml 
--rw-r--r--. 1 root root  342 Jun 29 13:27 nfs3.xml 
--rw-r--r--. 1 root root  324 Jun 29 13:27 nfs.xml 
--rw-r--r--. 1 root root  293 Jun 29 13:27 nmea-0183.xml 
--rw-r--r--. 1 root root  247 Jun 29 13:27 nrpe.xml 
--rw-r--r--. 1 root root  389 Jun 29 13:27 ntp.xml 
--rw-r--r--. 1 root root  368 Jun 29 13:27 nut.xml 
--rw-r--r--. 1 root root  335 Jun 29 13:27 openvpn.xml 
--rw-r--r--. 1 root root  260 Jun 29 13:27 ovirt-imageio.xml 
--rw-r--r--. 1 root root  343 Jun 29 13:27 ovirt-storageconsole.xml 
--rw-r--r--. 1 root root  235 Jun 29 13:27 ovirt-vmconsole.xml 
--rw-r--r--. 1 root root 1024 Jun 29 13:27 plex.xml 
--rw-r--r--. 1 root root  433 Jun 29 13:27 pmcd.xml 
--rw-r--r--. 1 root root  474 Jun 29 13:27 pmproxy.xml 
--rw-r--r--. 1 root root  544 Jun 29 13:27 pmwebapis.xml 
--rw-r--r--. 1 root root  460 Jun 29 13:27 pmwebapi.xml 
--rw-r--r--. 1 root root  357 Jun 29 13:27 pop3s.xml 
--rw-r--r--. 1 root root  348 Jun 29 13:27 pop3.xml 
--rw-r--r--. 1 root root  181 Jun 29 13:27 postgresql.xml 
--rw-r--r--. 1 root root  509 Jun 29 13:27 privoxy.xml 
--rw-r--r--. 1 root root  213 Jun 29 13:27 prometheus.xml 
--rw-r--r--. 1 root root  261 Jun 29 13:27 proxy-dhcp.xml 
--rw-r--r--. 1 root root  424 Jun 29 13:27 ptp.xml 
--rw-r--r--. 1 root root  414 Jun 29 13:27 pulseaudio.xml 
--rw-r--r--. 1 root root  297 Jun 29 13:27 puppetmaster.xml 
--rw-r--r--. 1 root root  273 Jun 29 13:27 quassel.xml 
--rw-r--r--. 1 root root  520 Jun 29 13:27 radius.xml 
--rw-r--r--. 1 root root  183 Jun 29 13:27 rdp.xml 
--rw-r--r--. 1 root root  212 Jun 29 13:27 redis-sentinel.xml 
--rw-r--r--. 1 root root  268 Jun 29 13:27 redis.xml 
--rw-r--r--. 1 root root  737 Jun 29 13:27 RH-Satellite-6.xml 
--rw-r--r--. 1 root root  214 Jun 29 13:27 rpc-bind.xml 
--rw-r--r--. 1 root root  213 Jun 29 13:27 rquotad.xml 
--rw-r--r--. 1 root root  310 Jun 29 13:27 rsh.xml 
--rw-r--r--. 1 root root  311 Jun 29 13:27 rsyncd.xml 
--rw-r--r--. 1 root root  350 Jun 29 13:27 rtsp.xml 
--rw-r--r--. 1 root root  329 Jun 29 13:27 salt-master.xml 
--rw-r--r--. 1 root root  371 Jun 29 13:27 samba-client.xml 
--rw-r--r--. 1 root root 1298 Jun 29 13:27 samba-dc.xml 
--rw-r--r--. 1 root root  448 Jun 29 13:27 samba.xml 
--rw-r--r--. 1 root root  324 Jun 29 13:27 sane.xml 
--rw-r--r--. 1 root root  283 Jun 29 13:27 sips.xml 
--rw-r--r--. 1 root root  496 Jun 29 13:27 sip.xml 
--rw-r--r--. 1 root root  299 Jun 29 13:27 slp.xml 
--rw-r--r--. 1 root root  231 Jun 29 13:27 smtp-submission.xml 
--rw-r--r--. 1 root root  577 Jun 29 13:27 smtps.xml 
--rw-r--r--. 1 root root  550 Jun 29 13:27 smtp.xml 
--rw-r--r--. 1 root root  308 Jun 29 13:27 snmptrap.xml 
--rw-r--r--. 1 root root  342 Jun 29 13:27 snmp.xml 
--rw-r--r--. 1 root root  405 Jun 29 13:27 spideroak-lansync.xml 
--rw-r--r--. 1 root root  275 Jun 29 13:27 spotify-sync.xml 
--rw-r--r--. 1 root root  173 Jun 29 13:27 squid.xml 
--rw-r--r--. 1 root root  421 Jun 29 13:27 ssdp.xml 
--rw-r--r--. 1 root root  463 Jun 29 13:27 ssh.xml 
--rw-r--r--. 1 root root  631 Jun 29 13:27 steam-streaming.xml 
--rw-r--r--. 1 root root  287 Jun 29 13:27 svdrp.xml 
--rw-r--r--. 1 root root  231 Jun 29 13:27 svn.xml 
--rw-r--r--. 1 root root  297 Jun 29 13:27 syncthing-gui.xml 
--rw-r--r--. 1 root root  311 Jun 29 13:27 syncthing.xml 
--rw-r--r--. 1 root root  496 Jun 29 13:27 synergy.xml 
--rw-r--r--. 1 root root  444 Jun 29 13:27 syslog-tls.xml 
--rw-r--r--. 1 root root  329 Jun 29 13:27 syslog.xml 
--rw-r--r--. 1 root root  393 Jun 29 13:27 telnet.xml 
--rw-r--r--. 1 root root  252 Jun 29 13:27 tentacle.xml 
--rw-r--r--. 1 root root  288 Jun 29 13:27 tftp-client.xml 
--rw-r--r--. 1 root root  424 Jun 29 13:27 tftp.xml 
--rw-r--r--. 1 root root  221 Jun 29 13:27 tile38.xml 
--rw-r--r--. 1 root root  336 Jun 29 13:27 tinc.xml 
--rw-r--r--. 1 root root  771 Jun 29 13:27 tor-socks.xml 
--rw-r--r--. 1 root root  244 Jun 29 13:27 transmission-client.xml 
--rw-r--r--. 1 root root  264 Jun 29 13:27 upnp-client.xml 
--rw-r--r--. 1 root root  593 Jun 29 13:27 vdsm.xml 
--rw-r--r--. 1 root root  475 Jun 29 13:27 vnc-server.xml 
--rw-r--r--. 1 root root  310 Jun 29 13:27 wbem-https.xml 
--rw-r--r--. 1 root root  352 Jun 29 13:27 wbem-http.xml 
--rw-r--r--. 1 root root  323 Jun 29 13:27 wsmans.xml 
--rw-r--r--. 1 root root  316 Jun 29 13:27 wsman.xml 
--rw-r--r--. 1 root root  329 Jun 29 13:27 xdmcp.xml 
--rw-r--r--. 1 root root  509 Jun 29 13:27 xmpp-bosh.xml 
--rw-r--r--. 1 root root  488 Jun 29 13:27 xmpp-client.xml 
--rw-r--r--. 1 root root  264 Jun 29 13:27 xmpp-local.xml 
--rw-r--r--. 1 root root  545 Jun 29 13:27 xmpp-server.xml 
--rw-r--r--. 1 root root  314 Jun 29 13:27 zabbix-agent.xml 
--rw-r--r--. 1 root root  315 Jun 29 13:27 zabbix-server.xml 
- 
-[root@centos8 ~]# ls -l /usr/lib/firewalld/zones/ 
-total 44 
--rw-r--r--. 1 root root 299 Jun 29 13:27 block.xml 
--rw-r--r--. 1 root root 293 Jun 29 13:27 dmz.xml 
--rw-r--r--. 1 root root 291 Jun 29 13:27 drop.xml 
--rw-r--r--. 1 root root 304 Jun 29 13:27 external.xml 
--rw-r--r--. 1 root root 397 Jun 29 13:27 home.xml 
--rw-r--r--. 1 root root 412 Jun 29 13:27 internal.xml 
--rw-r--r--. 1 root root 809 Nov 26  2019 libvirt.xml 
--rw-r--r--. 1 root root 729 Feb  1  2021 nm-shared.xml 
--rw-r--r--. 1 root root 343 Jun 29 13:27 public.xml 
--rw-r--r--. 1 root root 162 Jun 29 13:27 trusted.xml 
--rw-r--r--. 1 root root 339 Jun 29 13:27 work.xml 
-</code> 
- 
-Ces fichiers sont au format **xml**, par exemple : 
- 
-<code> 
-[root@centos8 ~]# cat /usr/lib/firewalld/zones/home.xml 
-<?xml version="1.0" encoding="utf-8"?> 
-<zone> 
-  <short>Home</short> 
-  <description>For use in home areas. You mostly trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description> 
-  <service name="ssh"/> 
-  <service name="mdns"/> 
-  <service name="samba-client"/> 
-  <service name="dhcpv6-client"/> 
-  <service name="cockpit"/> 
-</zone> 
-</code> 
- 
-La configuration de firewalld ainsi que les définitions et règles personnalisées se trouvent dans **/etc/firewalld** : 
- 
-<code> 
-[root@centos8 ~]# ls -l /etc/firewalld/ 
-total 8 
--rw-r--r--. 1 root root 2747 Jun 29 13:27 firewalld.conf 
-drwxr-x---. 2 root root    6 Jun 29 13:27 helpers 
-drwxr-x---. 2 root root    6 Jun 29 13:27 icmptypes 
-drwxr-x---. 2 root root    6 Jun 29 13:27 ipsets 
--rw-r--r--. 1 root root  283 Jun 29 13:27 lockdown-whitelist.xml 
-drwxr-x---. 2 root root    6 Jun 29 13:27 services 
-drwxr-x---. 2 root root   46 Jun 29 13:27 zones 
-</code> 
- 
-Le fichier de configuration de firewalld est **/etc/firewalld/firewalld.conf** : 
- 
-<code> 
-[root@centos8 ~]# cat /etc/firewalld/firewalld.conf  
-# firewalld config file 
- 
-# default zone 
-# The default zone used if an empty zone string is used. 
-# Default: public 
-DefaultZone=public 
- 
-# Clean up on exit 
-# If set to no or false the firewall configuration will not get cleaned up 
-# on exit or stop of firewalld 
-# Default: yes 
-CleanupOnExit=yes 
- 
-# Lockdown 
-# If set to enabled, firewall changes with the D-Bus interface will be limited 
-# to applications that are listed in the lockdown whitelist. 
-# The lockdown whitelist file is lockdown-whitelist.xml 
-# Default: no 
-Lockdown=no 
- 
-# IPv6_rpfilter 
-# Performs a reverse path filter test on a packet for IPv6. If a reply to the 
-# packet would be sent via the same interface that the packet arrived on, the  
-# packet will match and be accepted, otherwise dropped. 
-# The rp_filter for IPv4 is controlled using sysctl. 
-# Default: yes 
-IPv6_rpfilter=yes 
- 
-# IndividualCalls 
-# Do not use combined -restore calls, but individual calls. This increases the 
-# time that is needed to apply changes and to start the daemon, but is good for 
-# debugging. 
-# Default: no 
-IndividualCalls=no 
- 
-# LogDenied 
-# Add logging rules right before reject and drop rules in the INPUT, FORWARD 
-# and OUTPUT chains for the default rules and also final reject and drop rules 
-# in zones. Possible values are: all, unicast, broadcast, multicast and off. 
-# Default: off 
-LogDenied=off 
- 
-# FirewallBackend 
-# Selects the firewall backend implementation. 
-# Choices are: 
-#       - nftables (default) 
-#       - iptables (iptables, ip6tables, ebtables and ipset) 
-FirewallBackend=nftables 
- 
-# FlushAllOnReload 
-# Flush all runtime rules on a reload. In previous releases some runtime 
-# configuration was retained during a reload, namely; interface to zone 
-# assignment, and direct rules. This was confusing to users. To get the old 
-# behavior set this to "no". 
-# Default: yes 
-FlushAllOnReload=yes 
- 
-# RFC3964_IPv4 
-# As per RFC 3964, filter IPv6 traffic with 6to4 destination addresses that 
-# correspond to IPv4 addresses that should not be routed over the public 
-# internet. 
-# Defaults to "yes". 
-RFC3964_IPv4=yes 
- 
-# AllowZoneDrifting 
-# Older versions of firewalld had undocumented behavior known as "zone 
-# drifting". This allowed packets to ingress multiple zones - this is a 
-# violation of zone based firewalls. However, some users rely on this behavior 
-# to have a "catch-all" zone, e.g. the default zone. You can enable this if you 
-# desire such behavior. It's disabled by default for security reasons. 
-# Note: If "yes" packets will only drift from source based zones to interface 
-# based zones (including the default zone). Packets never drift from interface 
-# based zones to other interfaces based zones (including the default zone). 
-# Possible values; "yes", "no". Defaults to "yes". 
-AllowZoneDrifting=yes 
-</code> 
- 
-====4.3 - L'Utilisation de Base de Firewalld==== 
- 
-firewalld s'appuie sur netfilter. Pour cette raison, l'utilisation de firewall-cmd est incompatible avec l'utilisation des commandes iptables et system-config-firewall. 
- 
-<WRAP center round important> 
-**Important** - firewall-cmd est le front-end de firewalld en ligne de commande. Il existe aussi la commande **firewall-config** qui lance un outi de configuration graphique. 
-</WRAP> 
- 
-Pour obtenir la liste de toutes les zones prédéfinies, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --get-zones 
-block dmz drop external home internal libvirt nm-shared public trusted work 
-</code> 
- 
-Pour obtenir la liste de toutes les services prédéfinis, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --get-services 
-RH-Satellite-6 amanda-client amanda-k5-client amqp amqps apcupsd audit bacula bacula-client bb bgp bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc bittorrent-lsd ceph ceph-mon cfengine cockpit collectd condor-collector ctdb dhcp dhcpv6 dhcpv6-client distcc dns dns-over-tls docker-registry docker-swarm dropbox-lansync elasticsearch etcd-client etcd-server finger freeipa-4 freeipa-ldap freeipa-ldaps freeipa-replication freeipa-trust ftp galera ganglia-client ganglia-master git grafana gre high-availability http https imap imaps ipp ipp-client ipsec irc ircs iscsi-target isns jenkins kadmin kdeconnect kerberos kibana klogin kpasswd kprop kshell kube-apiserver ldap ldaps libvirt libvirt-tls lightning-network llmnr managesieve matrix mdns memcache minidlna mongodb mosh mountd mqtt mqtt-tls ms-wbt mssql murmur mysql nfs nfs3 nmea-0183 nrpe ntp nut openvpn ovirt-imageio ovirt-storageconsole ovirt-vmconsole plex pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy prometheus proxy-dhcp ptp pulseaudio puppetmaster quassel radius rdp redis redis-sentinel rpc-bind rquotad rsh rsyncd rtsp salt-master samba samba-client samba-dc sane sip sips slp smtp smtp-submission smtps snmp snmptrap spideroak-lansync spotify-sync squid ssdp ssh steam-streaming svdrp svn syncthing syncthing-gui synergy syslog syslog-tls telnet tentacle tftp tftp-client tile38 tinc tor-socks transmission-client upnp-client vdsm vnc-server wbem-http wbem-https wsman wsmans xdmcp xmpp-bosh xmpp-client xmpp-local xmpp-server zabbix-agent zabbix-server 
-</code> 
- 
-Pour obtenir la liste de toutes les types ICMP prédéfinis, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --get-icmptypes 
-address-unreachable bad-header beyond-scope communication-prohibited destination-unreachable echo-reply echo-request failed-policy fragmentation-needed host-precedence-violation host-prohibited host-redirect host-unknown host-unreachable ip-header-bad neighbour-advertisement neighbour-solicitation network-prohibited network-redirect network-unknown network-unreachable no-route packet-too-big parameter-problem port-unreachable precedence-cutoff protocol-unreachable redirect reject-route required-option-missing router-advertisement router-solicitation source-quench source-route-failed time-exceeded timestamp-reply timestamp-request tos-host-redirect tos-host-unreachable tos-network-redirect tos-network-unreachable ttl-zero-during-reassembly ttl-zero-during-transit unknown-header-type unknown-option 
-</code> 
- 
-Pour obtenir la liste des zones de la configuration courante, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --get-active-zones 
-public 
-  interfaces: ens18 
-</code> 
- 
-Pour obtenir la liste des zones de la configuration courante pour une interface spécifique, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --get-zone-of-interface=ens18 
-public 
-</code> 
- 
-Pour obtenir la liste des services autorisés pour la zone public, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --zone=public --list-services 
-cockpit dhcpv6-client ssh 
-</code> 
- 
-Pour obtenir toute la configuration pour la zone public, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --zone=public --list-all 
-public (active) 
-  target: default 
-  icmp-block-inversion: no 
-  interfaces: ens18 
-  sources:  
-  services: cockpit dhcpv6-client ssh 
-  ports: 5901/tcp 
-  protocols:  
-  masquerade: no 
-  forward-ports:  
-  source-ports:  
-  icmp-blocks:  
-  rich rules:   
-</code> 
- 
-Pour obtenir la liste complète de toutes les zones et leurs configurations, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --list-all-zones 
-block 
-  target: %%REJECT%% 
-  icmp-block-inversion: no 
-  interfaces:  
-  sources:  
-  services:  
-  ports:  
-  protocols:  
-  masquerade: no 
-  forward-ports:  
-  source-ports:  
-  icmp-blocks:  
-  rich rules:  
- 
-dmz 
-  target: default 
-  icmp-block-inversion: no 
-  interfaces:  
-  sources:  
-  services: ssh 
-  ports:  
-  protocols:  
-  masquerade: no 
-  forward-ports:  
-  source-ports:  
-  icmp-blocks:  
-  rich rules:  
- 
-drop 
-  target: DROP 
-  icmp-block-inversion: no 
-  interfaces:  
-  sources:  
-  services:  
-  ports:  
-  protocols:  
-  masquerade: no 
-  forward-ports:  
-  source-ports:  
-  icmp-blocks:  
-  rich rules:  
- 
-external 
-  target: default 
-  icmp-block-inversion: no 
-  interfaces:  
-  sources:  
-  services: ssh 
-  ports:  
-  protocols:  
-  masquerade: yes 
-  forward-ports:  
-  source-ports:  
-  icmp-blocks:  
-  rich rules:  
- 
-home 
-  target: default 
-  icmp-block-inversion: no 
-  interfaces:  
-  sources:  
-  services: cockpit dhcpv6-client mdns samba-client ssh 
-  ports:  
-  protocols:  
-  masquerade: no 
-  forward-ports:  
-  source-ports:  
-  icmp-blocks:  
-  rich rules:  
- 
-internal 
-  target: default 
-  icmp-block-inversion: no 
-  interfaces:  
-  sources:  
-  services: cockpit dhcpv6-client mdns samba-client ssh 
-  ports:  
-  protocols:  
-  masquerade: no 
-  forward-ports:  
-  source-ports:  
-  icmp-blocks:  
-  rich rules:  
- 
-libvirt 
-  target: ACCEPT 
-  icmp-block-inversion: no 
-  interfaces:  
-  sources:  
-  services: dhcp dhcpv6 dns ssh tftp 
-  ports:  
-  protocols: icmp ipv6-icmp 
-  masquerade: no 
-  forward-ports:  
-  source-ports:  
-  icmp-blocks:  
-  rich rules:  
-        rule priority="32767" reject 
- 
-nm-shared 
-  target: ACCEPT 
-  icmp-block-inversion: no 
-  interfaces:  
-  sources:  
-  services: dhcp dns ssh 
-  ports:  
-  protocols: icmp ipv6-icmp 
-  masquerade: no 
-  forward-ports:  
-  source-ports:  
-  icmp-blocks:  
-  rich rules:  
-        rule priority="32767" reject 
- 
-public (active) 
-  target: default 
-  icmp-block-inversion: no 
-  interfaces: ens18 
-  sources:  
-  services: cockpit dhcpv6-client ssh 
-  ports: 5901/tcp 
-  protocols:  
-  masquerade: no 
-  forward-ports:  
-  source-ports:  
-  icmp-blocks:  
-  rich rules:  
- 
-trusted 
-  target: ACCEPT 
-  icmp-block-inversion: no 
-  interfaces:  
-  sources:  
-  services:  
-  ports:  
-  protocols:  
-  masquerade: no 
-  forward-ports:  
-  source-ports:  
-  icmp-blocks:  
-  rich rules:  
- 
-work 
-  target: default 
-  icmp-block-inversion: no 
-  interfaces:  
-  sources:  
-  services: cockpit dhcpv6-client ssh 
-  ports:  
-  protocols:  
-  masquerade: no 
-  forward-ports:  
-  source-ports:  
-  icmp-blocks:  
-  rich rules:  
-</code> 
- 
-Pour changer la zone par défaut de public à work, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --set-default-zone=work 
-success 
- 
-[root@centos8 ~]# firewall-cmd --get-active-zones 
-work 
-  interfaces: ens18 
-</code> 
- 
-Pour ajouter l'interface ip_fixe à la zone work, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --zone=work --add-interface=ip_fixe 
-success 
-[root@centos8 ~]# firewall-cmd --get-active-zones 
-work 
-  interfaces: ens18 ip_fixe 
-</code> 
- 
-Pour supprimer l'interface ip_fixe à la zone work, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --zone=work --remove-interface=ip_fixe 
-success 
-[root@centos8 ~]# firewall-cmd --get-active-zones 
-work 
-  interfaces: ens18 
-</code> 
- 
-Pour ajouter le service **http** à la zone **work**, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --zone=work --add-service=http 
-success 
-[root@centos8 ~]# firewall-cmd --zone=work --list-services 
-cockpit dhcpv6-client http ssh 
-</code> 
- 
-Pour supprimer le service **http** de la zone **work**, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --zone=work --remove-service=http 
-success 
-[root@centos8 ~]# firewall-cmd --zone=work --list-services 
-cockpit dhcpv6-client ssh 
-</code> 
- 
-Pour ajouter un nouveau bloc ICMP, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --zone=work --add-icmp-block=echo-reply 
-success 
-[root@centos8 ~]# firewall-cmd --zone=work --list-icmp-blocks 
-echo-reply 
-</code> 
- 
-Pour supprimer un bloc ICMP, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --zone=work --remove-icmp-block=echo-reply 
-success 
-[root@centos8 ~]# firewall-cmd --zone=work --list-icmp-blocks 
- 
-[root@centos8 ~]#  
-</code> 
- 
-Pour ajouter le port 591/tcp à la zone work, utilisez la commande suivante : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --zone=work --add-port=591/tcp 
-success 
-[root@centos8 ~]# firewall-cmd --zone=work --list-ports 
-591/tcp 
-</code> 
- 
-Pour supprimer le port 591/tcp à la zone work, utilisez la commande suivante : 
- 
-<code> 
-root@centos8 ~]# firewall-cmd --zone=work --remove-port=591/tcp 
-success 
-[root@centos8 ~]# firewall-cmd --zone=work --list-ports 
- 
-[root@centos8 ~]#  
-</code> 
- 
-Pour créer un nouveau service, il convient de : 
- 
-  * copier un fichier existant se trouvant dans le répertoire **/usr/lib/firewalld/services** vers **/etc/firewalld/services**, 
-  * modifier le fichier, 
-  * recharger la configuration de firewalld, 
-  * vérifier que firewalld voit le nouveau service. 
- 
-Par exemple : 
- 
-<code> 
-[root@centos8 ~]# cp /usr/lib/firewalld/services/http.xml /etc/firewalld/services/filemaker.xml 
- 
-[root@centos8 ~]# vi /etc/firewalld/services/filemaker.xml 
-[root@centos8 ~]# cat /etc/firewalld/services/filemaker.xml 
-<?xml version="1.0" encoding="utf-8"?> 
-<service> 
-  <short>FileMakerPro</short> 
-  <description>Fichier de service firewalld pour FileMaker Pro</description> 
-  <port protocol="tcp" port="591"/> 
-</service> 
- 
-[root@centos8 ~]# firewall-cmd --reload 
-success 
- 
-[root@centos8 ~]# firewall-cmd --get-services | grep filemaker 
-RH-Satellite-6 amanda-client amanda-k5-client amqp amqps apcupsd audit bacula bacula-client bb bgp bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc bittorrent-lsd ceph ceph-mon cfengine cockpit collectd condor-collector ctdb dhcp dhcpv6 dhcpv6-client distcc dns dns-over-tls docker-registry docker-swarm dropbox-lansync elasticsearch etcd-client etcd-server filemaker finger freeipa-4 freeipa-ldap freeipa-ldaps freeipa-replication freeipa-trust ftp galera ganglia-client ganglia-master git grafana gre high-availability http https imap imaps ipp ipp-client ipsec irc ircs iscsi-target isns jenkins kadmin kdeconnect kerberos kibana klogin kpasswd kprop kshell kube-apiserver ldap ldaps libvirt libvirt-tls lightning-network llmnr managesieve matrix mdns memcache minidlna mongodb mosh mountd mqtt mqtt-tls ms-wbt mssql murmur mysql nfs nfs3 nmea-0183 nrpe ntp nut openvpn ovirt-imageio ovirt-storageconsole ovirt-vmconsole plex pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy prometheus proxy-dhcp ptp pulseaudio puppetmaster quassel radius rdp redis redis-sentinel rpc-bind rquotad rsh rsyncd rtsp salt-master samba samba-client samba-dc sane sip sips slp smtp smtp-submission smtps snmp snmptrap spideroak-lansync spotify-sync squid ssdp ssh steam-streaming svdrp svn syncthing syncthing-gui synergy syslog syslog-tls telnet tentacle tftp tftp-client tile38 tinc tor-socks transmission-client upnp-client vdsm vnc-server wbem-http wbem-https wsman wsmans xdmcp xmpp-bosh xmpp-client xmpp-local xmpp-server zabbix-agent zabbix-server 
-</code> 
- 
-====4.4 - La Configuration Avancée de firewalld==== 
- 
-La configuration de base de firewalld ne permet que la configuration des zones, services, blocs ICMP et les ports non-standard. Cependant firewalld peut également être configuré avec des **Rich Rules** ou **//Règles Riches//**. Rich Rules ou Règles Riches évaluent des **critères** pour ensuite entreprendre une **action**.  
- 
-Les **Critères** sont : 
- 
-  * **source address="<adresse_IP>"** 
-  * **destination address="<adresse_IP>"**, 
-  * **rule port port="<numéro_du_port>"**, 
-  * **service name=<nom_d'un_sevice_prédéfini>**. 
- 
-Les **Actions** sont : 
- 
-  * **accept**, 
-  * **reject**, 
-    * une Action reject peut être associée avec un message d'erreur spécifique par la clause **type="<type_d'erreur>**, 
-  * **drop**. 
- 
-Saisissez la commande suivante pour ouvrir le port 80 : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --add-rich-rule='rule port port="80" protocol="tcp" accept' 
-success 
-[root@centos8 ~]# firewall-cmd --list-all 
-work (active) 
-  target: default 
-  icmp-block-inversion: no 
-  interfaces: ens18 
-  sources:  
-  services: cockpit dhcpv6-client ssh 
-  ports:  
-  protocols:  
-  masquerade: no 
-  forward-ports:  
-  source-ports:  
-  icmp-blocks:  
-  rich rules:  
-        rule port port="80" protocol="tcp" accept 
-</code> 
- 
-<WRAP center round important 50%> 
-**Important** - Notez que la Rich Rule doit être entourée de caractères **'**.  
-</WRAP> 
- 
-Saisissez la commande suivante pour visualiser la règle nftables : 
- 
-<code> 
-[root@centos8 ~]# nft list ruleset | grep 80 
-                ip6 daddr fe80::/64 udp dport 546 ct state { new, untracked } accept 
-                tcp dport 80 ct state { new, untracked } accept 
-</code> 
- 
-Cette nouvelle règle est écrite en mémoire mais non pas sur disque : 
- 
-<code> 
-[root@centos8 ~]# ls -l /etc/firewalld/zones/ 
-total 12 
--rw-r--r--. 1 root root 380 Jun 16 12:02 public.xml 
--rw-r--r--. 1 root root 343 Jun 16 06:39 public.xml.old 
-</code> 
- 
-Pour l'écrire sur disque dans un fichier zone se trouvant dans **/etc/firewalld**, il faut ajouter l'option **--permanent** : 
- 
-<code> 
-[root@centos7 ~]# firewall-cmd --add-rich-rule='rule port port="80" protocol="tcp" accept' --permanent 
-success 
- 
-[root@centos8 ~]# ls -l /etc/firewalld/zones/ 
-total 12 
--rw-r--r--. 1 root root 380 Jun 16 12:02 public.xml 
--rw-r--r--. 1 root root 343 Jun 16 06:39 public.xml.old 
--rw-r--r--. 1 root root 409 Aug 30 06:43 work.xml 
- 
-[root@centos8 ~]# cat /etc/firewalld/zones/work.xml 
-<?xml version="1.0" encoding="utf-8"?> 
-<zone> 
-  <short>Work</short> 
-  <description>For use in work areas. You mostly trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description> 
-  <service name="ssh"/> 
-  <service name="dhcpv6-client"/> 
-  <service name="cockpit"/> 
-  <rule> 
-    <port port="80" protocol="tcp"/> 
-    <accept/> 
-  </rule> 
-</zone> 
-</code> 
- 
-<WRAP center round important 50%> 
-Attention ! La règle ajoutée avec l'option --permanent n'est pas prise en compte imédiatement mais uniquement au prochain redémmarge. Pour qu'une règle soit appliquée immédiatement **et** être écrite sur disque, il faut saisir la commande deux fois dont une avec l'option --permanent et l'autre sans l'option --permanent. 
-</WRAP> 
- 
-Notez que la Rich Rule est créée dans la Zone par Défaut. Il est possible de créer une Rich Rule dans une autre zone en utilisant l'option **--zone=<zone>** de la commande firewall-cmd : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --zone=public --add-rich-rule='rule port port="80" protocol="tcp" accept' 
-success 
- 
-[root@centos8 ~]# firewall-cmd --list-all --zone=public 
-public 
-  target: default 
-  icmp-block-inversion: no 
-  interfaces:  
-  sources:  
-  services: cockpit dhcpv6-client ssh 
-  ports: 5901/tcp 
-  protocols:  
-  masquerade: no 
-  forward-ports:  
-  source-ports:  
-  icmp-blocks:  
-  rich rules:  
-        rule port port="80" protocol="tcp" accept 
-</code> 
- 
-Pour supprimer une Rich Rule, il faut copier la ligne entière la concernant qui se trouve dans la sortie de la commande **firewall-cmd --list-all-zones** : 
- 
-<code> 
-[root@centos8 ~]# firewall-cmd --zone=public --remove-rich-rule='rule port port="80" protocol="tcp" accept' 
-success 
- 
-[root@centos8 ~]# firewall-cmd --list-all --zone=public 
-public 
-  target: default 
-  icmp-block-inversion: no 
-  interfaces:  
-  sources:  
-  services: cockpit dhcpv6-client ssh 
-  ports: 5901/tcp 
-  protocols:  
-  masquerade: no 
-  forward-ports:  
-  source-ports:  
-  icmp-blocks:  
-  rich rules:  
-</code> 
- 
-====4.5 - Le mode Panic de firewalld==== 
- 
-Le mode Panic de firewalld permet de bloquer tout le trafic avec une seule commande. Pour connaître l'état du mode Panic, utilisez la commande suivante : 
- 
-<code> 
-[root@centos7 ~]# firewall-cmd --query-panic 
-no 
-</code> 
- 
-Pour activer le mode Panic, il convient de saisir la commande suivante : 
- 
-<code> 
-# firewall-cmd --panic-on 
-</code> 
- 
-<WRAP center round warning 50%> 
-**Attention** - Veuillez ne **PAS** saisir la commande ci-dessus.  
-</WRAP> 
- 
-Pour désactiver le mode Panic, il convient de saisir la commande suivante : 
- 
-<code> 
-# firewall-cmd --panic-off 
-</code> 
- 
-<WRAP center round warning 50%> 
-**Attention** - Veuillez ne **PAS** saisir la commande ci-dessus.  
-</WRAP> 
  
 ----- -----
-<html> +Copyright © 2022 Hugh Norris.
-<div align="center"> +
-Copyright © 2021 Hugh Norris. +
-</html>+
Menu