Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
elearning:workbooks:centos:8:avance:l106 [2021/06/26 06:05] – admin | elearning:workbooks:centos:8:avance:l106 [2022/02/22 15:15] (Version actuelle) – created admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
+ | |||
+ | Version : **2022.01** | ||
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ======LCF306 | + | ======LCF606 |
=====Contenu du Module===== | =====Contenu du Module===== | ||
- | * **LCF306 | + | * **LCF606 |
* Contenu du Module | * Contenu du Module | ||
- | * Configuration du Réseau | + | * LAB #1 - Gestion des Clones |
- | * La Commande nmcli | + | * 1.1 - Création d'une VM à partir d'un Clone |
- | * Connections et Profils | + | * LAB #2 - Gestion des Snapshots |
- | * Ajouter | + | * 2.1 - Création d'un Snapshot - VM Arrêté |
- | * La Commande hostname | + | * 2.2 - Création d'un Snapshot - VM en Cours d' |
- | * La Commande ip | + | * 2.3 - Restauration d'un Snapshot |
- | * Activer/ | + | * 2.4 - Suppression de Snapshots |
- | * Routage Statique | + | * LAB #3 - Gestion des Sauvegardes |
- | * La commande ip | + | * 3.1 - Création d'une Copie du Disque |
- | * Activer/ | + | * 3.2 - Création d'une Copie de la Configuration |
- | * Diagnostique du Réseau | + | * 3.3 - Sauvegarder les Copies |
- | * ping | + | |
- | * netstat | + | =====LAB #1 - Gestion |
- | * traceroute | + | |
- | * Connexions à Distance | + | |
- | * Telnet | + | |
- | * wget | + | |
- | * ftp | + | |
- | * SSH | + | |
- | * Introduction | + | |
- | * SSH-1 | + | |
- | * SSH-2 | + | |
- | * L'authentification par mot de passe | + | |
- | * L'authentification par clef asymétrique | + | |
- | * Installation | + | |
- | * Configuration | + | |
- | * Serveur | + | |
- | * Utilisation | + | |
- | * Tunnels SSH | + | |
- | * SCP | + | |
- | * Introduction | + | |
- | * Utilisation | + | |
- | * Mise en place des clefs | + | |
- | * La Configuration par firewalld | + | |
- | * La Configuration de Base de firewalld | + | |
- | * La Commande firewall-cmd | + | |
- | * La Configuration Avancée de firewalld | + | |
- | * Le mode Panic de firewalld | + | |
- | =====Configuration du Réseau===== | + | La création de clones offre une méthode rapide de création de VMs basées sur des configurations déjà existantes. |
- | RHEL/CentOS 7 utilise exclusivement **Network Manager** pour gérer le réseau. Network Manager est composé de deux éléments : | + | ====1.1 - Création d'une VM à partir d'un Clone==== |
- | * un service qui gère les connexions réseaux et rapporte leurs états, | + | Commencez |
- | * des front-ends qui passent | + | |
- | + | ||
- | <WRAP center round important> | + | |
- | **Important** : Notez qu' | + | |
- | </ | + | |
- | + | ||
- | Le service NetworkManager doit toujours être lancé | + | |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | ● NetworkManager.service - Network Manager | + | Id |
- | Loaded: loaded (/ | + | ------------------------- |
- | Active: active (running) since Sun 2016-08-07 09:18:20 CEST; 1 day 1h ago | + | 3 testvm1 |
- | Main PID: 673 (NetworkManager) | + | |
- | | + | |
- | | + | |
- | | + | |
- | + | ||
- | Aug 08 11:03:55 centos7.fenestros.loc NetworkManager[673]: | + | |
- | Aug 08 11:03:55 centos7.fenestros.loc NetworkManager[673]: | + | |
- | Aug 08 11:03:55 centos7.fenestros.loc NetworkManager[673]: | + | |
- | Aug 08 11:03:55 centos7.fenestros.loc NetworkManager[673]: | + | |
- | Aug 08 11:03:55 centos7.fenestros.loc NetworkManager[673]: | + | |
- | Aug 08 11:03:55 centos7.fenestros.loc NetworkManager[673]: | + | |
- | Aug 08 11:03:55 centos7.fenestros.loc NetworkManager[673]: | + | |
- | Aug 08 11:03:55 centos7.fenestros.loc NetworkManager[673]: | + | |
- | Aug 08 11:03:55 centos7.fenestros.loc NetworkManager[673]: | + | |
- | Aug 08 11:03:55 centos7.fenestros.loc dhclient[2673]: | + | |
</ | </ | ||
- | ====La Commande nmcli==== | + | <WRAP center round important 60%> |
- | + | **Important** : Notez que la VM est dans un état de **running** et que son **Id** est de **3**. | |
- | La commande **nmcli** (Network Manager Command Line Interface) est utilisée pour configurer NetworkManager. | + | |
- | + | ||
- | Les options et les sous-commandes peuvent être consultées en utilisant les commandes suivantes : | + | |
- | + | ||
- | <code> | + | |
- | [root@centos7 ~]# nmcli help | + | |
- | Usage: nmcli [OPTIONS] OBJECT { COMMAND | help } | + | |
- | + | ||
- | OPTIONS | + | |
- | -t[erse] | + | |
- | -p[retty] | + | |
- | -m[ode] tabular|multiline | + | |
- | -f[ields] < | + | |
- | -e[scape] yes|no | + | |
- | -n[ocheck] | + | |
- | -a[sk] | + | |
- | -w[ait] < | + | |
- | -v[ersion] | + | |
- | -h[elp] | + | |
- | + | ||
- | OBJECT | + | |
- | g[eneral] | + | |
- | n[etworking] | + | |
- | r[adio] | + | |
- | c[onnection] | + | |
- | d[evice] | + | |
- | a[gent] | + | |
- | + | ||
- | [root@centos7 ~]# nmcli g help | + | |
- | Usage: nmcli general { COMMAND | help } | + | |
- | + | ||
- | COMMAND := { status | hostname | permissions | logging } | + | |
- | + | ||
- | status | + | |
- | + | ||
- | hostname [< | + | |
- | + | ||
- | permissions | + | |
- | + | ||
- | logging [level <log level>] [domains <log domains> | + | |
- | + | ||
- | + | ||
- | [root@centos7 ~]# nmcli g status help | + | |
- | Usage: nmcli general status { help } | + | |
- | + | ||
- | Show overall status of NetworkManager. | + | |
- | ' | + | |
- | + | ||
- | </ | + | |
- | + | ||
- | ====Connections et Profils==== | + | |
- | + | ||
- | 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** : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# nmcli c show | + | |
- | NAME UUID TYPE DEVICE | + | |
- | Wired connection 1 45b701c1-0a21-4d76-a795-2f2bcba86955 | + | |
- | </ | + | |
- | + | ||
- | Comme on peut constater ici, il n' | + | |
- | + | ||
- | Créez donc un profil IP fixe rattaché au périphérique **enp0s3** : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# nmcli connection add con-name ip_fixe ifname enp0s3 type ethernet ip4 10.0.2.16/ | + | |
- | Connection ' | + | |
- | </ | + | |
- | + | ||
- | Constatez sa présence : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# nmcli c show | + | |
- | NAME UUID TYPE DEVICE | + | |
- | ip_fixe | + | |
- | Wired connection 1 45b701c1-0a21-4d76-a795-2f2bcba86955 | + | |
- | </ | + | |
- | + | ||
- | Notez que la sortie n' | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# nmcli d show | + | |
- | GENERAL.DEVICE: | + | |
- | GENERAL.TYPE: | + | |
- | GENERAL.HWADDR: | + | |
- | GENERAL.MTU: | + | |
- | GENERAL.STATE: | + | |
- | GENERAL.CONNECTION: | + | |
- | GENERAL.CON-PATH: | + | |
- | WIRED-PROPERTIES.CARRIER: | + | |
- | IP4.ADDRESS[1]: | + | |
- | IP4.GATEWAY: | + | |
- | IP4.DNS[1]: | + | |
- | IP6.ADDRESS[1]: | + | |
- | IP6.GATEWAY: | + | |
- | + | ||
- | GENERAL.DEVICE: | + | |
- | GENERAL.TYPE: | + | |
- | GENERAL.HWADDR: | + | |
- | GENERAL.MTU: | + | |
- | GENERAL.STATE: | + | |
- | GENERAL.CONNECTION: | + | |
- | GENERAL.CON-PATH: | + | |
- | IP4.ADDRESS[1]: | + | |
- | IP4.GATEWAY: | + | |
- | IP6.ADDRESS[1]: | + | |
- | IP6.GATEWAY: | + | |
- | </ | + | |
- | + | ||
- | Pour activer le profil ip_fixe, utilisez la commande suivante : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# nmcli connection up ip_fixe | + | |
- | </ | + | |
- | + | ||
- | Le profil ip_fixe est maintenant activé tandis que le profil enp0s3 a été désactivé : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# nmcli c show | + | |
- | NAME UUID TYPE DEVICE | + | |
- | ip_fixe | + | |
- | Wired connection 1 45b701c1-0a21-4d76-a795-2f2bcba86955 | + | |
- | [root@centos7 ~]# nmcli d show | + | |
- | GENERAL.DEVICE: | + | |
- | GENERAL.TYPE: | + | |
- | GENERAL.HWADDR: | + | |
- | GENERAL.MTU: | + | |
- | GENERAL.STATE: | + | |
- | GENERAL.CONNECTION: | + | |
- | GENERAL.CON-PATH: | + | |
- | WIRED-PROPERTIES.CARRIER: | + | |
- | IP4.ADDRESS[1]: | + | |
- | IP4.GATEWAY: | + | |
- | IP6.ADDRESS[1]: | + | |
- | IP6.GATEWAY: | + | |
- | + | ||
- | GENERAL.DEVICE: | + | |
- | GENERAL.TYPE: | + | |
- | GENERAL.HWADDR: | + | |
- | GENERAL.MTU: | + | |
- | GENERAL.STATE: | + | |
- | GENERAL.CONNECTION: | + | |
- | GENERAL.CON-PATH: | + | |
- | IP4.ADDRESS[1]: | + | |
- | IP4.GATEWAY: | + | |
- | IP6.ADDRESS[1]: | + | |
- | IP6.GATEWAY: | + | |
- | </ | + | |
- | + | ||
- | Pour consulter les paramètres d'un profil, utilisez la commande suivante : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# nmcli -p connection show "Wired connection 1" | + | |
- | =============================================================================== | + | |
- | Connection profile details (Wired connection 1) | + | |
- | =============================================================================== | + | |
- | connection.id: | + | |
- | connection.uuid: | + | |
- | connection.interface-name: | + | |
- | connection.type: | + | |
- | connection.autoconnect: | + | |
- | connection.autoconnect-priority: | + | |
- | connection.timestamp: | + | |
- | connection.read-only: | + | |
- | connection.permissions: | + | |
- | connection.zone: | + | |
- | connection.master: | + | |
- | connection.slave-type: | + | |
- | connection.autoconnect-slaves: | + | |
- | connection.secondaries: | + | |
- | connection.gateway-ping-timeout: | + | |
- | connection.metered: | + | |
- | ------------------------------------------------------------------------------- | + | |
- | 802-3-ethernet.port: | + | |
- | 802-3-ethernet.speed: | + | |
- | 802-3-ethernet.duplex: | + | |
- | 802-3-ethernet.auto-negotiate: | + | |
- | 802-3-ethernet.mac-address: | + | |
- | 802-3-ethernet.cloned-mac-address: | + | |
- | 802-3-ethernet.mac-address-blacklist: | + | |
- | 802-3-ethernet.mtu: | + | |
- | 802-3-ethernet.s390-subchannels: | + | |
- | 802-3-ethernet.s390-nettype: | + | |
- | 802-3-ethernet.s390-options: | + | |
- | 802-3-ethernet.wake-on-lan: | + | |
- | 802-3-ethernet.wake-on-lan-password: | + | |
- | ------------------------------------------------------------------------------- | + | |
- | ipv4.method: | + | |
- | ipv4.dns: | + | |
- | ipv4.dns-search: | + | |
- | ipv4.addresses: | + | |
- | ipv4.gateway: | + | |
- | ipv4.routes: | + | |
- | ipv4.route-metric: | + | |
- | ipv4.ignore-auto-routes: | + | |
- | ipv4.ignore-auto-dns: | + | |
- | ipv4.dhcp-client-id: | + | |
- | ipv4.dhcp-send-hostname: | + | |
- | ipv4.dhcp-hostname: | + | |
- | ipv4.never-default: | + | |
- | ipv4.may-fail: | + | |
- | ------------------------------------------------------------------------------- | + | |
- | ipv6.method: | + | |
- | ipv6.dns: | + | |
- | ipv6.dns-search: | + | |
- | ipv6.addresses: | + | |
- | ipv6.gateway: | + | |
- | ipv6.routes: | + | |
- | ipv6.route-metric: | + | |
- | ipv6.ignore-auto-routes: | + | |
- | ipv6.ignore-auto-dns: | + | |
- | ipv6.never-default: | + | |
- | ipv6.may-fail: | + | |
- | ipv6.ip6-privacy: | + | |
- | ipv6.dhcp-send-hostname: | + | |
- | ipv6.dhcp-hostname: | + | |
- | ------------------------------------------------------------------------------- | + | |
- | [root@centos7 ~]# nmcli -p connection show ip_fixe | + | |
- | =============================================================================== | + | |
- | | + | |
- | =============================================================================== | + | |
- | connection.id: | + | |
- | connection.uuid: | + | |
- | connection.interface-name: | + | |
- | connection.type: | + | |
- | connection.autoconnect: | + | |
- | connection.autoconnect-priority: | + | |
- | connection.timestamp: | + | |
- | connection.read-only: | + | |
- | connection.permissions: | + | |
- | connection.zone: | + | |
- | connection.master: | + | |
- | connection.slave-type: | + | |
- | connection.autoconnect-slaves: | + | |
- | connection.secondaries: | + | |
- | connection.gateway-ping-timeout: | + | |
- | connection.metered: | + | |
- | ------------------------------------------------------------------------------- | + | |
- | 802-3-ethernet.port: | + | |
- | 802-3-ethernet.speed: | + | |
- | 802-3-ethernet.duplex: | + | |
- | 802-3-ethernet.auto-negotiate: | + | |
- | 802-3-ethernet.mac-address: | + | |
- | 802-3-ethernet.cloned-mac-address: | + | |
- | 802-3-ethernet.mac-address-blacklist: | + | |
- | 802-3-ethernet.mtu: | + | |
- | 802-3-ethernet.s390-subchannels: | + | |
- | 802-3-ethernet.s390-nettype: | + | |
- | 802-3-ethernet.s390-options: | + | |
- | 802-3-ethernet.wake-on-lan: | + | |
- | 802-3-ethernet.wake-on-lan-password: | + | |
- | ------------------------------------------------------------------------------- | + | |
- | ipv4.method: | + | |
- | ipv4.dns: | + | |
- | ipv4.dns-search: | + | |
- | ipv4.addresses: | + | |
- | ipv4.gateway: | + | |
- | ipv4.routes: | + | |
- | ipv4.route-metric: | + | |
- | ipv4.ignore-auto-routes: | + | |
- | ipv4.ignore-auto-dns: | + | |
- | ipv4.dhcp-client-id: | + | |
- | ipv4.dhcp-send-hostname: | + | |
- | ipv4.dhcp-hostname: | + | |
- | ipv4.never-default: | + | |
- | ipv4.may-fail: | + | |
- | ------------------------------------------------------------------------------- | + | |
- | ipv6.method: | + | |
- | ipv6.dns: | + | |
- | ipv6.dns-search: | + | |
- | ipv6.addresses: | + | |
- | ipv6.gateway: | + | |
- | ipv6.routes: | + | |
- | ipv6.route-metric: | + | |
- | ipv6.ignore-auto-routes: | + | |
- | ipv6.ignore-auto-dns: | + | |
- | ipv6.never-default: | + | |
- | ipv6.may-fail: | + | |
- | ipv6.ip6-privacy: | + | |
- | ipv6.dhcp-send-hostname: | + | |
- | ipv6.dhcp-hostname: | + | |
- | ------------------------------------------------------------------------------- | + | |
- | =============================================================================== | + | |
- | Activate connection details (fb3a11d9-4e03-4032-b26e-09d1195d2bcd) | + | |
- | =============================================================================== | + | |
- | GENERAL.NAME: | + | |
- | GENERAL.UUID: | + | |
- | GENERAL.DEVICES: | + | |
- | GENERAL.STATE: | + | |
- | GENERAL.DEFAULT: | + | |
- | GENERAL.DEFAULT6: | + | |
- | GENERAL.VPN: | + | |
- | GENERAL.ZONE: | + | |
- | GENERAL.DBUS-PATH: | + | |
- | GENERAL.CON-PATH: | + | |
- | GENERAL.SPEC-OBJECT: | + | |
- | GENERAL.MASTER-PATH: | + | |
- | ------------------------------------------------------------------------------- | + | |
- | IP4.ADDRESS[1]: | + | |
- | IP4.GATEWAY: | + | |
- | ------------------------------------------------------------------------------- | + | |
- | IP6.ADDRESS[1]: | + | |
- | IP6.GATEWAY: | + | |
- | ------------------------------------------------------------------------------- | + | |
- | </ | + | |
- | + | ||
- | Pour consulter la liste profils associés à un périphérique, | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# nmcli -f CONNECTIONS device show enp0s3 | + | |
- | CONNECTIONS.AVAILABLE-CONNECTION-PATHS: | + | |
- | CONNECTIONS.AVAILABLE-CONNECTIONS[1]: | + | |
- | CONNECTIONS.AVAILABLE-CONNECTIONS[2]: | + | |
- | </ | + | |
- | + | ||
- | Les fichiers | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# ls -l / | + | |
- | -rw-r--r--. 1 root root 296 Aug 8 11:08 ifcfg-ip_fixe | + | |
- | -rw-r--r--. 1 root root 254 Sep 16 2015 ifcfg-lo | + | |
- | </ | + | |
- | + | ||
- | L' | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# cat / | + | |
- | TYPE=Ethernet | + | |
- | BOOTPROTO=none | + | |
- | IPADDR=10.0.2.16 | + | |
- | PREFIX=24 | + | |
- | GATEWAY=10.0.2.2 | + | |
- | DEFROUTE=yes | + | |
- | IPV4_FAILURE_FATAL=no | + | |
- | IPV6INIT=yes | + | |
- | IPV6_AUTOCONF=yes | + | |
- | IPV6_DEFROUTE=yes | + | |
- | IPV6_PEERDNS=yes | + | |
- | IPV6_PEERROUTES=yes | + | |
- | IPV6_FAILURE_FATAL=no | + | |
- | NAME=ip_fixe | + | |
- | UUID=fb3a11d9-4e03-4032-b26e-09d1195d2bcd | + | |
- | DEVICE=enp0s3 | + | |
- | ONBOOT=yes | + | |
- | </ | + | |
- | + | ||
- | La résolution des noms est donc inactive : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# ping www.free.fr | + | |
- | ping: unknown host www.free.fr | + | |
- | </ | + | |
- | + | ||
- | Modifiez donc la configuration du profil | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# nmcli connection mod ip_fixe ipv4.dns 8.8.8.8 | + | |
- | </ | + | |
- | + | ||
- | L' | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# cat / | + | |
- | TYPE=Ethernet | + | |
- | BOOTPROTO=none | + | |
- | DEFROUTE=yes | + | |
- | IPV4_FAILURE_FATAL=no | + | |
- | IPV6INIT=yes | + | |
- | IPV6_AUTOCONF=yes | + | |
- | IPV6_DEFROUTE=yes | + | |
- | IPV6_FAILURE_FATAL=no | + | |
- | NAME=ip_fixe | + | |
- | UUID=fb3a11d9-4e03-4032-b26e-09d1195d2bcd | + | |
- | DEVICE=enp0s3 | + | |
- | ONBOOT=yes | + | |
- | IPADDR=10.0.2.16 | + | |
- | PREFIX=24 | + | |
- | GATEWAY=10.0.2.2 | + | |
- | DNS1=8.8.8.8 | + | |
- | IPV6_PEERDNS=yes | + | |
- | IPV6_PEERROUTES=yes | + | |
- | </ | + | |
- | + | ||
- | Afin que la modification du serveur DNS soit prise en compte, re-démarrez le service NetworkManager : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# systemctl restart NetworkManager.service | + | |
- | [root@centos7 ~]# systemctl status NetworkManager.service | + | |
- | ● NetworkManager.service - Network Manager | + | |
- | | + | |
- | | + | |
- | Main PID: 8394 (NetworkManager) | + | |
- | | + | |
- | | + | |
- | + | ||
- | Aug 08 11:16:53 centos7.fenestros.loc NetworkManager[8394]: | + | |
- | Aug 08 11:16:53 centos7.fenestros.loc NetworkManager[8394]: | + | |
- | Aug 08 11:16:53 centos7.fenestros.loc NetworkManager[8394]: | + | |
- | Aug 08 11:16:53 centos7.fenestros.loc NetworkManager[8394]: | + | |
- | Aug 08 11:16:53 centos7.fenestros.loc NetworkManager[8394]: | + | |
- | Aug 08 11:16:53 centos7.fenestros.loc NetworkManager[8394]: | + | |
- | Aug 08 11:16:53 centos7.fenestros.loc NetworkManager[8394]: | + | |
- | Aug 08 11:16:53 centos7.fenestros.loc NetworkManager[8394]: | + | |
- | Aug 08 11:16:53 centos7.fenestros.loc NetworkManager[8394]: | + | |
- | Aug 08 11:16:53 centos7.fenestros.loc NetworkManager[8394]: | + | |
- | </ | + | |
- | + | ||
- | Vérifiez que le fichier **/ | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# cat / | + | |
- | # Generated by NetworkManager | + | |
- | search fenestros.loc | + | |
- | nameserver 8.8.8.8 | + | |
- | </ | + | |
- | + | ||
- | Dernièrement vérifiez la resolution des noms : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# ping www.free.fr | + | |
- | PING www.free.fr (212.27.48.10) 56(84) bytes of data. | + | |
- | 64 bytes from www.free.fr (212.27.48.10): | + | |
- | 64 bytes from www.free.fr (212.27.48.10): | + | |
- | 64 bytes from www.free.fr (212.27.48.10): | + | |
- | ^C | + | |
- | --- www.free.fr ping statistics --- | + | |
- | 3 packets transmitted, | + | |
- | rtt min/ | + | |
- | </ | + | |
- | + | ||
- | <WRAP center round important> | + | |
- | **Important** : Notez qu'il existe un front-end graphique en mode texte, **nmtui**, pour configurer NetworkManager. | + | |
</ | </ | ||
- | ====Ajouter une Deuxième Adresse IP à un Profil==== | + | Afin de procéder |
- | + | ||
- | Pour ajouter une deuxième adresse IP à un profil sous RHEL/CentOS 7, il convient | + | |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
+ | Domain 3 is being shutdown | ||
</ | </ | ||
- | Redémarrez la machine virtuelle puis en tant que root saisissez | + | Vérifiez ensuite |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | connection.id: | + | Id |
- | connection.uuid: | + | -------------------- |
- | connection.interface-name: | + | |
- | connection.type: | + | |
- | connection.autoconnect: | + | |
- | connection.autoconnect-priority: | + | |
- | connection.timestamp: | + | |
- | connection.read-only: | + | |
- | connection.permissions: | + | |
- | connection.zone: | + | |
- | connection.master: | + | |
- | connection.slave-type: | + | |
- | connection.autoconnect-slaves: | + | |
- | connection.secondaries: | + | |
- | connection.gateway-ping-timeout: | + | |
- | connection.metered: | + | |
- | 802-3-ethernet.port: | + | |
- | 802-3-ethernet.speed: | + | |
- | 802-3-ethernet.duplex: | + | |
- | 802-3-ethernet.auto-negotiate: | + | |
- | 802-3-ethernet.mac-address: | + | |
- | 802-3-ethernet.cloned-mac-address: | + | |
- | 802-3-ethernet.mac-address-blacklist: | + | |
- | 802-3-ethernet.mtu: | + | |
- | 802-3-ethernet.s390-subchannels: | + | |
- | 802-3-ethernet.s390-nettype: | + | |
- | 802-3-ethernet.s390-options: | + | |
- | 802-3-ethernet.wake-on-lan: 1 (default) | + | |
- | 802-3-ethernet.wake-on-lan-password: | + | |
- | ipv4.method: | + | |
- | ipv4.dns: | + | |
- | ipv4.dns-search: | + | |
- | ipv4.addresses: | + | |
- | ipv4.gateway: | + | |
- | ipv4.routes: | + | |
- | ipv4.route-metric: | + | |
- | ipv4.ignore-auto-routes: | + | |
- | ipv4.ignore-auto-dns: | + | |
- | ipv4.dhcp-client-id: | + | |
- | ipv4.dhcp-send-hostname: | + | |
- | ipv4.dhcp-hostname: | + | |
- | ipv4.never-default: | + | |
- | ipv4.may-fail: | + | |
- | ipv6.method: | + | |
- | ipv6.dns: | + | |
- | ipv6.dns-search: | + | |
- | ipv6.addresses: | + | |
- | ipv6.gateway: | + | |
- | ipv6.routes: | + | |
- | ipv6.route-metric: | + | |
- | ipv6.ignore-auto-routes: | + | |
- | ipv6.ignore-auto-dns: | + | |
- | ipv6.never-default: | + | |
- | ipv6.may-fail: | + | |
- | ipv6.ip6-privacy: | + | |
- | ipv6.dhcp-send-hostname: | + | |
- | ipv6.dhcp-hostname: | + | |
- | GENERAL.NAME: | + | |
- | GENERAL.UUID: | + | |
- | GENERAL.DEVICES: | + | |
- | GENERAL.STATE: | + | |
- | GENERAL.DEFAULT: | + | |
- | GENERAL.DEFAULT6: | + | |
- | GENERAL.VPN: | + | |
- | GENERAL.ZONE: | + | |
- | GENERAL.DBUS-PATH: | + | |
- | GENERAL.CON-PATH: | + | |
- | GENERAL.SPEC-OBJECT: | + | |
- | GENERAL.MASTER-PATH: | + | |
- | IP4.ADDRESS[1]: | + | |
- | IP4.ADDRESS[2]: | + | |
- | IP4.GATEWAY: | + | |
- | IP4.DNS[1]: | + | |
- | IP6.ADDRESS[1]: | + | |
- | IP6.GATEWAY: | + | |
- | </ | + | |
- | <WRAP center round important> | ||
- | **Important** : Notez l' | ||
- | </ | ||
- | |||
- | Consultez maintenant le contenu du fichier **/ | ||
- | |||
- | < | ||
- | [root@centos7 ~]# cat / | ||
- | TYPE=Ethernet | ||
- | BOOTPROTO=none | ||
- | DEFROUTE=yes | ||
- | IPV4_FAILURE_FATAL=no | ||
- | IPV6INIT=yes | ||
- | IPV6_AUTOCONF=yes | ||
- | IPV6_DEFROUTE=yes | ||
- | IPV6_FAILURE_FATAL=no | ||
- | NAME=ip_fixe | ||
- | UUID=fb3a11d9-4e03-4032-b26e-09d1195d2bcd | ||
- | DEVICE=enp0s3 | ||
- | ONBOOT=yes | ||
- | DNS1=8.8.8.8 | ||
- | IPADDR=10.0.2.16 | ||
- | PREFIX=24 | ||
- | IPADDR1=192.168.1.2 | ||
- | PREFIX1=24 | ||
- | GATEWAY=10.0.2.2 | ||
- | IPV6_PEERDNS=yes | ||
- | IPV6_PEERROUTES=yes | ||
</ | </ | ||
- | <WRAP center round important> | + | Utilisez la commande |
- | **Important** : Notez l' | + | |
- | </WRAP> | + | |
- | + | ||
- | ====La Commande hostname==== | + | |
- | + | ||
- | La procédure de la modification du hostname est simplifiée et sa prise en compte est immédiate | + | |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | [root@centos7 ~]# cat /etc/hostname | + | Allocating ' |
- | centos.fenestros.loc | + | |
- | [root@centos7 ~]# hostname | + | |
- | centos.fenestros.loc | + | |
- | [root@centos7 ~]# nmcli general hostname centos7.fenestros.loc | + | |
- | [root@centos7 ~]# cat /etc/hostname | + | |
- | centos7.fenestros.loc | + | |
- | [root@centos7 ~]# hostname | + | |
- | centos7.fenestros.loc | + | |
- | </ | + | |
- | ====La Commande ip==== | + | Clone ' |
- | + | ||
- | Sous RHEL/CentOS 7 la commande **ip** est préférée par rapport à la commande ifconfig : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# ip address | + | |
- | 1: lo: < | + | |
- | link/ | + | |
- | inet 127.0.0.1/8 scope host lo | + | |
- | | + | |
- | inet6 ::1/128 scope host | + | |
- | | + | |
- | 2: enp0s3: < | + | |
- | link/ether 08: | + | |
- | inet 10.0.2.16/ | + | |
- | | + | |
- | inet 192.168.1.2/ | + | |
- | | + | |
- | inet6 fe80:: | + | |
- | | + | |
- | [root@centos7 ~]# ip addr | + | |
- | 1: lo: < | + | |
- | link/ | + | |
- | inet 127.0.0.1/8 scope host lo | + | |
- | | + | |
- | inet6 ::1/128 scope host | + | |
- | | + | |
- | 2: enp0s3: < | + | |
- | link/ether 08: | + | |
- | inet 10.0.2.16/ | + | |
- | | + | |
- | inet 192.168.1.2/ | + | |
- | | + | |
- | inet6 fe80:: | + | |
- | | + | |
</ | </ | ||
- | ===Options de la Commande ip=== | + | <WRAP center round important |
- | + | **Important** : Notez la rapidité de la création du clone par rapport à la lenteur de la création d'une VM à partir d'une image ISO. | |
- | Les options de cette commande sont : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# ip --help | + | |
- | Usage: ip [ OPTIONS ] OBJECT { COMMAND | help } | + | |
- | ip [ -force ] -batch filename | + | |
- | where OBJECT := { link | addr | addrlabel | route | rule | neigh | ntable | | + | |
- | | + | |
- | netns | l2tp | tcp_metrics | token } | + | |
- | | + | |
- | -f[amily] { inet | inet6 | ipx | dnet | bridge | link } | | + | |
- | -4 | -6 | -I | -D | -B | -0 | | + | |
- | -l[oops] { maximum-addr-flush-attempts } | | + | |
- | -o[neline] | -t[imestamp] | -b[atch] [filename] | | + | |
- | -rc[vbuf] [size]} | + | |
- | + | ||
- | </ | + | |
- | + | ||
- | ====Activer/ | + | |
- | + | ||
- | Deux commandes existent pour désactiver et activer manuellement une interface réseau : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# nmcli device disconnect enp0s3 | + | |
- | [root@centos7 ~]# nmcli device connect enp0s3 | + | |
- | </ | + | |
- | + | ||
- | ====Routage Statique==== | + | |
- | + | ||
- | ===La commande ip=== | + | |
- | + | ||
- | Sous RHEL/CentOS 7, pour supprimer la route vers le réseau 192.168.1.0 il convient d' | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# ip route | + | |
- | default via 10.0.2.2 dev enp0s3 | + | |
- | 10.0.2.0/24 dev enp0s3 | + | |
- | 192.168.1.0/ | + | |
- | + | ||
- | [root@centos7 ~]# ip route del 192.168.1.0/ | + | |
- | + | ||
- | [root@centos7 ~]# ip route | + | |
- | default via 10.0.2.2 dev enp0s3 | + | |
- | 10.0.2.0/24 dev enp0s3 | + | |
- | </ | + | |
- | + | ||
- | Pour ajouter la route vers le réseau 192.168.1.0 : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# ip route add 192.168.1.0/ | + | |
- | + | ||
- | [root@centos7 ~]# ip route | + | |
- | default via 10.0.2.2 dev enp0s3 | + | |
- | 10.0.2.0/24 dev enp0s3 | + | |
- | 192.168.1.0/ | + | |
- | </ | + | |
- | + | ||
- | <WRAP center round important> | + | |
- | La commande utilisée pour ajouter une passerelle par défaut prend la forme suivante | + | |
</ | </ | ||
- | ===Activer/ | + | La sortie de la commande **virsh list** ne montre pas les VMs en état d'arrêt |
- | + | ||
- | Pour activer le routage sur le serveur, il convient | + | |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | [root@centos7 ~]# cat / | + | Id |
- | 1 | + | -------------------- |
- | </ | + | |
- | Pour désactiver le routage sur le serveur, il convient de désactiver la retransmission des paquets: | ||
- | |||
- | < | ||
- | [root@centos7 ~]# echo 0 > / | ||
- | [root@centos7 ~]# cat / | ||
- | 0 | ||
</ | </ | ||
- | =====Diagnostique du Réseau===== | + | Pour voir la liste des VMs, peu importe leurs états, utilisez |
- | + | ||
- | ====ping==== | + | |
- | + | ||
- | Pour tester | + | |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | PING 10.0.2.2 (10.0.2.2) 56(84) bytes of data. | + | Id |
- | 64 bytes from 10.0.2.2: icmp_seq=1 ttl=63 time=0.602 ms | + | -------------------------- |
- | 64 bytes from 10.0.2.2: icmp_seq=2 ttl=63 time=0.375 ms | + | - testvm1 |
- | 64 bytes from 10.0.2.2: icmp_seq=3 ttl=63 time=0.512 ms | + | - testvm2 |
- | 64 bytes from 10.0.2.2: icmp_seq=4 ttl=63 time=0.547 ms | + | </ |
- | ^C | + | |
- | --- 10.0.2.2 ping statistics | + | Le **State** peut être une des valeurs suivantes : |
- | 4 packets transmitted, | + | |
- | rtt min/ | + | |
- | </ | + | |
- | ===Options de la commande ping=== | + | * **running** - la machine virtuelle est active, |
+ | * **blocked** ou **blocking** - la machine virtuelle est en attente d'E/S ou l' | ||
+ | * **paused** - la machine virtuelle est suspendue, | ||
+ | * **shutdown** - la machine virtuelle est en cours d' | ||
+ | * **shut off** - la machine virtuelle est éteinte et elle n' | ||
+ | * **crashed** - la machine virtuelle a crashée et est arrêtée. | ||
+ | |||
+ | =====LAB #2 - Gestion des Snapshots===== | ||
- | Les options | + | La création |
- | < | + | Il existe deux types de snapshots |
- | [root@centos7 ~]# ping --help | + | |
- | ping: invalid option -- ' | + | |
- | Usage: ping [-aAbBdDfhLnOqrRUvV] [-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 | + | |
- | </ | + | |
- | ====netstat -i==== | + | * **Internal**, |
+ | * uniquement possibles avec les images qcow2, | ||
+ | * la VM est mise en pause pendant la création du snapshot, | ||
+ | * ne fonctionne pas avec des pools de stockage de type LVM. | ||
+ | * **External**, | ||
+ | * sont basés sur le concept COW (**C**opy **O**n **W**rite), | ||
+ | * l' | ||
+ | * une image de type overlay en mode lecture/ | ||
+ | * est compatible avec n’importe lequel des formats de l' | ||
- | Pour visualiser les statistiques réseaux, vous disposez de la commande **netstat** : | + | ====2.1 - Création d'un Snapshot - VM Arrêté==== |
- | < | + | Utilisez la commande **virsh snapshot-list** pour consulter |
- | [root@centos7 ~]# netstat | + | |
- | Kernel Interface table | + | |
- | Iface MTU RX-OK RX-ERR RX-DRP RX-OVR | + | |
- | enp0s3 | + | |
- | lo | + | |
- | </ | + | |
- | + | ||
- | ===Options de la commande netstat=== | + | |
- | + | ||
- | Les options de cette commande sont : | + | |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | usage: netstat [-vWeenNcCF] [< | + | |
- | | + | ------------------------------- |
- | | + | |
- | -r, --route | ||
- | -I, --interfaces=< | ||
- | -i, --interfaces | ||
- | -g, --groups | ||
- | -s, --statistics | ||
- | -M, --masquerade | ||
- | |||
- | -v, --verbose | ||
- | -W, --wide | ||
- | -n, --numeric | ||
- | --numeric-hosts | ||
- | --numeric-ports | ||
- | --numeric-users | ||
- | -N, --symbolic | ||
- | -e, --extend | ||
- | -p, --programs | ||
- | -o, --timers | ||
- | -c, --continuous | ||
- | |||
- | -l, --listening | ||
- | -a, --all display all sockets (default: connected) | ||
- | -F, --fib display Forwarding Information Base (default) | ||
- | -C, --cache | ||
- | -Z, --context | ||
- | |||
- | < | ||
- | | ||
- | < | ||
- | 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) | ||
</ | </ | ||
- | ====La commande | + | La création d'un snapshot se fait grâce à l' |
- | La commande ping est à la base de la commande | + | * **--domain**, |
+ | * le domaine | ||
+ | | ||
+ | * le nom attribué au snapshot. | ||
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | traceroute to www.i2tch.eu (217.160.122.33), | + | Domain snapshot testvm1-snap-03092021 created |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | 7 172.19.132.146 (172.19.132.146) | + | |
- | | + | |
- | | + | |
- | 10 * * * | + | |
- | 11 * * * | + | |
- | 12 * * * | + | |
- | 13 * * * | + | |
- | 14 * * * | + | |
- | 15 * * * | + | |
- | 16 * * * | + | |
- | 17 * * * | + | |
- | 18 * * * | + | |
- | ... | + | |
</ | </ | ||
- | ===Options de la commande traceroute=== | + | Vérifiez que le snapshot a bien été pris en compte |
- | + | ||
- | Les options de cette commande sont : | + | |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | Usage: | + | Name Creation Time State |
- | | + | -------------------------------------------------------------- |
- | Options: | + | testvm1-snap-03092021 |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | Start from the first_ttl hop (instead from 1) | + | |
- | | + | |
- | Route packets through the specified gateway | + | |
- | (maximum 8 for IPv4 and 127 for IPv6) | + | |
- | | + | |
- | | + | |
- | | + | |
- | Specify a network interface to operate with | + | |
- | | + | |
- | Set the max number of hops (max TTL to be | + | |
- | reached). Default is 30 | + | |
- | | + | |
- | Set the number of probes to be tried | + | |
- | simultaneously (default is 16) | + | |
- | | + | |
- | | + | |
- | initial udp port value for " | + | |
- | (incremented by each probe, default is 33434), or | + | |
- | initial seq for " | + | |
- | default from 1), or some constant destination | + | |
- | port for other methods (with default of 80 for | + | |
- | " | + | |
- | | + | |
- | traffic class) value for outgoing packets | + | |
- | | + | |
- | Use specified flow_label for IPv6 packets | + | |
- | | + | |
- | Set the number of seconds to wait for response to | + | |
- | a probe (default is 5.0). Non-integer (float | + | |
- | point) values allowed too | + | |
- | | + | |
- | 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 | + | |
- | | + | |
- | Use source src_addr for outgoing packets | + | |
- | -z sendwait | + | |
- | Minimal time interval between probes (default 0). | + | |
- | If the value is more than 10, then it specifies a | + | |
- | number in milliseconds, | + | |
- | seconds (float point values allowed too) | + | |
- | | + | |
- | -A --as-path-lookups | + | |
- | print results directly after the corresponding | + | |
- | addresses | + | |
- | -M name --module=name | + | |
- | for traceroute operations. Most methods have | + | |
- | their shortcuts (`-I' means `-M icmp' etc.) | + | |
- | -O OPTS, | + | |
- | Use module-specific option OPTS for the | + | |
- | traceroute module. Several OPTS allowed, | + | |
- | separated by comma. If OPTS is " | + | |
- | about available options | + | |
- | --sport=num | + | |
- | `-N 1' | + | |
- | --fwmark=num | + | |
- | -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 | + | |
- | is 33434) | + | |
- | -P prot --protocol=prot | + | |
- | --mtu | + | |
- | `-F -N 1' | + | |
- | --back | + | |
- | print if it differs | + | |
- | -V --version | + | |
- | --help | + | |
- | + | ||
- | Arguments: | + | |
- | + | + | |
- | packetlen | + | |
- | header plus 40). Can be ignored or increased to a minimal | + | |
- | allowed value | + | |
</ | </ | ||
- | =====Connexions à Distance===== | + | <WRAP center round important |
- | + | **Important** : Notez que l'état est **shutoff**. | |
- | ==== Telnet ==== | + | |
- | + | ||
- | <WRAP center round important> | + | |
- | La commande | + | |
</ | </ | ||
- | La commande **telnet** est utilisée pour établir une connexion à distance avec un serveur telnet : | + | Pour obtenir |
- | + | ||
- | < | + | |
- | # telnet numero_ip | + | |
- | </ | + | |
- | + | ||
- | <WRAP center round important> | + | |
- | Le service telnet revient à une redirection | + | |
- | </ | + | |
- | + | ||
- | ===Options | + | |
- | + | ||
- | Les options de cette commande sont : | + | |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | telnet: invalid option | + | Name: testvm1-snap-03092021 |
- | Usage: telnet [-8] [-E] [-L] [-S tos] [-a] [-c] [-d] [-e char] [-l user] | + | Domain: |
- | [-n tracefile] [-b hostalias ] [-r] | + | Current: |
- | [host-name [port]] | + | State: |
+ | Location: | ||
+ | Parent: | ||
+ | Children: | ||
+ | Descendants: | ||
+ | Metadata: | ||
</ | </ | ||
- | ==== wget ==== | + | ====2.2 - Création d'un Snapshot - VM en Cours d' |
- | La commande **wget** | + | Il est aussi possible de prendre des snapshot d'une VM en cours d' |
- | < | + | Démarrez donc la VM **testvm2** avec la commande |
- | [root@centos7 ~]# wget https:// | + | |
- | --2017-06-22 16: | + | |
- | Resolving www.dropbox.com (www.dropbox.com)... 162.125.65.1 | + | |
- | Connecting to www.dropbox.com (www.dropbox.com)|162.125.65.1|: | + | |
- | HTTP request sent, awaiting response... 302 Found | + | |
- | Location: https:// | + | |
- | --2017-06-22 16: | + | |
- | Resolving dl.dropboxusercontent.com (dl.dropboxusercontent.com)... 162.125.65.6 | + | |
- | Connecting to dl.dropboxusercontent.com (dl.dropboxusercontent.com)|162.125.65.6|: | + | |
- | HTTP request sent, awaiting response... 200 OK | + | |
- | Length: 17 [text/ | + | |
- | Saving to: ‘fichier_test? | + | |
- | + | ||
- | 100%[====================================================================================> | + | |
- | + | ||
- | 2017-06-22 16:53:41 (480 KB/s) - ‘fichier_test? | + | |
- | </ | + | |
- | + | ||
- | ===Options de la commande | + | |
- | + | ||
- | Les options de cette commande sont : | + | |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | GNU Wget 1.14, a non-interactive network retriever. | + | Domain testvm2 started |
- | Usage: wget [OPTION]... [URL]... | + | |
- | Mandatory arguments to long options are mandatory for short options too. | ||
- | |||
- | Startup: | ||
- | -V, --version | ||
- | -h, --help | ||
- | -b, --background | ||
- | -e, --execute=COMMAND | ||
- | |||
- | Logging and input file: | ||
- | -o, --output-file=FILE | ||
- | -a, --append-output=FILE | ||
- | -d, --debug | ||
- | -q, --quiet | ||
- | -v, --verbose | ||
- | -nv, --no-verbose | ||
- | | ||
- | -i, --input-file=FILE | ||
- | -F, --force-html | ||
- | -B, --base=URL | ||
- | | ||
- | | ||
- | |||
- | Download: | ||
- | -t, --tries=NUMBER | ||
- | | ||
- | -O, --output-document=FILE | ||
- | -nc, --no-clobber | ||
- | | ||
- | -c, --continue | ||
- | | ||
- | -N, --timestamping | ||
- | | ||
- | --no-use-server-timestamps | ||
- | the one on the server. | ||
- | -S, --server-response | ||
- | | ||
- | -T, --timeout=SECONDS | ||
- | | ||
- | | ||
- | | ||
- | -w, --wait=SECONDS | ||
- | | ||
- | | ||
- | | ||
- | -Q, --quota=NUMBER | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | -4, --inet4-only | ||
- | -6, --inet6-only | ||
- | | ||
- | one of IPv6, IPv4, or none. | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | Directories: | ||
- | -nd, --no-directories | ||
- | -x, --force-directories | ||
- | -nH, --no-host-directories | ||
- | | ||
- | -P, --directory-prefix=PREFIX | ||
- | | ||
- | |||
- | HTTP options: | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | this is `index.html' | ||
- | -E, --adjust-extension | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | -U, --user-agent=AGENT | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | HTTPS (SSL/TLS) options: | ||
- | | ||
- | SSLv3, and TLSv1. | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | FTP options: | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | WARC options: | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | WARC writer. | ||
- | |||
- | Recursive download: | ||
- | -r, --recursive | ||
- | -l, --level=NUMBER | ||
- | | ||
- | -k, --convert-links | ||
- | local files. | ||
- | --backups=N | ||
- | -K, --backup-converted | ||
- | -m, --mirror | ||
- | -p, --page-requisites | ||
- | | ||
- | |||
- | Recursive accept/ | ||
- | -A, --accept=LIST | ||
- | -R, --reject=LIST | ||
- | | ||
- | | ||
- | | ||
- | -D, --domains=LIST | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | -H, --span-hosts | ||
- | -L, --relative | ||
- | -I, --include-directories=LIST | ||
- | --trust-server-names | ||
- | url last component. | ||
- | -X, --exclude-directories=LIST | ||
- | -np, --no-parent | ||
- | |||
- | Mail bug reports and suggestions to < | ||
</ | </ | ||
- | ==== ftp ==== | + | Vérifiez ensuite |
- | + | ||
- | <WRAP center round important> | + | |
- | La commande **ftp** n'est pas installée par défaut sous CentOS 7. Installez-le à l'aide de la commande **yum install ftp** en tant que root. | + | |
- | </ | + | |
- | + | ||
- | La commande **ftp** est utilisée pour le transfert de fichiers: | + | |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | Connected to ftp2.fenestros.com (213.186.33.14). | + | Id Name State |
- | 220 anonymous.ftp.ovh.net NcFTPd Server (licensed copy) ready. | + | -------------------------- |
- | Name (ftp2.fenestros.com: | + | 4 testvm2 |
- | 331 Guest login ok, send your complete e-mail address as password. | + | - testvm1 |
- | Password: | + | |
- | 230 Logged in anonymously. | + | |
- | Remote system type is UNIX. | + | |
- | Using binary mode to transfer files. | + | |
- | ftp> | + | |
- | </ | + | |
- | + | ||
- | Une fois connecté, il convient d' | + | |
- | + | ||
- | < | + | |
- | ftp> help | + | |
- | Commands may be abbreviated. | + | |
- | ! 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> | ||
</ | </ | ||
- | Le caractère | + | Créez un snapshot de **testvm2** : |
< | < | ||
- | ftp> !pwd | + | [root@centos8 ~]# virsh snapshot-create-as --domain testvm2 --name " |
- | /root | + | Domain snapshot testvm2-snap-03092021 created |
</ | </ | ||
- | Pour transférer un fichier vers le serveur, il convient d' | + | Consultez |
- | + | ||
- | < | + | |
- | ftp> put nom_fichier_local nom_fichier_distant | + | |
- | </ | + | |
- | + | ||
- | 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: | + | |
- | + | ||
- | < | + | |
- | ftp> mput nom*.* | + | |
- | </ | + | |
- | + | ||
- | Pour transférer un fichier du serveur, il convient d' | + | |
- | + | ||
- | < | + | |
- | ftp> get nom_fichier | + | |
- | </ | + | |
- | + | ||
- | 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' | + | |
- | + | ||
- | < | + | |
- | ftp> del nom_fichier | + | |
- | </ | + | |
- | + | ||
- | Pour fermer la session, il convient d' | + | |
< | < | ||
- | ftp> quit | + | [root@centos8 |
- | [root@centos7 | + | |
+ | -------------------------------------------------------------- | ||
+ | | ||
</ | </ | ||
- | ====SSH==== | + | Pour obtenir |
- | + | ||
- | ===Introduction=== | + | |
- | + | ||
- | La commande **[[wpfr> | + | |
- | + | ||
- | * Le **serveur SSH** | + | |
- | * le démon sshd, qui s' | + | |
- | * Le **client SSH** | + | |
- | * ssh ou scp, qui assure la connexion et le dialogue avec le serveur, | + | |
- | * La **session** qui représente la connexion courante et qui commence juste après l' | + | |
- | * Les **clefs** | + | |
- | * **Couple de clef utilisateur asymétriques** et persistantes qui assurent l' | + | |
- | * **Clef hôte asymétrique et persistante** garantissant l' | + | |
- | * **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 serveur. Elle est détruite en fin de session. SSH-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 | + | |
- | + | ||
- | * Le client contacte | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | * 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' | + | |
- | * 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' | + | |
- | + | ||
- | Afin de s' | + | |
- | + | ||
- | * **Kerberos**, | + | |
- | * **Rhosts**, | + | |
- | * **%%RhostsRSA%%**, | + | |
- | * Par **clef asymétrique**, | + | |
- | * **TIS**, | + | |
- | * Par **mot de passe**. | + | |
- | + | ||
- | ==SSH-2== | + | |
- | + | ||
- | SSH-2 utilise **DSA** ou **RSA**. Il assure l' | + | |
- | + | ||
- | * **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' | + | |
- | + | ||
- | * Par **clef asymétrique**, | + | |
- | * Identique à SSH-1 sauf avec l' | + | |
- | * **%%RhostsRSA%%**, | + | |
- | * Par **mot de passe**. | + | |
- | + | ||
- | ==Options de la commande== | + | |
- | + | ||
- | Les options de cette commande sont : | + | |
< | < | ||
- | [root@centos6 | + | [root@centos8 |
- | usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec] | + | Name: |
- | [-D [bind_address: | + | Domain: testvm2 |
- | [-i identity_file] [-L [bind_address:]port:host:hostport] | + | Current: yes |
- | [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] | + | State: |
- | [-R [bind_address:]port:host: | + | Location: |
- | [-w local_tun[:remote_tun]] [user@]hostname [command] | + | Parent: |
+ | Children: 0 | ||
+ | Descendants: 0 | ||
+ | Metadata: yes | ||
</ | </ | ||
- | ===L' | + | <WRAP center round important 60%> |
- | + | **Important** : Notez que le **State** est **running** par rapport | |
- | L' | + | |
- | + | ||
- | Avantage: | + | |
- | * Aucune configuration de clef asymétrique n'est nécessaire. | + | |
- | + | ||
- | Inconvénients: | + | |
- | | + | |
- | | + | |
- | + | ||
- | ===L' | + | |
- | + | ||
- | | + | |
- | | + | |
- | * Dans le cas où une correspondance n'est pas trouvée, le serveur met fin à la communication, | + | |
- | | + | |
- | * Le **client** reçoit le challenge et le décrypte avec la partie privée de sa clé. Il combine le challenge avec l' | + | |
- | | + | |
- | + | ||
- | ===Installation=== | + | |
- | + | ||
- | Pour installer/ | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# yum install openssh-server | + | |
- | Loaded plugins: fastestmirror, | + | |
- | Loading mirror speeds from cached hostfile | + | |
- | * base: centos.mirror.fr.planethoster.net | + | |
- | * extras: ftp.ciril.fr | + | |
- | * updates: centos.mirrors.ovh.net | + | |
- | Package openssh-server-6.6.1p1-25.el7_2.x86_64 already installed and latest version | + | |
- | Nothing to do | + | |
- | </ | + | |
- | + | ||
- | <WRAP center round important> | + | |
- | **Important** - Pour les stations | + | |
</ | </ | ||
- | ==Options de la commande== | + | ====2.3 - Restauration d'un Snapshot==== |
- | Les options de la commande | + | Pour restaurer un snapshot |
- | + | ||
- | < | + | |
- | SYNOPSIS | + | |
- | sshd [-46DdeiqTt] [-b bits] [-C connection_spec] [-f config_file] [-g login_grace_time] [-h host_key_file] [-k key_gen_time] [-o option] [-p port] [-u len] | + | |
- | </ | + | |
- | + | ||
- | ===Configuration=== | + | |
- | + | ||
- | <WRAP center round important> | + | |
- | **Important** - La configuration doit s' | + | |
- | </ | + | |
- | + | ||
- | ==Serveur== | + | |
- | + | ||
- | La configuration du serveur s' | + | |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | # $OpenBSD: sshd_config, | + | Domain testvm2 is being shutdown |
- | # This is the sshd server system-wide configuration file. See | + | [root@centos8 ~]# virsh list --all |
- | # sshd_config(5) for more information. | + | Id |
- | + | -------------------------- | |
- | # This sshd was compiled with PATH=/ | + | |
- | + | | |
- | # The strategy used for options in the default sshd_config shipped with | + | |
- | # OpenSSH is to specify options with their default value where | + | |
- | # possible, but leave them commented. | + | |
- | # default value. | + | |
- | + | ||
- | # 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 | + | |
- | # | + | |
- | #Port 22 | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | + | ||
- | # The default requires explicit activation of protocol 1 | + | |
- | #Protocol 2 | + | |
- | + | ||
- | # HostKey for protocol version 1 | + | |
- | #HostKey / | + | |
- | # HostKeys for protocol version 2 | + | |
- | HostKey / | + | |
- | #HostKey / | + | |
- | HostKey / | + | |
- | HostKey / | + | |
- | + | ||
- | # Lifetime and size of ephemeral version 1 server key | + | |
- | # | + | |
- | # | + | |
- | + | ||
- | # Ciphers and keying | + | |
- | #RekeyLimit default none | + | |
- | + | ||
- | # Logging | + | |
- | # obsoletes QuietMode and FascistLogging | + | |
- | # | + | |
- | SyslogFacility AUTHPRIV | + | |
- | #LogLevel INFO | + | |
- | + | ||
- | # Authentication: | + | |
- | + | ||
- | # | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | + | ||
- | # | + | |
- | # | + | |
- | + | ||
- | # The default is to check both .ssh/ | + | |
- | # but this is overridden so installations will only check .ssh/ | + | |
- | AuthorizedKeysFile .ssh/ | + | |
- | + | ||
- | # | + | |
- | + | ||
- | # | + | |
- | # | + | |
- | + | ||
- | # For this to work you will also need host keys in / | + | |
- | # | + | |
- | # similar for protocol version 2 | + | |
- | # | + | |
- | # Change to yes if you don't trust ~/ | + | |
- | # RhostsRSAAuthentication and HostbasedAuthentication | + | |
- | # | + | |
- | # Don't read the user's ~/.rhosts and ~/.shosts files | + | |
- | # | + | |
- | + | ||
- | # To disable tunneled clear text passwords, change to no here! | + | |
- | # | + | |
- | # | + | |
- | PasswordAuthentication yes | + | |
- | + | ||
- | # Change to no to disable s/key passwords | + | |
- | # | + | |
- | ChallengeResponseAuthentication no | + | |
- | + | ||
- | # Kerberos options | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | + | ||
- | # GSSAPI options | + | |
- | GSSAPIAuthentication yes | + | |
- | GSSAPICleanupCredentials no | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | + | ||
- | # Set this to ' | + | |
- | # and session processing. If this is enabled, PAM authentication will | + | |
- | # be allowed through the ChallengeResponseAuthentication and | + | |
- | # PasswordAuthentication. | + | |
- | # PAM authentication via ChallengeResponseAuthentication may bypass | + | |
- | # the setting of " | + | |
- | # If you just want the PAM account and session checks to run without | + | |
- | # PAM authentication, | + | |
- | # and ChallengeResponseAuthentication to ' | + | |
- | # WARNING: ' | + | |
- | # problems. | + | |
- | UsePAM yes | + | |
- | + | ||
- | # | + | |
- | # | + | |
- | # | + | |
- | X11Forwarding yes | + | |
- | # | + | |
- | # | + | |
- | #PermitTTY yes | + | |
- | #PrintMotd yes | + | |
- | # | + | |
- | # | + | |
- | #UseLogin no | + | |
- | UsePrivilegeSeparation sandbox # Default for new installations. | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | #UseDNS yes | + | |
- | #PidFile / | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | # | + | |
- | + | ||
- | # 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 / | + | |
- | + | ||
- | # Example of overriding settings on a per-user basis | + | |
- | #Match User anoncvs | + | |
- | # | + | |
- | # | + | |
- | # PermitTTY no | + | |
- | # | + | |
</ | </ | ||
- | Pour ôter les lignes de commentaires dans ce fichier, utilisez la commande suivante | + | Restaurez ensuite le snapshot |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | [root@centos7 tmp]# cat sshd_config | + | |
- | HostKey / | + | |
- | HostKey / | + | |
- | HostKey / | + | |
- | SyslogFacility AUTHPRIV | + | |
- | AuthorizedKeysFile .ssh/ | + | |
- | PasswordAuthentication yes | + | |
- | ChallengeResponseAuthentication no | + | |
- | GSSAPIAuthentication yes | + | |
- | GSSAPICleanupCredentials no | + | |
- | UsePAM yes | + | |
- | X11Forwarding yes | + | |
- | UsePrivilegeSeparation sandbox # Default for new installations. | + | |
- | 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 / | + | |
- | </ | + | |
- | Pour sécuriser le serveur ssh, ajoutez ou modifiez les directives suivantes : | + | [root@centos8 |
- | + | Id | |
- | < | + | -------------------------- |
- | AllowGroups adm | + | |
- | Banner / | + | |
- | HostbasedAuthentication no | + | |
- | IgnoreRhosts yes | + | |
- | LoginGraceTime 60 | + | |
- | LogLevel INFO | + | |
- | PermitEmptyPasswords no | + | |
- | PermitRootLogin no | + | |
- | PrintLastLog yes | + | |
- | Protocol 2 | + | |
- | StrictModes yes | + | |
- | X11Forwarding no | + | |
- | </ | + | |
- | + | ||
- | Votre fichier ressemblera à celui-ci : | + | |
- | + | ||
- | < | + | |
- | AllowGroups adm | + | |
- | Banner / | + | |
- | HostbasedAuthentication no | + | |
- | IgnoreRhosts yes | + | |
- | LoginGraceTime 60 | + | |
- | LogLevel INFO | + | |
- | PermitEmptyPasswords no | + | |
- | PermitRootLogin no | + | |
- | PrintLastLog yes | + | |
- | Protocol 2 | + | |
- | StrictModes yes | + | |
- | X11Forwarding no | + | |
- | HostKey / | + | |
- | HostKey / | + | |
- | HostKey / | + | |
- | SyslogFacility AUTHPRIV | + | |
- | AuthorizedKeysFile .ssh/ | + | |
- | PasswordAuthentication yes | + | |
- | ChallengeResponseAuthentication no | + | |
- | GSSAPIAuthentication yes | + | |
- | GSSAPICleanupCredentials no | + | |
- | UsePAM yes | + | |
- | UsePrivilegeSeparation sandbox # Default for new installations. | + | |
- | 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 / | + | |
- | </ | + | |
- | + | ||
- | <WRAP center round todo> | + | |
- | **A Faire** - Renommez le fichier **/ | + | |
- | </ | + | |
- | + | ||
- | Pour générer les clefs sur le serveur saisissez la commande suivante en tant que **root**: | + | |
- | + | ||
- | Lors de la génération des clefs, la passphrase doit être **vide**. | + | |
- | + | ||
- | < | + | |
- | [root@centos7 | + | |
- | Generating public/ | + | |
- | Enter file in which to save the key (/ | + | |
- | Enter passphrase (empty for no passphrase): | + | |
- | Enter same passphrase again: | + | |
- | Your identification has been saved in / | + | |
- | Your public key has been saved in / | + | |
- | The key fingerprint is: | + | |
- | d5: | + | |
- | The key's randomart image is: | + | |
- | +--[ DSA 1024]----+ | + | |
- | | +oBB.| | + | |
- | | o *.o*| | + | |
- | | . o +.o| | + | |
- | | | + | |
- | | S .=..| | + | |
- | | .o.| | + | |
- | | o| | + | |
- | | E| | + | |
- | | | | + | |
- | +-----------------+ | + | |
</ | </ | ||
- | <WRAP center round important> | + | <WRAP center round important |
- | Le chemin à indiquer pour le fichier est **/ | + | **Important** : Notez que le **State** est **running** après la restauration du snapshot. |
</ | </ | ||
- | Les clefs publiques générées possèdent l' | + | Connectez-vous à la VM grâce à la commande |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | moduli | + | Connected to domain testvm2 |
- | ssh_config | + | Escape character is ^] |
- | </ | + | |
- | Re-démarrez ensuite le service sshd : | + | CentOS Linux 8 |
+ | Kernel 4.18.0-305.12.1.el8_4.x86_64 on an x86_64 | ||
- | < | + | testvm1 login: root |
- | [root@centos7 | + | Mot de passe : fenestros |
+ | Dernière connexion : | ||
+ | [root@testvm1 | ||
+ | ... | ||
+ | [root@testvm1 ~]# [ALT GR]+[CTRL]+[)] | ||
+ | [root@centos8 ~]# | ||
</ | </ | ||
- | Saisissez maintenant les commandes suivantes en tant que **trainee** : | + | ====2.4 - Suppression de Snapshots==== |
- | <WRAP center round important> | + | Les snapshots peuvent être supprimés grâce à l' |
- | Lors de la génération des clefs, la passphrase doit être **vide**. | + | |
- | </ | + | |
< | < | ||
- | [trainee@centos7 | + | [root@centos8 |
- | Generating public/ | + | Domain snapshot testvm1-snap-03092021 deleted |
- | Enter file in which to save the key (/ | + | |
- | Created directory '/ | + | |
- | Enter passphrase (empty for no passphrase): | + | |
- | Enter same passphrase again: | + | |
- | Your identification has been saved in / | + | |
- | Your public key has been saved in / | + | |
- | The key fingerprint is: | + | |
- | 97: | + | |
- | The key's randomart image is: | + | |
- | +--[ DSA 1024]----+ | + | |
- | | .. ..=| | + | |
- | | | + | |
- | | ... | + | |
- | | o.. ..E.| | + | |
- | | S.o..oo .| | + | |
- | | .oo o.+. | | + | |
- | | . . =. | | + | |
- | | . | | + | |
- | | | | + | |
- | +-----------------+ | + | |
- | [trainee@centos7 ~]$ ssh-keygen -t rsa | + | |
- | Generating public/ | + | |
- | Enter file in which to save the key (/ | + | |
- | Enter passphrase (empty for no passphrase): | + | |
- | Enter same passphrase again: | + | |
- | Your identification has been saved in / | + | |
- | Your public key has been saved in / | + | |
- | The key fingerprint is: | + | |
- | 80: | + | |
- | The key's randomart image is: | + | |
- | +--[ RSA 2048]----+ | + | |
- | | +o=o.. | + | |
- | | * Xo+o. | | + | |
- | | . B.Bo. | | + | |
- | | | + | |
- | | o.S | | + | |
- | | | + | |
- | | | | + | |
- | | | | + | |
- | | | | + | |
- | +-----------------+ | + | |
- | [trainee@centos7 ~]$ ssh-keygen -t ecdsa | + | |
- | Generating public/ | + | |
- | Enter file in which to save the key (/ | + | |
- | Enter passphrase (empty for no passphrase): | + | |
- | Enter same passphrase again: | + | |
- | Your identification has been saved in / | + | |
- | Your public key has been saved in / | + | |
- | The key fingerprint is: | + | |
- | 41: | + | |
- | The key's randomart image is: | + | |
- | +--[ECDSA | + | |
- | | ..... .. o+ | | + | |
- | | ... . .. o . | | + | |
- | |. .. . = .| | + | |
- | | o E . = . | | + | |
- | | . | + | |
- | | . | + | |
- | | o . o . | | + | |
- | | . o . . | | + | |
- | | ..... . | | + | |
- | +-----------------+ | + | |
- | [trainee@centos7 ~]$ ssh-keygen -t ed25519 | + | |
- | Generating public/ | + | |
- | Enter file in which to save the key (/ | + | |
- | Enter passphrase (empty for no passphrase): | + | |
- | Enter same passphrase again: | + | |
- | Your identification has been saved in / | + | |
- | Your public key has been saved in / | + | |
- | The key fingerprint is: | + | |
- | 66: | + | |
- | The key's randomart image is: | + | |
- | +--[ED25519 | + | |
- | | . . +..oo. | + | |
- | | o +..o. . | | + | |
- | | | + | |
- | | . . o . . | | + | |
- | | . . S + E | | + | |
- | | o = o + | | + | |
- | | . + | + | |
- | | | + | |
- | | | | + | |
- | +-----------------+ | + | |
- | </ | + | |
- | <WRAP center round important> | + | [root@centos8 |
- | Les clés générées seront placées dans le répertoire **~/.ssh/**. | + | Domain snapshot testvm2-snap-03092021 deleted |
- | </ | + | |
- | ==Utilisation== | + | [root@centos8 ~]# virsh snapshot-list testvm1 |
+ | | ||
+ | ------------------------------- | ||
- | La commande ssh prend la forme suivante: | + | [root@centos8 |
- | + | Name | |
- | ssh -l nom_de_compte numero_ip (nom_de_machine) | + | ------------------------------- |
- | + | ||
- | En saisissant cette commande sur votre propre machine, vous obtiendrez un résultat similaire à celle-ci : | + | |
- | + | ||
- | < | + | |
- | [trainee@centos7 ~]$ su - | + | |
- | Mot de passe : | + | |
- | Dernière connexion : lundi 9 mai 2016 à 22:47:48 CEST sur pts/0 | + | |
- | + | ||
- | [root@centos7 | + | |
- | The authenticity of host ' | + | |
- | ECDSA key fingerprint is 19: | + | |
- | Are you sure you want to continue connecting (yes/no)? yes | + | |
- | Warning: Permanently added ' | + | |
- | trainee@localhost' | + | |
- | Last login: Mon May 9 23:25:15 2016 from localhost.localdomain | + | |
</ | </ | ||
- | ===Tunnels SSH=== | + | =====LAB #3 - Gestion des Sauvegardes===== |
- | + | ||
- | 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 : | + | Pour effectuer une sauvegarde d'une VM en utilisant les outils classiques, il convient simplement de copier le fichier d' |
- | ssh -N -f compte@hôte -Lport-local: | + | ====3.1 |
- | Dans votre cas, vous allez créer un tunnel dans votre propre vm entre le port 15023 et le port 23 : | + | Actuellement seule la VM **testvm2** est en cours d' |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | trainee@localhost' | + | |
+ | ------------------------- | ||
+ | | ||
+ | </ | ||
+ | |||
+ | Créez donc un répertoire destiné à contenir les copies créées | ||
+ | |||
+ | < | ||
+ | [root@centos8 ~]# mkdir /vm-backups | ||
</ | </ | ||
- | Installez maintenant | + | Placez-vous dans le répertoire des images **/ |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
+ | [root@centos8 images]# ls -l | ||
+ | total 4029008 | ||
+ | -rw-------. 1 root root 5369757696 Sep 3 11:42 testvm1-os.qcow2 | ||
+ | -rw-------. 1 qemu qemu 2261123072 Sep 4 02:25 testvm2.qcow2 | ||
</ | </ | ||
- | Telnet n'est ni démarré ni activé. Il convient donc de le démarrer et de l' | + | Copiez ensuite l'image vers le répertoire **/ |
< | < | ||
- | [root@centos7 ~]# systemctl status telnet.socket | + | [root@centos8 images]# cp -p testvm1-os.qcow2 /vm-backups/testvm1-os.qcow2-04092021 & |
- | ● telnet.socket | + | |
- | | + | |
- | | + | |
- | Docs: man: | + | |
- | | + | |
- | | + | |
- | + | ||
- | [root@centos7 ~]# systemctl start telnet.socket | + | |
- | + | ||
- | [root@centos7 ~]# systemctl status telnet.socket | + | |
- | ● telnet.socket | + | |
- | | + | |
- | | + | |
- | Docs: man: | + | |
- | | + | |
- | | + | |
- | + | ||
- | May 09 23:40:13 centos7.fenestros.loc systemd[1]: Listening on Telnet Server Activation Socket. | + | |
- | May 09 23:40:13 centos7.fenestros.loc systemd[1]: Starting Telnet Server Activation Socket. | + | |
- | + | ||
- | [root@centos7 ~]# systemctl enable telnet.socket | + | |
- | Created symlink from /etc/ | + | |
- | [root@centos7 ~]# systemctl status telnet.socket | + | |
- | ● telnet.socket | + | |
- | | + | |
- | | + | |
- | Docs: man: | + | |
- | | + | |
- | | + | |
- | + | ||
- | May 09 23:40:13 centos7.fenestros.loc systemd[1]: Listening on Telnet Server Activation Socket. | + | |
- | May 09 23:40:13 centos7.fenestros.loc systemd[1]: Starting Telnet Server Activation Socket. | + | |
- | </ | + | |
- | + | ||
- | Connectez-vous ensuite via telnet sur le port 15023, vous constaterez que votre connexion n' | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# telnet localhost 15023 | + | |
- | Trying 127.0.0.1... | + | |
- | Connected to localhost. | + | |
- | Escape character is ' | + | |
- | + | ||
- | Kernel 3.10.0-327.13.1.el7.x86_64 on an x86_64 | + | |
- | centos7 login: trainee | + | |
- | Password: | + | |
- | Last login: Mon May 9 23:26:32 from localhost.localdomain | + | |
- | [trainee@centos7 ~]$ | + | |
</ | </ | ||
- | <WRAP center round important> | + | <WRAP center round important |
- | Notez bien que votre communication telnet passe par le tunnel SSH. | + | **Important** : Notez que cette copie est effectuée en arrière plan afin de libérer |
</ | </ | ||
- | ====SCP==== | + | ====3.2 - Création d'une Sauvegarde de la Configuration de la VM==== |
- | ===Introduction=== | + | La configuration de chaque VM est contenue dans un fichier |
- | + | ||
- | La commande **scp** | + | |
- | + | ||
- | $ scp compte@numero_ip(nom_de_machine):/ | + | |
- | + | ||
- | ou vers une machine distante : | + | |
- | + | ||
- | $ scp / | + | |
- | + | ||
- | ===Utilisation=== | + | |
- | + | ||
- | Nous allons maintenant utiliser **scp** pour chercher | + | |
- | + | ||
- | Créez le fichier | + | |
< | < | ||
- | [trainee@centos7 ~]$ pwd | + | [root@centos8 images]# cd /etc/ |
- | /home/trainee | + | [root@centos8 qemu]# ls -lR |
- | [trainee@centos7 ~]$ touch scp_test | + | .: |
- | </ | + | total 16 |
+ | drwx------. 3 root root 42 Sep 2 10:22 networks | ||
+ | -rw-------. 1 root root 4936 Sep 3 10:07 testvm1.xml | ||
+ | -rw-------. 1 root root 4933 Sep 3 11:35 testvm2.xml | ||
- | Récupérez le fichier **scp_test** en utilisant scp : | + | ./networks: |
+ | total 4 | ||
+ | drwx------. 2 root root 25 Aug 10 17:00 autostart | ||
+ | -rw-------. 1 root root 575 Sep 2 10:22 default.xml | ||
- | < | + | ./networks/autostart: |
- | [trainee@centos7 ~]$ touch / | + | |
- | [trainee@centos7 ~]$ scp trainee@127.0.0.1:/home/ | + | |
- | The authenticity of host ' | + | |
- | ECDSA key fingerprint is 19: | + | |
- | Are you sure you want to continue connecting (yes/no)? yes | + | |
- | Warning: Permanently added ' | + | |
- | trainee@127.0.0.1' | + | |
- | scp_test | + | |
- | [trainee@centos7 ~]$ ls / | + | |
- | / | + | |
- | </ | + | |
- | + | ||
- | ==Mise en place des clefs== | + | |
- | + | ||
- | Il convient maintenant de se connecter sur le << | + | |
- | + | ||
- | En saisissant cette commande, vous obtiendrez une fenêtre similaire à celle-ci : | + | |
- | + | ||
- | < | + | |
- | [trainee@centos7 ~]$ ssh -l trainee 127.0.0.1 | + | |
- | trainee@127.0.0.1' | + | |
- | Last login: Mon May 9 23:42:46 2016 from localhost.localdomain | + | |
- | [trainee@centos7 ~]$ ls -la | grep .ssh | + | |
- | drwx------. | + | |
- | [trainee@centos7 ~]$ exit | + | |
- | logout | + | |
- | Connection to 127.0.0.1 closed. | + | |
- | </ | + | |
- | + | ||
- | <WRAP center round important> | + | |
- | Si le dossier distant .ssh n' | + | |
- | </ | + | |
- | + | ||
- | Ensuite, il convient de transférer le fichier local **.ssh/ | + | |
- | + | ||
- | < | + | |
- | [trainee@centos7 ~]$ scp .ssh/ | + | |
- | trainee@127.0.0.1' | + | |
- | id_ecdsa.pub | + | |
- | </ | + | |
- | + | ||
- | Connectez-vous via telnet et insérer les clefs publiques restantes dans le fichier .ssh/ | + | |
- | + | ||
- | < | + | |
- | root@centos7 ~]# ssh -l trainee localhost | + | |
- | trainee@localhost' | + | |
- | Last login: Tue May 10 01:39:33 2016 from localhost.localdomain | + | |
- | [trainee@centos7 ~]$ cat .ssh/ | + | |
- | [trainee@centos7 ~]$ cat .ssh/ | + | |
- | [trainee@centos7 ~]$ cat .ssh/ | + | |
- | [trainee@centos7 ~]$ cat .ssh/ | + | |
- | ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBG5BtOMFLrUbxD// | + | |
- | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9KOuEH5+kyihhm99Na8UTA4Gi5AfiOVeJyS3UzH7ta73ewmv7JZqaXzar1NlHcpEMkCUs2yKxHyO/ | + | |
- | ssh-dss AAAAB3NzaC1kc3MAAACBAK9/ | + | |
- | ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIENas3A3hmXFj1cb+lrn2NAt6g95Pla6qUFQHd1wg2y1 trainee@centos7.fenestros.loc | + | |
- | ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBG5BtOMFLrUbxD// | + | |
- | </ | + | |
- | + | ||
- | Lors de la connexion suivante au serveur, l' | + | |
- | + | ||
- | < | + | |
- | [trainee@centos7 ~]$ ssh -l trainee localhost | + | |
- | Last login: Tue May 10 01:50:39 2016 from localhost.localdomain | + | |
- | [trainee@centos7 ~]$ exit | + | |
- | déconnexion | + | |
- | Connection to localhost closed. | + | |
- | </ | + | |
- | + | ||
- | <WRAP center round important> | + | |
- | Le fichier **authorized_keys** doit avoir les permissions de 600. | + | |
- | </ | + | |
- | + | ||
- | =====La Configuration par firewalld sous RHEL/CentOS 7===== | + | |
- | + | ||
- | <WRAP center round important> | + | |
- | **Important** : Importez une machine virtuelle vierge de CentOS 7. | + | |
- | </ | + | |
- | + | ||
- | firewalld est à Netfilter ce que NetworkManager est au réseau. 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' | + | |
- | + | ||
- | <WRAP center round important> | + | |
- | Une interface ne peut être que dans une zone à la fois tandis que plusieurs interfaces peuvent être dans la même zone. | + | |
- | </ | + | |
- | + | ||
- | Le service firewalld doit toujours être lancé : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# systemctl status firewalld.service | + | |
- | firewalld.service - firewalld - dynamic firewall daemon | + | |
- | | + | |
- | | + | |
- | Main PID: 493 (firewalld) | + | |
- | | + | |
- | | + | |
- | + | ||
- | Jul 07 15:53:56 centos7.fenestros.loc systemd[1]: Started firewalld - dynamic firewall daemon. | + | |
- | </ | + | |
- | + | ||
- | ==La Configuration de Base de firewalld== | + | |
- | + | ||
- | La configuration par défaut de firewalld se trouve dans **/ | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# ls -l / | + | |
- | total 12 | + | |
- | drwxr-x---. 2 root root 4096 Jun 4 09:52 icmptypes | + | |
- | drwxr-x---. 2 root root 4096 Jun 4 09:52 services | + | |
- | drwxr-x---. 2 root root 4096 Jun 4 09:52 zones | + | |
- | [root@centos7 ~]# ls -l / | + | |
- | total 36 | + | |
- | -rw-r-----. 1 root root 299 Mar 6 00:35 block.xml | + | |
- | -rw-r-----. 1 root root 293 Mar 6 00:35 dmz.xml | + | |
- | -rw-r-----. 1 root root 291 Mar 6 00:35 drop.xml | + | |
- | -rw-r-----. 1 root root 304 Mar 6 00:35 external.xml | + | |
- | -rw-r-----. 1 root root 400 Mar 6 00:35 home.xml | + | |
- | -rw-r-----. 1 root root 415 Mar 6 00:35 internal.xml | + | |
- | -rw-r-----. 1 root root 315 Mar 6 00:35 public.xml | + | |
- | -rw-r-----. 1 root root 162 Mar 6 00:35 trusted.xml | + | |
- | -rw-r-----. 1 root root 342 Mar 6 00:35 work.xml | + | |
- | [root@centos7 ~]# ls -l / | + | |
- | total 192 | + | |
- | -rw-r-----. 1 root root 412 Mar 6 00:35 amanda-client.xml | + | |
- | -rw-r-----. 1 root root 320 Mar 6 00:35 bacula-client.xml | + | |
- | -rw-r-----. 1 root root 346 Mar 6 00:35 bacula.xml | + | |
- | -rw-r-----. 1 root root 305 Mar 6 00:35 dhcpv6-client.xml | + | |
- | -rw-r-----. 1 root root 234 Mar 6 00:35 dhcpv6.xml | + | |
- | -rw-r-----. 1 root root 227 Mar 6 00:35 dhcp.xml | + | |
- | -rw-r-----. 1 root root 346 Mar 6 00:35 dns.xml | + | |
- | -rw-r-----. 1 root root 374 Mar 6 00:35 ftp.xml | + | |
- | -rw-r-----. 1 root root 476 Mar 6 00:35 high-availability.xml | + | |
- | -rw-r-----. 1 root root 448 Mar 6 00:35 https.xml | + | |
- | -rw-r-----. 1 root root 353 Mar 6 00:35 http.xml | + | |
- | -rw-r-----. 1 root root 372 Mar 6 00:35 imaps.xml | + | |
- | -rw-r-----. 1 root root 454 Mar 6 00:35 ipp-client.xml | + | |
- | -rw-r-----. 1 root root 427 Mar 6 00:35 ipp.xml | + | |
- | -rw-r-----. 1 root root 517 Mar 6 00:35 ipsec.xml | + | |
- | -rw-r-----. 1 root root 233 Mar 6 00:35 kerberos.xml | + | |
- | -rw-r-----. 1 root root 221 Mar 6 00:35 kpasswd.xml | + | |
- | -rw-r-----. 1 root root 232 Mar 6 00:35 ldaps.xml | + | |
- | -rw-r-----. 1 root root 199 Mar 6 00:35 ldap.xml | + | |
- | -rw-r-----. 1 root root 385 Mar 6 00:35 libvirt-tls.xml | + | |
- | -rw-r-----. 1 root root 389 Mar 6 00:35 libvirt.xml | + | |
- | -rw-r-----. 1 root root 424 Mar 6 00:35 mdns.xml | + | |
- | -rw-r-----. 1 root root 211 Mar 6 00:35 mountd.xml | + | |
- | -rw-r-----. 1 root root 190 Mar 6 00:35 ms-wbt.xml | + | |
- | -rw-r-----. 1 root root 171 Mar 6 00:35 mysql.xml | + | |
- | -rw-r-----. 1 root root 324 Mar 6 00:35 nfs.xml | + | |
- | -rw-r-----. 1 root root 389 Mar 6 00:35 ntp.xml | + | |
- | -rw-r-----. 1 root root 335 Mar 6 00:35 openvpn.xml | + | |
- | -rw-r-----. 1 root root 433 Mar 6 00:35 pmcd.xml | + | |
- | -rw-r-----. 1 root root 474 Mar 6 00:35 pmproxy.xml | + | |
- | -rw-r-----. 1 root root 544 Mar 6 00:35 pmwebapis.xml | + | |
- | -rw-r-----. 1 root root 460 Mar 6 00:35 pmwebapi.xml | + | |
- | -rw-r-----. 1 root root 357 Mar 6 00:35 pop3s.xml | + | |
- | -rw-r-----. 1 root root 181 Mar 6 00:35 postgresql.xml | + | |
- | -rw-r-----. 1 root root 261 Mar 6 00:35 proxy-dhcp.xml | + | |
- | -rw-r-----. 1 root root 446 Mar 6 00:35 radius.xml | + | |
- | -rw-r-----. 1 root root 517 Mar 6 00:35 RH-Satellite-6.xml | + | |
- | -rw-r-----. 1 root root 214 Mar 6 00:35 rpc-bind.xml | + | |
- | -rw-r-----. 1 root root 384 Mar 6 00:35 samba-client.xml | + | |
- | -rw-r-----. 1 root root 461 Mar 6 00:35 samba.xml | + | |
- | -rw-r-----. 1 root root 550 Mar 6 00:35 smtp.xml | + | |
- | -rw-r-----. 1 root root 463 Mar 6 00:35 ssh.xml | + | |
- | -rw-r-----. 1 root root 393 Mar 6 00:35 telnet.xml | + | |
- | -rw-r-----. 1 root root 301 Mar 6 00:35 tftp-client.xml | + | |
- | -rw-r-----. 1 root root 437 Mar 6 00:35 tftp.xml | + | |
- | -rw-r-----. 1 root root 211 Mar 6 00:35 transmission-client.xml | + | |
- | -rw-r-----. 1 root root 475 Mar 6 00:35 vnc-server.xml | + | |
- | -rw-r-----. 1 root root 310 Mar 6 00:35 wbem-https.xml | + | |
- | [root@centos7 ~]# ls -l / | + | |
- | total 36 | + | |
- | -rw-r-----. 1 root root 222 Mar 6 00:35 destination-unreachable.xml | + | |
- | -rw-r-----. 1 root root 173 Mar 6 00:35 echo-reply.xml | + | |
- | -rw-r-----. 1 root root 210 Mar 6 00:35 echo-request.xml | + | |
- | -rw-r-----. 1 root root 225 Mar 6 00:35 parameter-problem.xml | + | |
- | -rw-r-----. 1 root root 185 Mar 6 00:35 redirect.xml | + | |
- | -rw-r-----. 1 root root 227 Mar 6 00:35 router-advertisement.xml | + | |
- | -rw-r-----. 1 root root 223 Mar 6 00:35 router-solicitation.xml | + | |
- | -rw-r-----. 1 root root 248 Mar 6 00:35 source-quench.xml | + | |
- | -rw-r-----. 1 root root 253 Mar 6 00:35 time-exceeded.xml | + | |
- | </ | + | |
- | + | ||
- | Ces fichiers sont au format **xml**, par exemple : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# cat / | + | |
- | <?xml version=" | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | <service name=" | + | |
- | <service name=" | + | |
- | <service name=" | + | |
- | <service name=" | + | |
- | <service name=" | + | |
- | </ | + | |
- | </ | + | |
- | + | ||
- | La configuration de firewalld ainsi que les définitions et règles personnalisées se trouvent dans **/ | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# ls -l / | + | |
- | total 8 | + | |
- | -rw-r-----. 1 root root 1026 Mar 6 00:35 firewalld.conf | + | |
- | drwxr-x---. 2 root root 6 Mar 6 00:35 icmptypes | + | |
- | -rw-r-----. 1 root root 271 Mar 6 00:35 lockdown-whitelist.xml | + | |
- | drwxr-x---. 2 root root 6 Mar 6 00:35 services | + | |
- | drwxr-x---. 2 root root 23 Mar 6 00:35 zones | + | |
- | [root@centos7 ~]# ls -l / | + | |
- | total 4 | + | |
- | -rw-r--r--. 1 root root 315 Mar 8 14:05 public.xml | + | |
- | [root@centos7 ~]# ls -l / | + | |
- | total 0 | + | |
- | [root@centos7 ~]# ls -l / | + | |
total 0 | total 0 | ||
+ | lrwxrwxrwx. 1 root root 14 Jun 16 06:28 default.xml -> ../ | ||
</ | </ | ||
- | Le fichier | + | Si vous consultez le contenu du fichier **testvm1.xml**, vous vous apercevrez des balises contenant la configuration actuelle de la VM. Par exemple, les deux lignes suivantes démontrent que la VM a 2 Go de RAM et 1 vCPU : |
- | <code> | + | <file> |
- | [root@centos7 ~]# cat / | + | ... |
- | # firewalld config file | + | < |
- | + | < | |
- | # default zone | + | ... |
- | # The default zone used if an empty zone string is used. | + | </file> |
- | # Default: public | + | |
- | DefaultZone=public | + | |
- | + | ||
- | # Minimal mark | + | |
- | # Marks up to this minimum are free for use for example in the direct | + | |
- | # interface. If more free marks are needed, increase the minimum | + | |
- | # Default: 100 | + | |
- | MinimalMark=100 | + | |
- | + | ||
- | # 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 | + | |
- | + | ||
- | </code> | + | |
- | + | ||
- | ===La Commande firewall-cmd=== | + | |
- | + | ||
- | firewalld s'appuie sur netfilter. Pour cette raison, l'utilisation de firewall-cmd est incompatible avec l' | + | |
- | + | ||
- | <WRAP center round 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, | + | |
< | < | ||
- | [root@centos7 ~]# firewall-cmd --get-zones | + | [root@centos8 qemu]# cat testvm1.xml |
- | block dmz drop external home internal public trusted work | + | <!-- |
- | </code> | + | WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE |
+ | OVERWRITTEN AND LOST. Changes to this xml configuration should be made using: | ||
+ | virsh edit testvm1 | ||
+ | or other application using the libvirt API. | ||
+ | --> | ||
- | Pour obtenir la liste de toutes les services prédéfinis, | + | <domain type=' |
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | <memory unit=' | ||
+ | < | ||
+ | <vcpu placement=' | ||
+ | < | ||
+ | <type arch=' | ||
+ | <boot dev=' | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | <cpu mode=' | ||
+ | <clock offset=' | ||
+ | <timer name=' | ||
+ | <timer name=' | ||
+ | <timer name=' | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | <disk type=' | ||
+ | <driver name=' | ||
+ | <source file='/ | ||
+ | <target dev=' | ||
+ | <address type=' | ||
+ | </ | ||
+ | <disk type=' | ||
+ | <driver name=' | ||
+ | <target dev=' | ||
+ | < | ||
+ | <address type=' | ||
+ | </ | ||
+ | < | ||
+ | <address type=' | ||
+ | </ | ||
+ | < | ||
+ | <address type=' | ||
+ | </ | ||
+ | < | ||
+ | < | ||
+ | <address type=' | ||
+ | </ | ||
+ | < | ||
+ | <model name=' | ||
+ | <target chassis=' | ||
+ | <address type=' | ||
+ | </ | ||
+ | < | ||
+ | <model name=' | ||
+ | <target chassis=' | ||
+ | <address type=' | ||
+ | </ | ||
+ | < | ||
+ | <model name=' | ||
+ | <target chassis=' | ||
+ | <address type=' | ||
+ | </ | ||
+ | < | ||
+ | <model name=' | ||
+ | <target chassis=' | ||
+ | <address type=' | ||
+ | </ | ||
+ | < | ||
+ | <model name=' | ||
+ | <target chassis=' | ||
+ | <address type=' | ||
+ | </ | ||
+ | < | ||
+ | <model name=' | ||
+ | <target chassis=' | ||
+ | <address type=' | ||
+ | </ | ||
+ | < | ||
+ | <model name=' | ||
+ | <target chassis=' | ||
+ | <address type=' | ||
+ | </ | ||
+ | < | ||
+ | <mac address=' | ||
+ | <source bridge=' | ||
+ | <model type=' | ||
+ | <address type=' | ||
+ | </ | ||
+ | <serial type=' | ||
+ | <target type=' | ||
+ | <model name=' | ||
+ | </ | ||
+ | </ | ||
+ | <console type=' | ||
+ | <target type=' | ||
+ | </ | ||
+ | <channel type=' | ||
+ | <target type=' | ||
+ | <address type=' | ||
+ | </ | ||
+ | <input type=' | ||
+ | <input type=' | ||
+ | < | ||
+ | <address type=' | ||
+ | </ | ||
+ | <rng model=' | ||
+ | <backend model=' | ||
+ | <address type=' | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
- | < | ||
- | [root@centos7 ~]# firewall-cmd --get-services | ||
- | RH-Satellite-6 amanda-client bacula bacula-client dhcp dhcpv6 dhcpv6-client dns ftp high-availability http https imaps ipp ipp-client ipsec kerberos kpasswd ldap ldaps libvirt libvirt-tls mdns mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s postgresql proxy-dhcp radius rpc-bind samba samba-client smtp ssh telnet tftp tftp-client transmission-client vnc-server wbem-https | ||
</ | </ | ||
- | Pour obtenir la liste de toutes les types ICMP prédéfinis, | + | Ce fichier doit donc être copié vers le répertoire **/ |
< | < | ||
- | [root@centos7 ~]# firewall-cmd --get-icmptypes | + | [root@centos8 qemu]# cp -p testvm1.xml /vm-backups/ |
- | destination-unreachable echo-reply echo-request parameter-problem redirect router-advertisement router-solicitation source-quench time-exceeded | + | |
</ | </ | ||
- | Pour obtenir | + | Une fois le processus en arrière plan terminé, vous pouvez constater |
< | < | ||
- | [root@centos7 ~]# firewall-cmd --get-active-zones | + | [root@centos8 vm-backups]# ls -l |
- | public | + | total 3992904 |
- | | + | -rw-------. 1 root root 5369757696 Sep 3 11:42 testvm1-os.qcow2-04092021 |
+ | -rw-------. 1 root root 4936 Sep 3 10:07 testvm1.xml-backup-04092021 | ||
</ | </ | ||
- | Pour obtenir | + | Notez que la taille |
< | < | ||
- | [root@centos7 | + | [root@centos8 |
- | public | + | Name: |
+ | Type: | ||
+ | Capacity: | ||
+ | Allocation: | ||
</ | </ | ||
- | Pour obtenir la liste des services autorisés pour la zone public, utilisez la commande suivante : | + | ====3.3 - Sauvegarder les Copies |
- | < | + | Ayant effectué les copies, il est maintenant possible de sauvegarder les fichiers à l'aide d'un outil classique tel **tar** |
- | [root@centos7 ~]# firewall-cmd --zone=public --list-services | + | |
- | dhcpv6-client ssh | + | |
- | </ | + | |
- | + | ||
- | Pour obtenir toute la configuration pour la zone public, utilisez la commande suivante | + | |
< | < | ||
- | [root@centos7 ~]# firewall-cmd --zone=public --list-all | + | [root@centos8 vm-backups]# mkdir testvm1 |
- | public (default, active) | + | [root@centos8 vm-backups]# mv *04* testvm1 |
- | interfaces: enp0s3 | + | [root@centos8 vm-backups]# ls |
- | sources: | + | testvm1 |
- | | + | |
- | | + | |
- | masquerade: no | + | |
- | forward-ports: | + | |
- | icmp-blocks: | + | |
- | rich rules: | + | |
- | + | ||
- | </code> | + | [root@centos8 vm-backups]# |
+ | testvm1/ | ||
+ | testvm1/ | ||
+ | testvm1/ | ||
- | Pour obtenir la liste complète de toutes les zones et leurs configurations, | + | [root@centos8 vm-backups]# ls -l |
- | + | total 846724 | |
- | < | + | drwxr-xr-x. 2 root root 74 Sep 4 03:19 testvm1 |
- | [root@centos7 ~]# firewall-cmd --list-all-zones | + | -rw-r--r--. 1 root root 867042697 Sep 4 03:24 testvm1-backup-04092021.tar.gz |
- | block | + | |
- | interfaces: | + | |
- | sources: | + | |
- | services: | + | |
- | ports: | + | |
- | masquerade: no | + | |
- | forward-ports: | + | |
- | icmp-blocks: | + | |
- | rich rules: | + | |
- | + | ||
- | dmz | + | |
- | interfaces: | + | |
- | sources: | + | |
- | services: ssh | + | |
- | ports: | + | |
- | masquerade: no | + | |
- | forward-ports: | + | |
- | icmp-blocks: | + | |
- | rich rules: | + | |
- | + | ||
- | drop | + | |
- | interfaces: | + | |
- | sources: | + | |
- | services: | + | |
- | ports: | + | |
- | masquerade: no | + | |
- | forward-ports: | + | |
- | icmp-blocks: | + | |
- | rich rules: | + | |
- | + | ||
- | external | + | |
- | interfaces: | + | |
- | sources: | + | |
- | services: ssh | + | |
- | ports: | + | |
- | masquerade: yes | + | |
- | forward-ports: | + | |
- | icmp-blocks: | + | |
- | rich rules: | + | |
- | + | ||
- | home | + | |
- | interfaces: | + | |
- | sources: | + | |
- | services: dhcpv6-client ipp-client mdns samba-client ssh | + | |
- | ports: | + | |
- | masquerade: no | + | |
- | forward-ports: | + | |
- | icmp-blocks: | + | |
- | rich rules: | + | |
- | + | ||
- | internal | + | |
- | interfaces: | + | |
- | sources: | + | |
- | services: dhcpv6-client ipp-client mdns samba-client ssh | + | |
- | ports: | + | |
- | masquerade: no | + | |
- | forward-ports: | + | |
- | icmp-blocks: | + | |
- | rich rules: | + | |
- | + | ||
- | public (default, active) | + | |
- | interfaces: enp0s3 | + | |
- | sources: | + | |
- | services: dhcpv6-client ssh | + | |
- | ports: | + | |
- | masquerade: no | + | |
- | forward-ports: | + | |
- | icmp-blocks: | + | |
- | rich rules: | + | |
- | + | ||
- | trusted | + | |
- | interfaces: | + | |
- | sources: | + | |
- | services: | + | |
- | ports: | + | |
- | masquerade: no | + | |
- | forward-ports: | + | |
- | icmp-blocks: | + | |
- | rich rules: | + | |
- | + | ||
- | work | + | |
- | interfaces: | + | |
- | sources: | + | |
- | services: dhcpv6-client ipp-client ssh | + | |
- | ports: | + | |
- | masquerade: no | + | |
- | forward-ports: | + | |
- | icmp-blocks: | + | |
- | rich rules: | + | |
- | </ | + | |
- | + | ||
- | Pour changer la zone par défaut de public à work, utilisez la commande suivante : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --set-default-zone=work | + | |
- | success | + | |
- | [root@centos7 ~]# firewall-cmd --get-active-zones | + | |
- | work | + | |
- | interfaces: enp0s3 | + | |
- | </ | + | |
- | + | ||
- | Pour ajouter | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --zone=work --add-interface=ip_fixe | + | |
- | success | + | |
- | [root@centos7 ~]# firewall-cmd --get-active-zones | + | |
- | work | + | |
- | interfaces: enp0s3 ip_fixe | + | |
- | </ | + | |
- | + | ||
- | Pour supprimer l' | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --zone=work --remove-interface=ip_fixe | + | |
- | success | + | |
- | [root@centos7 ~]# firewall-cmd --get-active-zones | + | |
- | work | + | |
- | interfaces: enp0s3 | + | |
- | </ | + | |
- | + | ||
- | Pour ajouter le service **http** à la zone **work**, utilisez la commande suivante : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --zone=work | + | |
- | success | + | |
- | [root@centos7 ~]# firewall-cmd --zone=work --list-services | + | |
- | dhcpv6-client http ipp-client ssh | + | |
- | </ | + | |
- | + | ||
- | Pour supprimer le service **http** de la zone **work**, utilisez la commande suivante : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --zone=work --remove-service=http | + | |
- | success | + | |
- | [root@centos7 ~]# firewall-cmd --zone=work --list-services | + | |
- | dhcpv6-client ipp-client ssh | + | |
- | </ | + | |
- | + | ||
- | Pour ajouter un nouveau bloc ICMP, utilisez la commande suivante : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --zone=work --add-icmp-block=echo-reply | + | |
- | success | + | |
- | [root@centos7 ~]# firewall-cmd --zone=work --list-icmp-blocks | + | |
- | echo-reply | + | |
- | </ | + | |
- | + | ||
- | Pour supprimer un bloc ICMP, utilisez la commande suivante : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --zone=work --remove-icmp-block=echo-reply | + | |
- | success | + | |
- | [root@centos7 ~]# firewall-cmd --zone=work --list-icmp-blocks | + | |
- | [root@centos7 ~]# | + | |
- | </ | + | |
- | + | ||
- | Pour ajouter le port 591/tcp à la zone work, utilisez la commande suivante : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --zone=work --add-port=591/ | + | |
- | success | + | |
- | [root@centos7 ~]# firewall-cmd --zone=work --list-ports | + | |
- | 591/tcp | + | |
- | </ | + | |
- | + | ||
- | Pour supprimer le port 591/tcp à la zone work, utilisez la commande suivante : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --zone=work --remove-port=591/ | + | |
- | success | + | |
- | [root@centos7 ~]# firewall-cmd --zone=work --list-ports | + | |
- | [root@centos7 ~]# | + | |
- | </ | + | |
- | + | ||
- | Pour créer un nouveau service, il convient de : | + | |
- | + | ||
- | * copier un fichier existant se trouvant dans le répertoire **/ | + | |
- | * modifier le fichier, | + | |
- | * recharger la configuration de firewalld, | + | |
- | * vérifier que firewalld voit le nouveau service. | + | |
- | + | ||
- | Par exemple : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# cp / | + | |
- | [root@centos7 ~]# | + | |
- | [root@centos7 ~]# cat / | + | |
- | <?xml version=" | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | <port protocol=" | + | |
- | </ | + | |
- | [root@centos7 ~]# | + | |
- | [root@centos7 ~]# firewall-cmd --reload | + | |
- | success | + | |
- | [root@centos7 ~]# | + | |
- | [root@centos7 ~]# firewall-cmd --get-services | + | |
- | RH-Satellite-6 amanda-client bacula bacula-client dhcp dhcpv6 dhcpv6-client dns filemaker ftp high-availability http https imaps ipp ipp-client ipsec kerberos kpasswd ldap ldaps libvirt libvirt-tls mdns mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s postgresql proxy-dhcp radius rpc-bind samba samba-client smtp ssh telnet tftp tftp-client transmission-client vnc-server wbem-https | + | |
- | </ | + | |
- | + | ||
- | ==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="< | + | |
- | * **destination address="< | + | |
- | * **rule port port="< | + | |
- | * **service name=< | + | |
- | + | ||
- | Les **Actions** sont : | + | |
- | + | ||
- | * **accept**, | + | |
- | * **reject**, | + | |
- | * une Action reject peut être associée avec un message d' | + | |
- | * **drop**. | + | |
- | + | ||
- | Saisissez la commande suivante pour ouvrir le port 80 : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --add-rich-rule=' | + | |
- | success | + | |
- | </ | + | |
- | + | ||
- | <WRAP center round important 50%> | + | |
- | Notez que la Rich Rule doit être entourée de caractères **'**. | + | |
- | </ | + | |
- | + | ||
- | Saisissez la commande suivante pour visualiser la règle iptables pour IPv4 : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# iptables -L -n | grep 80 | + | |
- | ACCEPT | + | |
- | </ | + | |
- | + | ||
- | Saisissez la commande suivante pour visualiser la règle iptables pour IPv6 : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# ip6tables -L -n | grep 80 | + | |
- | ACCEPT | + | |
- | ACCEPT | + | |
- | </ | + | |
- | + | ||
- | <WRAP center round important 50%> | + | |
- | Notez que la Rich Rule a créé deux règles, une pour IPv4 et une deuxième pour IPv6. Une règle peut être créée pour IPv4 seul en incluant le Critère **family=ipv4**. De la même façon, une règle peut être créée pour IPv6 seul en incluant le Critère **family=ipv6**. | + | |
- | </ | + | |
- | + | ||
- | Cette nouvelle règle est écrite en mémoire mais non pas sur disque. Pour l' | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --add-rich-rule=' | + | |
- | success | + | |
- | [root@centos7 ~]# | + | |
- | [root@centos7 ~]# cat / | + | |
- | <?xml version=" | + | |
- | < | + | |
- | < | + | |
- | < | + | |
- | <service name=" | + | |
- | <service name=" | + | |
- | <service name=" | + | |
- | < | + | |
- | <port protocol=" | + | |
- | < | + | |
- | </ | + | |
- | </ | + | |
- | </ | + | |
- | + | ||
- | <WRAP center round important 50%> | + | |
- | Attention ! La règle ajoutée avec l' | + | |
- | </ | + | |
- | + | ||
- | Pour visualiser cette règle dans la configuration de firewalld, il convient de saisir la commande suivante : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --list-all-zones | + | |
- | ... | + | |
- | work (default, active) | + | |
- | interfaces: enp0s3 | + | |
- | sources: | + | |
- | services: dhcpv6-client ipp-client ssh | + | |
- | ports: | + | |
- | masquerade: no | + | |
- | forward-ports: | + | |
- | icmp-blocks: | + | |
- | rich rules: | + | |
- | rule port port=" | + | |
- | + | ||
- | </ | + | |
- | + | ||
- | 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' | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --zone=public --add-rich-rule=' | + | |
- | success | + | |
- | [root@centos7 ~]# firewall-cmd --list-all-zones | + | |
- | ... | + | |
- | public | + | |
- | interfaces: | + | |
- | sources: | + | |
- | services: dhcpv6-client ssh | + | |
- | ports: | + | |
- | masquerade: no | + | |
- | forward-ports: | + | |
- | icmp-blocks: | + | |
- | rich rules: | + | |
- | rule port port=" | + | |
- | trusted | + | |
- | interfaces: | + | |
- | sources: | + | |
- | services: | + | |
- | ports: | + | |
- | masquerade: no | + | |
- | forward-ports: | + | |
- | icmp-blocks: | + | |
- | rich rules: | + | |
- | + | ||
- | work (default, active) | + | |
- | interfaces: enp0s3 | + | |
- | sources: | + | |
- | services: dhcpv6-client ipp-client ssh | + | |
- | ports: | + | |
- | masquerade: no | + | |
- | forward-ports: | + | |
- | icmp-blocks: | + | |
- | rich rules: | + | |
- | rule port port=" | + | |
- | </ | + | |
- | + | ||
- | + | ||
- | 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** : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --zone=public --remove-rich-rule=' | + | |
- | success | + | |
- | </ | + | |
- | + | ||
- | ==Le mode Panic de firewalld== | + | |
- | + | ||
- | Le mode Panic de firewalld permet de bloquer tout le trafic avec une seule commande. Pour connaître l' | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --query-panic | + | |
- | no | + | |
- | </ | + | |
- | + | ||
- | Pour activer le mode Panic, il convient de saisir la commande suivante : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --panic-on | + | |
- | success | + | |
- | [root@centos7 ~]# firewall-cmd --query-panic | + | |
- | yes | + | |
- | </ | + | |
- | + | ||
- | Pour désactiver le mode Panic, il convient de saisir la commande suivante : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 ~]# firewall-cmd --panic-off | + | |
- | success | + | |
- | [root@centos7 ~]# firewall-cmd --query-panic | + | |
- | no | + | |
</ | </ | ||
----- | ----- | ||
- | < | + | Copyright © 2022 Hugh Norris |
- | <div align=" | + | |
- | Copyright © 2021 Hugh Norris. | + | |
- | </ | + |