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:redhat:rh134:l103 [2024/10/21 15:20] – admin | elearning:workbooks:redhat:rh134:l103 [2024/10/22 10:15] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
- | Version : **2021.01** | + | Version : **2024.01** |
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ======LRF607 | + | ======RH13404 |
=====Contenu du Module===== | =====Contenu du Module===== | ||
- | * **LRF607 | + | * **RH13404 |
* Contenu du Module | * Contenu du Module | ||
- | * System Hardening Manuel | + | * LAB #1 - Les Droits Unix Avancés |
- | * Les compilateurs | + | * 1.1 - Les ACL |
- | * Les paquets | + | * 1.2 - Les Attributs Étendus |
- | * Les démons et services | + | |
- | * Les fichiers | + | |
- | * Les fichiers et les repertoires sans proprietaire | + | |
- | * Interdire les connexions de root via le réseau | + | |
- | * Limiter le delai d' | + | |
- | * Renforcer la securite d' | + | |
- | * Les Distributions SysVInit | + | |
- | * Les Distributions Upstart | + | |
- | * Renforcer la sécurité du Noyau | + | |
- | * La commande sysctl | + | |
- | * LAB #1 - System Hardening à l'aide de l' | + | |
- | * Présentation | + | |
- | * Installation | + | |
- | * Utilisation | + | |
* LAB #2 - Mise en place de SELinux pour sécuriser le serveur | * LAB #2 - Mise en place de SELinux pour sécuriser le serveur | ||
- | * Introducton | + | * 2.1 - Introducton |
- | * Définitions | + | * 2.2 - Définitions |
* Security Context | * Security Context | ||
* Domains et Types | * Domains et Types | ||
Ligne 46: | Ligne 32: | ||
* Booléens | * Booléens | ||
* LAB #3 - Travailler avec SELinux | * LAB #3 - Travailler avec SELinux | ||
- | * Copier et Déplacer des Fichiers | + | * 3.1 - Copier et Déplacer des Fichiers |
- | * Vérifier les SC des Processus | + | * 3.2 - Vérifier les SC des Processus |
- | * Visualiser la SC d'un Utilisateur | + | * 3.3 - Visualiser la SC d'un Utilisateur |
- | * Vérifier la SC d'un fichier | + | * 3.4 - Vérifier la SC d'un fichier |
- | * Troubleshooting SELinux | + | * 3.4 - La commande chcon |
- | * La commande chcon | + | * 3.5 - La commande restorecon |
- | * La commande restorecon | + | * 3.6 - Le fichier / |
- | * Le fichier / | + | * 3.7 - La commande semanage |
- | * La commande semanage | + | * 3.8 - La commande audit2allow |
- | * La commande audit2allow | + | * LAB #4 - Le Pare-feu Netfilter/ |
+ | * 4.1 - La Configuration par firewalld | ||
+ | * 4.2 - La Configuration de Base de firewalld | ||
+ | * 4.3 - La Commande firewall-cmd | ||
+ | * 4.4 - La Configuration Avancée de firewalld | ||
+ | * 4.5 - Le mode Panic de firewalld | ||
- | =====System Hardening Manuel===== | + | =====LAB #1 - Les Droits Unix Avancés===== |
- | ====Les | + | ====1.1 - Les ACL==== |
- | Afin d'empêcher | + | Au delà des droits étendus |
- | ====Les paquets==== | + | Pour connaître les ACL positionnés sur un fichier, il convient |
- | + | ||
- | Il convient | + | |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | libtalloc-2.1.9-1.el7.x86_64 | + | |
- | gnome-contacts-3.22.1-1.el7.x86_64 | + | [root@redhat9 ~]# getfacl tux.jpg |
- | lrzsz-0.12.20-36.el7.x86_64 | + | # file: tux.jpg |
- | NetworkManager-team-1.8.0-11.el7_4.x86_64 | + | # owner: root |
- | opus-1.0.2-6.el7.x86_64 | + | # group: root |
- | libsss_certmap-1.15.2-50.el7_4.11.x86_64 | + | user::rw- |
- | m17n-db-1.6.4-3.el7.noarch | + | group::r-- |
- | expat-2.1.0-10.el7_3.x86_64 | + | other::r-- |
- | gvfs-mtp-1.30.4-3.el7.x86_64 | + | |
- | hypervfcopyd-0-0.30.20161211git.el7.x86_64 | + | |
- | perl-parent-0.225-244.el7.noarch | + | |
- | libreport-centos-2.1.11-38.el7.centos.x86_64 | + | |
- | pixman-0.34.0-1.el7.x86_64 | + | |
- | alsa-plugins-pulseaudio-1.1.1-1.el7.x86_64 | + | |
- | libreoffice-graphicfilter-5.0.6.2-15.el7_4.x86_64 | + | |
- | libreport-rhel-anaconda-bugzilla-2.1.11-38.el7.centos.x86_64 | + | |
- | libXext-1.3.3-3.el7.x86_64 | + | |
- | libtool-ltdl-2.4.2-22.el7_3.x86_64 | + | |
- | NetworkManager-ppp-1.8.0-11.el7_4.x86_64 | + | |
- | osinfo-db-20170423-2.el7.noarch | + | |
- | fftw-libs-double-3.3.3-8.el7.x86_64 | + | |
- | kernel-tools-libs-3.10.0-693.21.1.el7.x86_64 | + | |
- | e2fsprogs-libs-1.42.9-10.el7.x86_64 | + | |
- | --More-- | + | |
</ | </ | ||
- | ====Les démons et services==== | + | Pour positionner des ACL sur un fichier, il convient d' |
- | Il convient dans ce cas de passer en revue la liste des démons et services actives puis de supprimer ceux qui sont juges être inutiles; | + | < |
+ | [root@redhat9 ~]# setfacl --set u:: | ||
- | * ps aux | + | [root@redhat9 |
- | * chkconfig --list | + | # file: tux.jpg |
- | * systemctl list-unit-files | + | # owner: root |
- | + | # group: root | |
- | < | + | user::rwx |
- | [root@centos7 | + | user:trainee:rw- |
- | USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | + | group::r-x |
- | root | + | mask::rwx |
- | ched-root --system --deserialize 21 | + | other::--- |
- | root | + | |
- | root | + | |
- | root | + | |
- | root 6 0.0 0.0 0 0 ? S 14:58 0:00 [kworker/ | + | |
- | root | + | |
- | root 8 0.0 0.0 0 0 ? S 14:58 0:00 [rcu_bh] | + | |
- | root | + | |
- | root 10 0.0 0.0 0 0 ? S 14:58 0:00 [watchdog/ | + | |
- | root 12 0.0 0.0 0 0 ? S 14:58 0:00 [kdevtmpfs] | + | |
- | root 13 0.0 0.0 0 0 ? S< 14:58 0:00 [netns] | + | |
- | root 14 0.0 0.0 0 0 ? S 14:58 0:00 [khungtaskd] | + | |
- | root 15 0.0 0.0 0 0 ? S< | + | |
- | root 16 0.0 0.0 0 0 ? S< | + | |
- | root 17 0.0 0.0 0 0 ? S< | + | |
- | root 18 0.0 0.0 0 0 ? S< | + | |
- | root 19 0.0 0.0 0 0 ? S< | + | |
- | root 25 0.0 0.0 0 0 ? S 14:58 0:03 [kswapd0] | + | |
- | root 26 0.0 0.0 0 0 ? SN | + | |
- | root 27 0.0 0.0 0 0 ? S< | + | |
- | root 35 0.0 0.0 0 0 ? S< | + | |
- | --More-- | + | |
</ | </ | ||
- | <code> | + | <WRAP center round important 60%> |
- | [root@centos7 ~]# chkconfig | + | **Important** |
+ | </ | ||
- | Note: This output shows SysV services only and does not include native | + | Regardez maintenant l' |
- | systemd services. SysV configuration data might be overridden by native | + | |
- | systemd configuration. | + | |
- | If you want to list systemd services use ' | + | < |
- | To see services enabled on particular target use | + | [root@redhat9 ~]# mkdir rep1 |
- | ' | + | |
- | + | ||
- | livesys | + | |
- | livesys-late | + | |
- | netconsole | + | |
- | network | + | |
- | snortd | + | |
</ | </ | ||
+ | |||
+ | Positionnez des ACL le répertoire avec la commande **setfacl** : | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | UNIT FILE | + | |
- | proc-sys-fs-binfmt_misc.automount | + | |
- | dev-hugepages.mount | + | |
- | dev-mqueue.mount | + | |
- | proc-fs-nfsd.mount | + | |
- | proc-sys-fs-binfmt_misc.mount | + | |
- | sys-fs-fuse-connections.mount | + | |
- | sys-kernel-config.mount | + | |
- | sys-kernel-debug.mount | + | |
- | tmp.mount | + | |
- | var-lib-nfs-rpc_pipefs.mount | + | |
- | brandbot.path | + | |
- | cups.path | + | |
- | systemd-ask-password-console.path | + | |
- | systemd-ask-password-plymouth.path | + | |
- | systemd-ask-password-wall.path | + | |
- | session-33.scope | + | |
- | abrt-ccpp.service | + | |
- | abrt-oops.service | + | |
- | abrt-pstoreoops.service | + | |
- | abrt-vmcore.service | + | |
- | abrt-xorg.service | + | |
- | abrtd.service | + | |
- | lines 1-23 | + | |
</ | </ | ||
- | ====Les fichiers | + | Notez l' |
- | Le systeme rhosts presente une faille de securite importante pour un serveur Linux. Pour cette raison, il convient de supprimer les fichiers **.rhosts** des utilisateurs. Utilisez la commande suivante: | + | Créez maintenant |
- | + | ||
- | # find / -name " | + | |
- | + | ||
- | ====Les fichiers et les repertoires sans proprietaire==== | + | |
- | + | ||
- | Afin de dresser la liste des fichiers et des groupes sans proprietaires sur le serveur, il convient d' | + | |
- | + | ||
- | # find / -nouser -exec ls -l \{\} \; 2> sans_pro.txt [Entree] | + | |
- | + | ||
- | # find / -nogroup -exec ls -l \{\} \; 2>> sans_pro.txt[Entree] | + | |
- | + | ||
- | Ces commandes produiront une liste éventuelle dans le fichier **sans_pro.txt**. | + | |
- | + | ||
- | L' | + | |
- | + | ||
- | * modifier le propriétaire a root | + | |
- | * modifier le groupe a root | + | |
- | * modifier les permissions a 700 | + | |
- | + | ||
- | ====Interdire les connexions de root via le reseau==== | + | |
- | + | ||
- | Le fichier de configuration des connexions de root est **/etc/securetty** | + | |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | console | + | |
- | vc/1 | + | |
- | vc/2 | + | |
- | vc/3 | + | |
- | vc/4 | + | |
- | vc/5 | + | |
- | vc/6 | + | |
- | vc/7 | + | |
- | vc/8 | + | |
- | vc/9 | + | |
- | vc/10 | + | |
- | vc/11 | + | |
- | tty1 | + | |
- | tty2 | + | |
- | tty3 | + | |
- | tty4 | + | |
- | tty5 | + | |
- | tty6 | + | |
- | tty7 | + | |
- | tty8 | + | |
- | tty9 | + | |
- | tty10 | + | |
- | tty11 | + | |
- | ttyS0 | + | |
- | ttysclp0 | + | |
- | sclp_line0 | + | |
- | 3270/tty1 | + | |
- | hvc0 | + | |
- | hvc1 | + | |
- | hvc2 | + | |
- | hvc3 | + | |
- | hvc4 | + | |
- | hvc5 | + | |
- | hvc6 | + | |
- | hvc7 | + | |
- | hvsi0 | + | |
- | hvsi1 | + | |
- | hvsi2 | + | |
- | xvc0 | + | |
</ | </ | ||
- | Afin d' | + | Utilisez |
- | + | ||
- | ====Limiter | + | |
- | + | ||
- | Une session de shell laissee ouverte inutilement et d'une maniere sans surveillance est un risque de securite. Verifiez donc le contenu du fichier **/ | + | |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | # / | + | # file: rep1 |
+ | # owner: root | ||
+ | # group: root | ||
+ | user::rwx | ||
+ | group:: | ||
+ | other:: | ||
+ | default: | ||
+ | default: | ||
+ | default: | ||
- | # System wide environment and startup programs, for login setup | + | [root@redhat9 ~]# getfacl rep1/ |
- | # Functions and aliases go in /etc/bashrc | + | # file: rep1/fichier1 |
+ | # owner: root | ||
+ | # group: root | ||
+ | user::r-- | ||
+ | group:: | ||
+ | other:: | ||
+ | </code> | ||
- | # It's NOT a good idea to change this file unless you know what you | + | Notez que le fichier créé possède les ACL positionnés sur le répertoire rep1. |
- | # are doing. It's much better to create a custom.sh shell script in | + | |
- | # / | + | |
- | # will prevent the need for merging in future updates. | + | |
- | pathmunge () { | + | Dernièrement, |
- | case ": | + | |
- | | + | |
- | ;; | + | |
- | | + | |
- | if [ " | + | |
- | PATH=$PATH: | + | |
- | else | + | |
- | PATH=$1:$PATH | + | |
- | fi | + | |
- | esac | + | |
- | } | + | |
+ | < | ||
+ | [root@redhat9 ~]# cd rep1 | ||
- | if [ -x / | + | [root@redhat9 rep1]# getfacl |
- | if [ -z " | + | |
- | # ksh workaround | + | |
- | EUID=`/ | + | |
- | UID=`/ | + | |
- | fi | + | |
- | USER=" | + | |
- | LOGNAME=$USER | + | |
- | MAIL="/ | + | |
- | fi | + | |
- | # Path manipulation | + | [root@redhat9 rep1]# cat backup.acl |
- | if [ " | + | # file: . |
- | pathmunge /usr/sbin | + | # owner: root |
- | pathmunge / | + | # group: root |
- | else | + | user::rwx |
- | pathmunge / | + | group::r-x |
- | pathmunge /usr/sbin after | + | other::r-x |
- | fi | + | default: |
- | + | default: | |
- | HOSTNAME=`/ | + | default: |
- | HISTSIZE=1000 | + | |
- | if [ " | + | |
- | export HISTCONTROL=ignoreboth | + | |
- | else | + | |
- | export HISTCONTROL=ignoredups | + | |
- | fi | + | |
- | + | ||
- | export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL | + | |
- | + | ||
- | # By default, we want umask to get set. This sets it for login shell | + | |
- | # Current threshold for system reserved uid/gids is 200 | + | |
- | # You could check uidgid reservation validity in | + | |
- | # / | + | |
- | if [ $UID -gt 199 ] && [ " | + | |
- | umask 002 | + | |
- | else | + | |
- | umask 022 | + | |
- | fi | + | |
- | + | ||
- | for i in / | + | |
- | if [ -r " | + | |
- | if [ "${-#*i}" != "$-" ]; then | + | |
- | . " | + | |
- | else | + | |
- | . " | + | |
- | fi | + | |
- | fi | + | |
- | done | + | |
- | + | ||
- | unset i | + | |
- | unset -f pathmunge | + | |
</ | </ | ||
- | A ce fichier doivent etre ajoutées les deux lignes suivantes: | + | La restauration des ACL se fait avec la commande **setfacl** |
- | < | + | # setfacl --restore=backup.acl [Entrée] |
- | Readonly TMOUT=300 | + | |
- | Export TMOUT | + | |
- | </ | + | |
- | Par cette action, vous définissez le délai d’inactivité d'une session shell a une durée de 5 minutes. | + | ==Options des Commandes=== |
- | Dernièrement, | + | Les options |
- | + | ||
- | ====Renforcer la securite d' | + | |
- | + | ||
- | ===Les Distributions SysVInit=== | + | |
- | + | ||
- | Le fichier **/ | + | |
- | + | ||
- | La première modification à effectuer est de spécifier le niveau d’exécution par défaut a 3 au lieu de 5. Ceci permet de ne pas lancer les sessions graphiques sur une serveur de production. Cherchez donc la ligne suivante: | + | |
- | + | ||
- | < | + | |
- | id: | + | |
- | </ | + | |
- | + | ||
- | Modifiez-la en: | + | |
- | + | ||
- | < | + | |
- | id: | + | |
- | </ | + | |
- | + | ||
- | Le mode **single user** de démarrage de Linux n'est pas habituellement protégé par un mot de passe. Afin de remédier a cela, ajoutez les lignes suivantes: | + | |
- | + | ||
- | < | + | |
- | # Single user mode | + | |
- | ~~: | + | |
- | </ | + | |
- | + | ||
- | Dernièrement, | + | |
- | + | ||
- | < | + | |
- | # ca:: | + | |
- | </ | + | |
- | + | ||
- | ===Les Distributions Upstart=== | + | |
- | + | ||
- | Afin d' | + | |
- | + | ||
- | < | + | |
- | exec / | + | |
- | </ | + | |
- | + | ||
- | en | + | |
- | + | ||
- | < | + | |
- | #exec / | + | |
- | </ | + | |
- | + | ||
- | ====Renforcer la sécurité du Noyau==== | + | |
- | + | ||
- | ===La commande | + | |
- | + | ||
- | Les fichiers dans le répertoire | + | |
- | + | ||
- | La commande **sysctl** applique les règles consignés dans le fichier **/ | + | |
- | + | ||
- | Saisissez la commande | + | |
< | < | ||
- | [root@centos7 ~]# cat / | + | [root@redhat9 rep1]# getfacl --help |
- | # System default settings live in / | + | getfacl 2.3.1 -- get file access control lists |
- | # To override those settings, enter new settings here, or in an /etc/sysctl.d/< | + | Usage: getfacl [-aceEsRLPtpndvh] file ... |
- | # | + | -a, --access |
- | # For more information, | + | -d, --default |
- | + | -c, --omit-header | |
- | [root@centos7 ~]# cat / | + | -e, --all-effective |
- | # Kernel sysctl configuration file | + | -E, --no-effective |
- | # | + | |
- | # For binary values, 0 is disabled, 1 is enabled. | + | -R, --recursive |
- | # sysctl.conf(5) for more details. | + | -L, --logical |
- | + | -P, --physical | |
- | # Disable netfilter on bridges. | + | -t, --tabular |
- | net.bridge.bridge-nf-call-ip6tables = 0 | + | -n, --numeric |
- | net.bridge.bridge-nf-call-iptables = 0 | + | --one-file-system |
- | net.bridge.bridge-nf-call-arptables = 0 | + | -p, --absolute-names |
- | + | -v, --version | |
- | # Controls the maximum shared segment size, in bytes | + | -h, --help |
- | kernel.shmmax = 4294967295 | + | |
- | + | ||
- | # Controls the maximum number of shared memory segments, in pages | + | |
- | + | ||
- | [root@centos7 ~]# ls -l / | + | |
- | total 0 | + | |
- | lrwxrwxrwx. 1 root root 14 Jun 4 09:54 99-sysctl.conf | + | |
- | + | ||
- | [root@centos7 ~]# cat / | + | |
- | # System default settings live in / | + | |
- | # To override those settings, enter new settings here, or in an / | + | |
- | # | + | |
- | # For more information, see sysctl.conf(5) and sysctl.d(5). | + | |
</ | </ | ||
- | ==Options de la commande== | + | Les options de la commande **setfacl** sont : |
- | + | ||
- | Les options de la commande **sysctl** sont : | + | |
< | < | ||
- | [root@centos7 ~]# sysctl | + | [root@redhat9 rep1]# setfacl |
+ | setfacl 2.3.1 -- set file access control lists | ||
+ | Usage: setfacl [-bkndRLP] { -m|-M|-x|-X ... } file ... | ||
+ | -m, --modify=acl | ||
+ | -M, --modify-file=file | ||
+ | -x, --remove=acl | ||
+ | -X, --remove-file=file | ||
+ | -b, --remove-all | ||
+ | -k, --remove-default | ||
+ | --set=acl | ||
+ | --set-file=file | ||
+ | --mask | ||
+ | -n, --no-mask | ||
+ | -d, --default | ||
+ | -R, --recursive | ||
+ | -L, --logical | ||
+ | -P, --physical | ||
+ | --restore=file | ||
+ | --test | ||
+ | -v, --version | ||
+ | -h, --help | ||
+ | </ | ||
- | Usage: | + | ====1.2 - Les Attributs Etendus==== |
- | | + | |
- | Options: | + | Les attributs s' |
- | -a, --all display all variables | + | |
- | -A alias of -a | + | |
- | -X alias of -a | + | |
- | --deprecated | + | |
- | -b, --binary | + | |
- | -e, --ignore | + | |
- | -N, --names | + | |
- | -n, --values | + | |
- | -p, --load[=< | + | |
- | -f alias of -p | + | |
- | --system | + | |
- | -r, --pattern < | + | |
- | | + | |
- | -q, --quiet | + | |
- | -w, --write | + | |
- | -o does nothing | + | |
- | -x does nothing | + | |
- | -d alias of -h | + | |
- | -h, --help | + | Les principaux attributs sont : |
- | -V, --version | + | |
- | For more details see sysctl(8). | + | ^ Attribut ^ Description ^ |
- | </ | + | | a | Fichier journal - uniquement l' |
+ | | i | Le fichier ne peut ni être modifié, ni être détruit, ni être déplacé. Le placement d'un lien sur le fichier n'est pas permis | | ||
+ | | s | Le fichier sera physiquement détruit lors de sa suppression | | ||
+ | | D | Répertoire synchrone | | ||
+ | | S | Fichier synchrone | | ||
+ | | A | La date et l' | ||
- | <WRAP center round important | + | <WRAP center round important |
- | **Important** | + | **Important** |
</ | </ | ||
- | =====LAB #1 - System Hardening à l'aide de l' | + | Les commandes associées avec les attributs sont : |
- | + | ||
- | ====Présentation==== | + | |
- | + | ||
- | Bastille Linux est un script interactif de renforcement de la sécurité pour certaines distributions de Linux dont %%RHEL%%, %%CentOS%% et Debian. | + | |
- | ====Installation==== | + | ^ Commande ^ description ^ |
+ | | chattr | Modifie les attributs | | ||
+ | | lsattr | Visualise les attributs | | ||
- | Installez | + | Pour mieux comprendre, créez |
< | < | ||
- | [root@centos7 ~]# wget http://dl.fedoraproject.org/ | + | [root@redhat9 rep1]# cd .. |
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
- | Commencez par installer la dépendance de Bastille | + | Créez ensuite les fichier **fichier** et **rep/ |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | [root@redhat9 ~]# touch attributs/ | ||
</ | </ | ||
- | Téléchargez et installez Bastille | + | Modifiez les attributs d'une manière récursive sur le répertoire **attributs** |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
+ | |||
+ | Visualisez les attributs de l' | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | </code> | + | ----i----------------- attributs/rep |
- | Dernièrement créez un lien symbolique | + | attributs/ |
+ | ----i----------------- attributs/ | ||
- | < | + | ----i----------------- attributs/fichier |
- | [root@centos7 /]# ln -s / | + | |
</ | </ | ||
- | ===Utilisation=== | + | <WRAP center round important 60%> |
+ | **Important** - Notez que l' | ||
+ | </ | ||
- | Pour démarrez bastille en mode texte, saisissez la commande suivante | + | Essayez maintenant de déplacer le fichier **fichier**. Vous obtiendrez un résultat similaire à celui-ci |
- | | + | < |
- | + | [root@redhat9 ~]# cd attributs; mv /root/attributs/fichier / | |
- | Pour démarrez bastille en mode graphique, saisissez la commande suivante | + | mv: cannot move '/root/attributs/fichier' |
- | + | </code> | |
- | # /usr/sbin/bastille -x [Entrée] | + | |
- | + | ||
- | <WRAP center round todo 50%> | + | |
- | **A Faire** - Lancez Bastille et répondez aux questions posées. Ré-amorcez votre machine virtuelle et testez le résultat. | + | |
- | </WRAP> | + | |
=====LAB #2 - Mise en place de SELinux pour sécuriser le serveur===== | =====LAB #2 - Mise en place de SELinux pour sécuriser le serveur===== | ||
- | ====Introducton==== | + | ====2.1 - Introducton==== |
L' | L' | ||
Ligne 547: | Ligne 298: | ||
Chaque **//classe d' | Chaque **//classe d' | ||
- | ====Définitions==== | + | ====2.2 - Définitions==== |
===Security Context=== | ===Security Context=== | ||
Ligne 561: | Ligne 312: | ||
| Niveau | Un niveau est un attribut de MLS et MCS. Une plage MLS est une paire de niveaux exprimée en utilisant la syntaxe // | | Niveau | Un niveau est un attribut de MLS et MCS. Une plage MLS est une paire de niveaux exprimée en utilisant la syntaxe // | ||
- | Sous RHEL/CentOS 7, le fichier **/ | + | Sous RedHat 9, le fichier **/ |
< | < | ||
- | [root@centos7 /]# cat / | + | [root@redhat9 attributs]# cat / |
# | # | ||
# Multi-Category Security translation table for SELinux | # Multi-Category Security translation table for SELinux | ||
Ligne 593: | Ligne 344: | ||
< | < | ||
- | [root@centos7 /]# / | + | [root@redhat9 attributs]# / |
Login Name | Login Name | ||
Ligne 599: | Ligne 350: | ||
__default__ | __default__ | ||
root | root | ||
- | system_u | ||
</ | </ | ||
Ligne 628: | Ligne 378: | ||
< | < | ||
- | [root@centos7 /]# ls -lR / | + | [root@redhat9 attributs]# ls -lR / |
/ | / | ||
- | total 12 | + | total 8 |
- | -rw-r--r--. 1 root root | + | -rw-r--r--. 1 root root 1187 Oct 19 2023 config |
- | drwx------. 2 root root 6 Apr 23 16:24 final | + | -rw-r--r--. 1 root root 2668 Dec 14 2023 semanage.conf |
- | -rw-r--r--. 1 root root 2321 Aug 4 2017 semanage.conf | + | drwxr-xr-x. |
- | drwxr-xr-x. | + | |
- | drwxr-xr-x. 2 root root 6 Aug 4 2017 tmp | + | |
- | / | + | / |
- | total 0 | + | total 16 |
+ | -rw-r--r--. 1 root root 2367 Jun 5 11:17 booleans.subs_dist | ||
+ | drwxr-xr-x. 4 root root 4096 Sep 25 11:58 contexts | ||
+ | drwxr-xr-x. 2 root root 6 Jun 5 11:17 logins | ||
+ | drwxr-xr-x. 2 root root 23 Sep 25 12:04 policy | ||
+ | -rw-r--r--. 1 root root 607 Jun 5 11:17 setrans.conf | ||
+ | -rw-r--r--. 1 root root 73 Sep 25 12:04 seusers | ||
- | / | + | / |
- | total 24 | + | total 72 |
- | drwx------. | + | -rw-r--r--. 1 root root 262 Sep 25 11:58 customizable_types |
- | -rw-r--r--. 1 root root 2623 Mar 7 15:19 booleans.subs_dist | + | -rw-r--r--. 1 root root |
- | drwxr-xr-x. 4 root root 4096 Apr 23 16:20 contexts | + | -rw-r--r--. 1 root root 1111 Jun 5 11:17 default_contexts |
- | drwxr-xr-x. 2 root root 6 Mar 7 15:19 logins | + | -rw-r--r--. 1 root root |
- | drwxr-xr-x. 3 root root 19 Apr 23 16:41 modules | + | -rw-r--r--. 1 root root 29 Jun 5 11:17 failsafe_context |
- | drwxr-xr-x. 2 root root 22 Apr 23 16:41 policy | + | drwxr-xr-x. 2 root root 4096 Sep 25 12:04 files |
- | -rw-------. 1 root root 0 Mar 7 14:52 semanage.read.LOCK | + | |
- | -rw-------. 1 root root 0 Mar 7 14:52 semanage.trans.LOCK | + | |
- | -rw-r--r--. 1 root root | + | |
- | -rw-r--r--. 1 root root 176 Apr 23 16:24 seusers | + | |
--More-- | --More-- | ||
</ | </ | ||
- | Afin d' | + | Afin d' |
< | < | ||
- | [root@centos7 ~]# yum install setools-console | + | [root@redhat9 attributs]# dnf install setools-console |
</ | </ | ||
Ligne 664: | Ligne 414: | ||
< | < | ||
- | [root@centos7 ~]# seinfo | + | [root@redhat9 attributs]# seinfo |
Statistics for policy file: / | Statistics for policy file: / | ||
- | Policy Version | + | Policy Version: |
- | + | Target Policy: | |
- | | + | Handle unknown classes: |
- | | + | |
- | | + | Sensitivities: |
- | | + | Types: |
- | | + | Users: |
- | | + | Booleans: |
- | | + | Allow: |
- | | + | Auditallow: |
- | | + | Type_trans: |
- | Role_trans: | + | Type_member: |
- | Constraints: 109 Validatetrans: 0 | + | |
- | | + | Constraints: |
- | | + | MLS Constrain: |
- | | + | |
- | | + | Defaults: |
+ | Allowxperm: | ||
+ | | ||
+ | Ibendportcon: | ||
+ | | ||
+ | Genfscon: | ||
+ | Netifcon: | ||
</ | </ | ||
Ligne 794: | Ligne 549: | ||
< | < | ||
- | [root@centos7 /]# cat / | + | [root@redhat9 attributs]# cat / |
# This file controls the state of SELinux on the system. | # This file controls the state of SELinux on the system. | ||
Ligne 801: | Ligne 556: | ||
# | # | ||
# | # | ||
+ | # See also: | ||
+ | # https:// | ||
+ | # | ||
+ | # NOTE: In earlier Fedora kernel builds, SELINUX=disabled would also | ||
+ | # fully disable SELinux during boot. If you need a system with SELinux | ||
+ | # fully disabled instead of SELinux running with no policy loaded, you | ||
+ | # need to pass selinux=0 to the kernel command line. You can use grubby | ||
+ | # to persistently set the bootloader to boot with selinux=0: | ||
+ | # | ||
+ | # grubby --update-kernel ALL --args selinux=0 | ||
+ | # | ||
+ | # To revert back to SELinux enabled: | ||
+ | # | ||
+ | # grubby --update-kernel ALL --remove-args selinux | ||
+ | # | ||
SELINUX=enforcing | SELINUX=enforcing | ||
- | # SELINUXTYPE= can take one of three two values: | + | # SELINUXTYPE= can take one of these three values: |
# | # | ||
- | # | + | # |
# mls - Multi Level Security protection. | # mls - Multi Level Security protection. | ||
- | SELINUXTYPE=targeted | + | SELINUXTYPE=targeted |
</ | </ | ||
Ligne 812: | Ligne 582: | ||
< | < | ||
- | [root@centos7 /]# getenforce | + | [root@redhat9 attributs]# getenforce |
Enforcing | Enforcing | ||
</ | </ | ||
Ligne 819: | Ligne 589: | ||
< | < | ||
- | [root@centos7 /]# setenforce permissive | + | [root@redhat9 attributs]# setenforce permissive |
- | [root@centos7 /]# getenforce | + | |
+ | [root@redhat9 attributs]# getenforce | ||
Permissive | Permissive | ||
</ | </ | ||
Ligne 827: | Ligne 598: | ||
< | < | ||
- | [root@centos7 /]# sestatus | + | root@redhat9 attributs]# sestatus |
SELinux status: | SELinux status: | ||
SELinuxfs mount: | SELinuxfs mount: | ||
Ligne 836: | Ligne 607: | ||
Policy MLS status: | Policy MLS status: | ||
Policy deny_unknown status: | Policy deny_unknown status: | ||
- | Max kernel policy version: | + | Memory protection checking: |
+ | Max kernel policy version: | ||
</ | </ | ||
Ligne 844: | Ligne 616: | ||
< | < | ||
- | [root@centos7 /]# sestatus -v | + | [root@redhat9 attributs]# sestatus -v |
SELinux status: | SELinux status: | ||
SELinuxfs mount: | SELinuxfs mount: | ||
Ligne 853: | Ligne 625: | ||
Policy MLS status: | Policy MLS status: | ||
Policy deny_unknown status: | Policy deny_unknown status: | ||
- | Max kernel policy version: | + | Memory protection checking: |
+ | Max kernel policy version: | ||
Process contexts: | Process contexts: | ||
Ligne 870: | Ligne 643: | ||
/ | / | ||
/ | / | ||
- | / | ||
- | / | ||
</ | </ | ||
Ligne 881: | Ligne 652: | ||
< | < | ||
- | [root@centos7 /]# getsebool -a | more | + | [root@redhat9 attributs]# getsebool -a | more |
abrt_anon_write --> off | abrt_anon_write --> off | ||
abrt_handle_event --> off | abrt_handle_event --> off | ||
Ligne 902: | Ligne 673: | ||
cobbler_use_nfs --> off | cobbler_use_nfs --> off | ||
collectd_tcp_network_connect --> off | collectd_tcp_network_connect --> off | ||
+ | colord_use_nfs --> off | ||
condor_tcp_network_connect --> off | condor_tcp_network_connect --> off | ||
conman_can_network --> off | conman_can_network --> off | ||
+ | conman_use_nfs --> off | ||
container_connect_any --> off | container_connect_any --> off | ||
+ | container_manage_cgroup --> off | ||
+ | container_read_certs --> off | ||
+ | container_use_cephfs --> off | ||
+ | container_use_devices --> off | ||
+ | container_use_dri_devices --> on | ||
+ | container_use_ecryptfs --> off | ||
+ | container_user_exec_content --> on | ||
+ | cron_can_relabel --> off | ||
+ | cron_system_cronjob_use_shares --> off | ||
+ | cron_userdomain_transition --> on | ||
+ | cups_execmem --> off | ||
+ | cvs_read_shadow --> off | ||
+ | daemons_dontaudit_scheduling --> on | ||
+ | daemons_dump_core --> off | ||
+ | daemons_enable_cluster_mode --> off | ||
+ | daemons_use_tcp_wrapper --> off | ||
+ | daemons_use_tty --> off | ||
+ | dbadm_exec_content --> on | ||
+ | dbadm_manage_user_files --> off | ||
+ | dbadm_read_user_files --> off | ||
+ | deny_bluetooth --> off | ||
+ | deny_execmem --> off | ||
+ | deny_ptrace --> off | ||
+ | dhcpc_exec_iptables --> off | ||
+ | dhcpd_use_ldap --> off | ||
+ | dnsmasq_use_ipset --> off | ||
+ | domain_can_mmap_files --> off | ||
--More-- | --More-- | ||
</ | </ | ||
Ligne 911: | Ligne 711: | ||
< | < | ||
- | [root@centos7 /]# sestatus -b | more | + | [root@redhat9 attributs]# sestatus -b | more |
SELinux status: | SELinux status: | ||
SELinuxfs mount: | SELinuxfs mount: | ||
Ligne 920: | Ligne 720: | ||
Policy MLS status: | Policy MLS status: | ||
Policy deny_unknown status: | Policy deny_unknown status: | ||
- | Max kernel policy version: | + | Memory protection checking: |
+ | Max kernel policy version: | ||
Policy booleans: | Policy booleans: | ||
Ligne 935: | Ligne 736: | ||
boinc_execmem | boinc_execmem | ||
cdrecord_read_content | cdrecord_read_content | ||
+ | cluster_can_network_connect | ||
+ | cluster_manage_all_files | ||
+ | cluster_use_execmem | ||
+ | cobbler_anon_write | ||
+ | cobbler_can_network_connect | ||
+ | cobbler_use_cifs | ||
+ | cobbler_use_nfs | ||
+ | collectd_tcp_network_connect | ||
+ | colord_use_nfs | ||
+ | condor_tcp_network_connect | ||
+ | conman_can_network | ||
+ | conman_use_nfs | ||
+ | container_connect_any | ||
+ | container_manage_cgroup | ||
+ | container_read_certs | ||
+ | container_use_cephfs | ||
+ | container_use_devices | ||
+ | container_use_dri_devices | ||
+ | container_use_ecryptfs | ||
+ | container_user_exec_content | ||
+ | cron_can_relabel | ||
+ | cron_system_cronjob_use_shares | ||
+ | cron_userdomain_transition | ||
+ | cups_execmem | ||
+ | cvs_read_shadow | ||
+ | daemons_dontaudit_scheduling | ||
+ | daemons_dump_core | ||
+ | daemons_enable_cluster_mode | ||
--More-- | --More-- | ||
</ | </ | ||
Ligne 941: | Ligne 770: | ||
< | < | ||
- | [root@centos7 /]# setsebool antivirus_can_scan_system 1 | + | [root@redhat9 attributs]# setsebool antivirus_can_scan_system 1 |
- | [root@centos7 /]# getsebool antivirus_can_scan_system | + | |
+ | [root@redhat9 attributs]# getsebool antivirus_can_scan_system | ||
antivirus_can_scan_system --> on | antivirus_can_scan_system --> on | ||
- | [root@centos7 /]# setsebool antivirus_can_scan_system 0 | + | |
- | [root@centos7 /]# getsebool antivirus_can_scan_system | + | [root@redhat9 attributs]# setsebool antivirus_can_scan_system 0 |
+ | |||
+ | [root@redhat9 attributs]# getsebool antivirus_can_scan_system | ||
antivirus_can_scan_system --> off | antivirus_can_scan_system --> off | ||
</ | </ | ||
Ligne 954: | Ligne 786: | ||
< | < | ||
- | [root@centos7 ~]# semodule -DB | + | [root@redhat9 attributs]# semodule -DB |
</ | </ | ||
Ligne 960: | Ligne 792: | ||
< | < | ||
- | [root@centos7 ~]# seinfo | + | [root@redhat9 attributs]# seinfo |
Statistics for policy file: / | Statistics for policy file: / | ||
- | Policy Version | + | Policy Version: |
- | + | Target Policy: | |
- | | + | Handle unknown classes: |
- | | + | |
- | | + | Sensitivities: |
- | | + | Types: |
- | | + | Users: |
- | | + | Booleans: |
- | | + | Allow: |
- | | + | Auditallow: |
- | | + | Type_trans: |
- | Role_trans: | + | Type_member: |
- | Constraints: 109 Validatetrans: 0 | + | |
- | | + | Constraints: |
- | | + | MLS Constrain: |
- | | + | |
- | | + | Defaults: |
+ | Allowxperm: | ||
+ | | ||
+ | Ibendportcon: | ||
+ | | ||
+ | Genfscon: | ||
+ | Netifcon: | ||
</ | </ | ||
- | ====Copier et Déplacer des Fichiers==== | + | ====3.1 - Copier et Déplacer des Fichiers==== |
Créez deux fichiers **file1** et **file2** en tant que l' | Créez deux fichiers **file1** et **file2** en tant que l' | ||
< | < | ||
- | [root@centos7 /]# exit | + | [root@redhat9 attributs]# exit |
logout | logout | ||
- | [trainee@centos7 | + | |
- | [trainee@centos7 | + | [trainee@redhat9 |
- | -rw-rw-r--. trainee trainee | + | |
- | -rw-rw-r--. trainee trainee | + | [trainee@redhat9 |
+ | unconfined_u: | ||
+ | unconfined_u: | ||
</ | </ | ||
Ligne 1000: | Ligne 839: | ||
< | < | ||
- | [trainee@centos7 | + | [trainee@redhat9 |
- | [trainee@centos7 | + | |
- | -rw-rw-r--. trainee trainee | + | [trainee@redhat9 |
+ | unconfined_u: | ||
</ | </ | ||
Ligne 1010: | Ligne 850: | ||
< | < | ||
- | [trainee@centos7 | + | [trainee@redhat9 |
- | [trainee@centos7 | + | |
- | -rw-rw-r--. trainee trainee | + | [trainee@redhat9 |
+ | unconfined_u: | ||
</ | </ | ||
Notez que la commande **mv** maintient le **type** d' | Notez que la commande **mv** maintient le **type** d' | ||
- | ====Vérifier les SC des Processus==== | + | ====3.2 - Vérifier les SC des Processus==== |
Il convient d' | Il convient d' | ||
< | < | ||
- | [trainee@centos7 | + | [trainee@redhat9 |
- | LABEL | + | LABEL |
- | system_u: | + | system_u: |
- | deserialize | + | system --deserialize |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | system_u: |
- | system_u: | + | --More-- |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | system_u: | + | |
- | --Plus-- | + | |
</ | </ | ||
- | ====Visualiser la SC d'un Utilisateur==== | + | ====3.3 - Visualiser la SC d'un Utilisateur==== |
Utilisez l' | Utilisez l' | ||
< | < | ||
- | [trainee@centos7 | + | [trainee@redhat9 |
unconfined_u: | unconfined_u: | ||
</ | </ | ||
Ligne 1073: | Ligne 909: | ||
< | < | ||
- | [trainee@centos7 | + | [trainee@redhat9 |
- | uid=0(root) gid=0(root) | + | uid=0(root) gid=0(root) |
- | [trainee@centos7 | + | |
- | id: impossible d' | + | [trainee@redhat9 |
+ | id: cannot print security context when user specified | ||
</ | </ | ||
- | ====Vérifier la SC d'un fichier==== | + | ====3.4 - Vérifier la SC d'un fichier==== |
Il convient d' | Il convient d' | ||
< | < | ||
- | [trainee@centos7 | + | [trainee@redhat9 |
- | [trainee@centos7 | + | |
- | -rw-r--r--. root root unconfined_u: | + | [trainee@redhat9 |
- | -rw-r--r--. root root system_u: | + | unconfined_u: |
- | drwxr-xr-x. root root system_u: | + | system_u: |
- | -rw-r-----. root root system_u: | + | |
- | drwxr-xr-x. root root system_u: | + | |
- | drwxr-xr-x. root root system_u: | + | system_u: |
- | -rw-r--r--. root root unconfined_u: | + | |
- | -rw-r--r--. root root unconfined_u:object_r:locale_t:s0 locale.conf | + | |
- | lrwxrwxrwx. root root unconfined_u:object_r:locale_t:s0 localtime -> ../ | + | system_u: |
- | -rw-r--r--. root root unconfined_u: | + | |
- | -rw-r--r--. root root system_u: | + | |
- | drwxr-xr-x. root root system_u: | + | |
- | drwxr-xr-x. root root system_u: | + | |
- | drwxr-xr-x. root root system_u: | + | |
</ | </ | ||
- | ====Troubleshooting SELinux==== | + | ====3.5 - Troubleshooting SELinux==== |
L' | L' | ||
Ligne 1108: | Ligne 941: | ||
Si le démon **auditd** est démarré, les messages de %%SELinux%% sont consignés dans le fichier **/ | Si le démon **auditd** est démarré, les messages de %%SELinux%% sont consignés dans le fichier **/ | ||
- | ===La commande chcon=== | + | ====3.6 - La commande chcon==== |
La commande **chcon** permet de modifier // | La commande **chcon** permet de modifier // | ||
+ | |||
+ | Prenons le cas de la création d'un répertoire à la racine du système de fichiers afin d'y stocker les pages web du serveur apache : | ||
< | < | ||
- | [trainee@centos7 | + | [trainee@redhat9 |
- | [trainee@centos7 ~]$ chcon --help | + | Password: fenestros |
- | Utilisation : chcon [OPTION]... CONTEXT FILE... | + | |
- | ou : chcon [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE... | + | |
- | ou : chcon [OPTION]... --reference=RFILE FILE... | + | |
- | Modifier le contexte de sécurité SELinux de chaque FILE en CONTEXT. | + | |
- | Avec --reference, | + | |
- | celui de RFILE. | + | |
- | + | ||
- | Les arguments obligatoires pour les options longues le sont aussi pour les | + | |
- | options courtes. | + | |
- | --dereference | + | |
- | | + | |
- | -h, --no-dereference | + | |
- | | + | |
- | -u, --user=USER | + | |
- | | + | |
- | -r, --role=ROLE | + | |
- | -t, --type=TYPE | + | |
- | -l, --range=RANGE | + | |
- | | + | |
- | --no-preserve-root ne pas traiter « / » de manière spéciale (par défaut) | + | |
- | --preserve-root | + | |
- | --reference=RFILE | + | |
- | | + | |
- | -R, --recursive | + | |
- | -v, --verbose | + | |
- | + | ||
- | Les options suivantes modifient la façon de parcourir la hiérarchie lorsque | + | |
- | l' | + | |
- | dernière sera prise en compte. | + | |
- | + | ||
- | -H si l' | + | |
- | | + | |
- | -L | + | |
- | | + | |
- | -P ne parcourir aucun lien symbolique (par défaut) | + | |
- | + | ||
- | --help | + | |
- | --version | + | |
- | Aide en ligne de GNU coreutils : | + | [root@redhat9 ~]# mkdir /www |
- | Signalez les problèmes de traduction de « chcon » à : < | + | [root@redhat9 ~]# touch /www/index.html |
- | Utilisez « info coreutils 'chcon invocation' | + | |
</ | </ | ||
- | Prenons | + | Installez maintenant |
< | < | ||
- | [trainee@centos7 ~]$ su - | + | [root@redhat9 |
- | Mot de passe : | + | |
- | Dernière connexion : dimanche 17 juin 2018 à 20:21:42 CEST sur pts/1 | + | |
- | [root@centos7 ~]# mkdir /www | + | |
- | [root@centos7 | + | |
</ | </ | ||
- | Installez maintenant | + | Activez et démarrez |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | ○ httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | [root@redhat9 ~]# systemctl enable --now httpd | ||
+ | Created symlink / | ||
+ | [root@redhat9 ~]# systemctl status httpd | ||
+ | ● httpd.service - The Apache HTTP Server | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | Main PID: 101100 (httpd) | ||
+ | | ||
+ | Tasks: 177 (limit: 48800) | ||
+ | | ||
+ | CPU: 86ms | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | Oct 22 10:15:49 redhat9.ittraining.loc systemd[1]: Starting The Apache HTTP Server... | ||
+ | Oct 22 10:15:49 redhat9.ittraining.loc httpd[101100]: | ||
+ | Oct 22 10:15:49 redhat9.ittraining.loc systemd[1]: Started The Apache HTTP Server. | ||
</ | </ | ||
Modifiez ensuite la directive **%%DocumentRoot%%** dans le fichier **/ | Modifiez ensuite la directive **%%DocumentRoot%%** dans le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# vi / | ||
+ | </ | ||
< | < | ||
Ligne 1208: | Ligne 1030: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | [root@centos7 | + | |
+ | [root@redhat9 | ||
< | < | ||
< | < | ||
Ligne 1223: | Ligne 1046: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
Ligne 1229: | Ligne 1052: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
Ligne 1235: | Ligne 1058: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
- | Consultez | + | Installez |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
- | Pour consulter les messages d' | + | Consultez le site localhost en utilisant |
- | + | ||
- | Installez donc ce paquet | + | |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
Ligne 1255: | Ligne 1076: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | type=AVC msg=audit(1524491216.546: | + | |
- | + | ||
- | **** Invalid AVC allowed in current policy *** | + | |
- | + | ||
- | type=AVC msg=audit(1524491220.766: | + | |
- | + | ||
- | **** Invalid AVC allowed in current policy *** | + | |
</ | </ | ||
Ligne 1268: | Ligne 1082: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | found 3 alerts in / | + | found 24 alerts in / |
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
- | SELinux is preventing /usr/libexec/dbus-1/ | + | SELinux is preventing /usr/bin/pkla-check-authorization |
***** Plugin catchall (100. confidence) suggests | ***** Plugin catchall (100. confidence) suggests | ||
- | you believe that dbus-daemon-launch-helper | + | If you believe that pkla-check-authorization |
Then you should report this as a bug. | Then you should report this as a bug. | ||
You can generate a local policy module to allow this access. | You can generate a local policy module to allow this access. | ||
Do | Do | ||
allow this access for now by executing: | allow this access for now by executing: | ||
- | # ausearch -c 'dbus-daemon-lau' --raw | audit2allow -M my-dbusdaemonlau | + | # ausearch -c 'pkla-check-auth' --raw | audit2allow -M my-pklacheckauth |
- | # semodule -i my-dbusdaemonlau.pp | + | # semodule |
Additional Information: | Additional Information: | ||
- | Source Context | + | Source Context |
- | Target Context | + | Target Context |
- | 023 | + | Target Objects |
- | Target Objects | + | Source |
- | Source | + | Source Path /usr/bin/pkla-check-authorization |
- | Source Path /usr/libexec/dbus-1/ | + | |
Port < | Port < | ||
Host < | Host < | ||
- | Source RPM Packages | + | Source RPM Packages |
- | Target RPM Packages | + | Target RPM Packages |
- | Policy RPM selinux-policy-3.13.1-166.el7_4.9.noarch | + | SELinux |
+ | Local Policy RPM selinux-policy-targeted-38.1.35-2.el9_4.2.noarch | ||
Selinux Enabled | Selinux Enabled | ||
Policy Type | Policy Type | ||
Enforcing Mode Permissive | Enforcing Mode Permissive | ||
- | Host Name centos7.fenestros.loc | + | Host Name redhat9.ittraining.loc |
- | Platform | + | Platform |
- | | + | |
- | | + | |
- | Alert Count 1 | + | |
- | First Seen | + | Alert Count 10 |
- | Last Seen 2020-01-23 16:04:33 CET | + | First Seen |
- | --More--(4%) | + | Last Seen 2024-10-22 10:33:01 CEST |
+ | Local ID 344c2abc-bac6-4064-ae22-411f0ce680cd | ||
+ | |||
+ | Raw Audit Messages | ||
+ | type=AVC msg=audit(1729585981.217:17543): avc: denied | ||
+ | ntext=system_u: | ||
+ | |||
+ | |||
+ | type=AVC msg=audit(1729585981.217: | ||
+ | :s0 tcontext=system_u: | ||
+ | |||
+ | |||
+ | --More--(1%) | ||
</ | </ | ||
Ligne 1314: | Ligne 1140: | ||
< | < | ||
- | ***** Plugin catchall (17.1 confidence) suggests | + | ... |
+ | ***** Plugin catchall (100. confidence) suggests | ||
- | you believe that httpd should | + | If you believe that httpd should |
Then you should report this as a bug. | Then you should report this as a bug. | ||
You can generate a local policy module to allow this access. | You can generate a local policy module to allow this access. | ||
Ligne 1322: | Ligne 1149: | ||
allow this access for now by executing: | allow this access for now by executing: | ||
# ausearch -c ' | # ausearch -c ' | ||
- | # semodule -i my-httpd.pp | + | # semodule |
Additional Information: | Additional Information: | ||
Source Context | Source Context | ||
- | Target Context | + | Target Context |
- | Target Objects | + | Target Objects |
Source | Source | ||
Source Path / | Source Path / | ||
Port < | Port < | ||
Host < | Host < | ||
- | Source RPM Packages | + | Source RPM Packages |
- | Target RPM Packages | + | Target RPM Packages |
- | Policy RPM selinux-policy-3.13.1-166.el7_4.9.noarch | + | SELinux |
+ | Local Policy RPM selinux-policy-targeted-38.1.35-2.el9_4.2.noarch | ||
Selinux Enabled | Selinux Enabled | ||
Policy Type | Policy Type | ||
Enforcing Mode Permissive | Enforcing Mode Permissive | ||
- | Host Name centos7.fenestros.loc | + | Host Name redhat9.ittraining.loc |
- | Platform | + | Platform |
- | | + | |
- | | + | |
- | Alert Count 1 | + | |
- | First Seen | + | Alert Count 9 |
- | Last Seen 2020-01-23 16:04:30 CET | + | First Seen |
- | Local ID | + | Last Seen 2024-10-22 10:32:34 CEST |
+ | Local ID | ||
Raw Audit Messages | Raw Audit Messages | ||
- | type=AVC msg=audit(1579791870.276:244): avc: denied | + | type=AVC msg=audit(1729585954.475:17532): avc: denied |
+ | t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=capability permissive=1 | ||
- | type=SYSCALL msg=audit(1579791870.276:244): arch=x86_64 syscall=stat success=yes exit=0 a0=56255c9727b8 | + | type=SYSCALL msg=audit(1729585954.475:17532): arch=x86_64 syscall=setsockopt |
+ | 101828 | ||
+ | _u: | ||
+ | ID=root | ||
- | Hash: httpd, | + | Hash: httpd, |
</ | </ | ||
Ligne 1360: | Ligne 1193: | ||
< | < | ||
- | [root@centos6 | + | [root@redhat9 |
- | -rw-r--r--. root root unconfined_u: | + | unconfined_u: |
</ | </ | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | -rw-r--r--. root root unconfined_u: | + | unconfined_u: |
</ | </ | ||
Ligne 1374: | Ligne 1207: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | changing security context of ‘/ | + | changing security context of '/ |
- | changing security context of ‘/www’ | + | changing security context of '/www' |
- | [root@centos7 | + | [root@redhat9 |
- | -rw-r--r--. root root unconfined_u: | + | unconfined_u: |
</ | </ | ||
Ligne 1385: | Ligne 1218: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
- | ====La | + | Les options de la commande |
- | <file> | + | <code> |
- | usage: | + | [root@redhat9 ~]# chcon --help |
- | </file> | + | Usage: chcon [OPTION]... CONTEXT FILE... |
+ | or: chcon [OPTION]... | ||
+ | or: chcon [OPTION]... --reference=RFILE FILE... | ||
+ | Change the SELinux security context of each FILE to CONTEXT. | ||
+ | With --reference, | ||
+ | |||
+ | Mandatory arguments to long options are mandatory for short options too. | ||
+ | --dereference | ||
+ | the default), rather than the symbolic link itself | ||
+ | -h, --no-dereference | ||
+ | -u, --user=USER | ||
+ | -r, --role=ROLE | ||
+ | -t, --type=TYPE | ||
+ | -l, --range=RANGE | ||
+ | --no-preserve-root | ||
+ | --preserve-root | ||
+ | --reference=RFILE | ||
+ | a CONTEXT value | ||
+ | -R, --recursive | ||
+ | -v, --verbose | ||
+ | |||
+ | The following options modify how a hierarchy is traversed when the -R | ||
+ | option is also specified. | ||
+ | one takes effect. | ||
+ | |||
+ | -H if a command line argument is a symbolic link | ||
+ | to a directory, traverse it | ||
+ | -L | ||
+ | | ||
+ | -P do not traverse any symbolic links (default) | ||
+ | |||
+ | --help | ||
+ | --version | ||
+ | |||
+ | GNU coreutils online help: < | ||
+ | Full documentation < | ||
+ | or available locally via: info ' | ||
+ | </ | ||
+ | |||
+ | ====3.7 - La commande restorecon==== | ||
Pour illustrer l' | Pour illustrer l' | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | [root@centos7 | + | |
- | -rw-r--r--. root root unconfined_u: | + | [root@redhat9 |
- | -rw-r--r--. root root unconfined_u: | + | |
+ | | ||
</ | </ | ||
Ligne 1406: | Ligne 1279: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | [root@centos7 | + | |
- | [root@centos7 | + | [root@redhat9 |
- | -rw-r--r--. root root unconfined_u: | + | |
- | -rw-r--r--. root root unconfined_u: | + | [root@redhat9 |
- | -rw-r--r--. root root unconfined_u: | + | unconfined_u: |
+ | unconfined_u: | ||
</ | </ | ||
Ligne 1421: | Ligne 1295: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | restorecon reset / | + | Relabeled |
- | [root@centos7 | + | [root@redhat9 |
- | -rw-r--r--. root root unconfined_u: | + | unconfined_u: |
- | -rw-r--r--. root root unconfined_u: | + | unconfined_u: |
- | -rw-r--r--. root root unconfined_u: | + | |
</ | </ | ||
- | ====Le fichier / | + | ====3.8 - Le fichier / |
En cas de besoin il est intéressant de pouvoir restaurer les SC par défaut sur l' | En cas de besoin il est intéressant de pouvoir restaurer les SC par défaut sur l' | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | [root@centos7 | + | |
+ | [root@redhat9 | ||
</ | </ | ||
- | ====La commande semanage==== | + | ====3.9 - La commande semanage==== |
- | + | ||
- | La commande **semanage** peut prendre plusieurs options : | + | |
- | + | ||
- | < | + | |
- | [root@centos7 tmp]# semanage --help | + | |
- | usage: semanage [-h] | + | |
- | + | ||
- | {import, | + | |
- | ... | + | |
- | + | ||
- | semanage is used to configure certain elements of SELinux policy with-out | + | |
- | requiring modification to or recompilation from policy source. | + | |
- | + | ||
- | positional arguments: | + | |
- | {import, | + | |
- | import | + | |
- | export | + | |
- | login | + | |
- | confined users | + | |
- | user Manage SELinux confined users (Roles and levels for an | + | |
- | SELinux user) | + | |
- | port Manage network port type definitions | + | |
- | interface | + | |
- | module | + | |
- | node Manage network node type definitions | + | |
- | fcontext | + | |
- | boolean | + | |
- | permissive | + | |
- | dontaudit | + | |
- | + | ||
- | optional arguments: | + | |
- | -h, --help | + | |
- | </ | + | |
Pour illustrer l' | Pour illustrer l' | ||
Ligne 1479: | Ligne 1320: | ||
< | < | ||
- | [root@centos7 tmp]# semanage port -l | + | [trainee@redhat9 ~]$ su - |
- | SELinux Port Type Proto Port Number | + | Password: fenestros |
- | afs3_callback_port_t | + | [root@redhat9 ~]# semanage port -l | grep http |
- | afs3_callback_port_t | + | |
- | afs_bos_port_t | + | |
- | afs_fs_port_t | + | |
- | afs_fs_port_t | + | |
- | afs_ka_port_t | + | |
- | afs_pt_port_t | + | |
- | afs_pt_port_t | + | |
- | afs_vl_port_t | + | |
- | agentx_port_t | + | |
- | agentx_port_t | + | |
- | amanda_port_t | + | |
- | amanda_port_t | + | |
- | amavisd_recv_port_t | + | |
- | amavisd_send_port_t | + | |
- | amqp_port_t | + | |
- | amqp_port_t | + | |
- | aol_port_t | + | |
- | aol_port_t | + | |
- | apc_port_t | + | |
- | apc_port_t | + | |
- | apcupsd_port_t | + | |
- | apcupsd_port_t | + | |
- | apertus_ldp_port_t | + | |
- | apertus_ldp_port_t | + | |
- | asterisk_port_t | + | |
- | asterisk_port_t | + | |
- | audit_port_t | + | |
- | auth_port_t | + | |
- | bacula_port_t | + | |
- | bacula_port_t | + | |
- | bctp_port_t | + | |
- | bctp_port_t | + | |
- | bgp_port_t | + | |
- | bgp_port_t | + | |
- | boinc_client_port_t | + | |
- | boinc_client_port_t | + | |
- | boinc_port_t | + | |
- | brlp_port_t | + | |
- | certmaster_port_t | + | |
- | chronyd_port_t | + | |
- | clamd_port_t | + | |
- | clockspeed_port_t | + | |
- | cluster_port_t | + | |
- | cluster_port_t | + | |
- | cma_port_t | + | |
- | cma_port_t | + | |
- | cobbler_port_t | + | |
- | collectd_port_t | + | |
- | commplex_link_port_t | + | |
- | commplex_link_port_t | + | |
- | commplex_main_port_t | + | |
- | commplex_main_port_t | + | |
- | comsat_port_t | + | |
- | condor_port_t | + | |
- | condor_port_t | + | |
- | conman_port_t | + | |
- | conman_port_t | + | |
- | connlcli_port_t | + | |
- | connlcli_port_t | + | |
- | couchdb_port_t | + | |
- | couchdb_port_t | + | |
- | ctdb_port_t | + | |
- | ctdb_port_t | + | |
- | cvs_port_t | + | |
- | cvs_port_t | + | |
- | cyphesis_port_t | + | |
- | cyphesis_port_t | + | |
- | cyrus_imapd_port_t | + | |
- | daap_port_t | + | |
- | daap_port_t | + | |
- | dbskkd_port_t | + | |
- | dcc_port_t | + | |
- | dccm_port_t | + | |
- | dccm_port_t | + | |
- | dey_keyneg_port_t | + | |
- | dey_keyneg_port_t | + | |
- | dey_sapi_port_t | + | |
- | dhcpc_port_t | + | |
- | dhcpc_port_t | + | |
- | dhcpd_port_t | + | |
- | dhcpd_port_t | + | |
- | dict_port_t | + | |
- | distccd_port_t | + | |
- | dns_port_t | + | |
- | dns_port_t | + | |
- | dnssec_port_t | + | |
- | dogtag_port_t | + | |
- | echo_port_t | + | |
- | echo_port_t | + | |
- | efs_port_t | + | |
- | embrace_dp_c_port_t | + | |
- | embrace_dp_c_port_t | + | |
- | ephemeral_port_t | + | |
- | ephemeral_port_t | + | |
- | epmap_port_t | + | |
- | epmap_port_t | + | |
- | epmd_port_t | + | |
- | epmd_port_t | + | |
- | fac_restore_port_t | + | |
- | fac_restore_port_t | + | |
- | fingerd_port_t | + | |
- | flash_port_t | + | |
- | flash_port_t | + | |
- | fmpro_internal_port_t | + | |
- | fmpro_internal_port_t | + | |
- | freeipmi_port_t | + | |
- | freeipmi_port_t | + | |
- | ftp_data_port_t | + | |
- | ftp_port_t | + | |
- | ftp_port_t | + | |
- | gatekeeper_port_t | + | |
- | gatekeeper_port_t | + | |
- | gdomap_port_t | + | |
- | gdomap_port_t | + | |
- | gds_db_port_t | + | |
- | gds_db_port_t | + | |
- | gear_port_t | + | |
- | gear_port_t | + | |
- | geneve_port_t | + | |
- | giftd_port_t | + | |
- | git_port_t | + | |
- | git_port_t | + | |
- | glance_port_t | + | |
- | glance_port_t | + | |
- | glance_registry_port_t | + | |
- | glance_registry_port_t | + | |
- | gluster_port_t | + | |
- | gluster_port_t | + | |
- | gopher_port_t | + | |
- | gopher_port_t | + | |
- | gpsd_port_t | + | |
- | hadoop_datanode_port_t | + | |
- | hadoop_namenode_port_t | + | |
- | hddtemp_port_t | + | |
- | hi_reserved_port_t | + | |
- | hi_reserved_port_t | + | |
- | howl_port_t | + | |
- | howl_port_t | + | |
- | hplip_port_t | + | |
http_cache_port_t | http_cache_port_t | ||
http_cache_port_t | http_cache_port_t | ||
http_port_t | http_port_t | ||
- | ... | + | pegasus_http_port_t |
+ | pegasus_https_port_t | ||
</ | </ | ||
Ligne 1637: | Ligne 1340: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
Ligne 1643: | Ligne 1346: | ||
< | < | ||
- | [root@centos7 tmp]# semanage port -l | grep http | + | [root@redhat9 ~]# semanage port -l | grep http |
http_cache_port_t | http_cache_port_t | ||
http_cache_port_t | http_cache_port_t | ||
Ligne 1651: | Ligne 1354: | ||
</ | </ | ||
- | ====La commande audit2allow==== | + | Les options **semanage** sont : |
- | < | + | [root@redhat9 ~]# semanage |
- | [root@centos7 tmp]# audit2allow | + | usage: semanage |
- | Usage: audit2allow | + | |
- | Options: | + | semanage is used to configure certain elements of SELinux policy with-out requiring modification or recompilation from policy source. |
- | | + | |
+ | positional arguments: | ||
+ | | ||
+ | import | ||
+ | export | ||
+ | login | ||
+ | user Manage SELinux confined users (Roles and levels for an SELinux user) | ||
+ | port Manage network port type definitions | ||
+ | ibpkey | ||
+ | ibendport | ||
+ | interface | ||
+ | module | ||
+ | node Manage network node type definitions | ||
+ | fcontext | ||
+ | boolean | ||
+ | permissive | ||
+ | dontaudit | ||
+ | |||
+ | optional arguments: | ||
-h, --help | -h, --help | ||
- | -b, --boot | + | |
- | -a, --all read input from audit log - conflicts with -i | + | ====3.10 - La commande audit2allow==== |
- | -p POLICY, --policy=POLICY | + | |
- | Policy file to use for analysis | + | |
- | -d, --dmesg | + | |
- | --input | + | |
- | -i INPUT, --input=INPUT | + | |
- | read input from < | + | |
- | -l, --lastreload | + | |
- | -r, --requires | + | |
- | -m MODULE, --module=MODULE | + | |
- | set the module name - implies --requires | + | |
- | -M MODULE_PACKAGE, | + | |
- | generate a module package - conflicts with -o and -m | + | |
- | -o OUTPUT, --output=OUTPUT | + | |
- | append output to < | + | |
- | -D, --dontaudit | + | |
- | -R, --reference | + | |
- | -N, --noreference | + | |
- | -v, --verbose | + | |
- | -e, --explain | + | |
- | -t TYPE, --type=TYPE only process messages with a type that matches this | + | |
- | regex | + | |
- | --perm-map=PERM_MAP | + | |
- | --interface-info=INTERFACE_INFO | + | |
- | file name of interface information | + | |
- | --debug | + | |
- | -w, --why | + | |
- | of why the access was denied | + | |
- | </ | + | |
La création d'un module de politique personnalisé se fait en utilisant la commande **audit2allow**. L' | La création d'un module de politique personnalisé se fait en utilisant la commande **audit2allow**. L' | ||
Ligne 1699: | Ligne 1391: | ||
< | < | ||
- | [root@centos7 tmp]# mkdir /www1 | + | [root@redhat9 ~]# mkdir /www1 |
- | [root@centos7 tmp]# touch / | + | |
+ | [root@redhat9 ~]# touch / | ||
</ | </ | ||
Éditez le fichier **/ | Éditez le fichier **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# vi / | ||
+ | </ | ||
< | < | ||
Ligne 1712: | Ligne 1409: | ||
</ | </ | ||
- | Ajoutez les section **< | + | Ajoutez les section **< |
< | < | ||
Ligne 1736: | Ligne 1433: | ||
< | < | ||
- | [root@centos7 ~]# cd ~ | + | [root@redhat9 |
- | [root@centos7 | + | |
- | [root@centos7 | + | [root@redhat9 |
< | < | ||
< | < | ||
Ligne 1752: | Ligne 1449: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
Ligne 1758: | Ligne 1455: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
Ligne 1764: | Ligne 1461: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | Red Hat Logo | ||
+ | Red Hat Enterprise Linux Test Page | ||
+ | |||
+ | This page is used to test the proper operation of the HTTP server after | ||
+ | it has been installed. If you can read this page, it means that the | ||
+ | HTTP server installed at this site is working properly. | ||
+ | | ||
+ | |||
+ | If you are a member of the general public: | ||
+ | |||
+ | The fact that you are seeing this page indicates that the website you | ||
+ | just visited is either experiencing problems, or is undergoing routine | ||
+ | | ||
+ | |||
+ | If you would like to let the administrators of this website know that | ||
+ | | ||
+ | them e-mail. In general, mail sent to the name " | ||
+ | to the website' | ||
+ | |||
+ | For example, if you experienced problems while visiting | ||
+ | | ||
+ | |||
+ | For information on Red Hat Enterprise Linux, please visit the [1]Red | ||
+ | Hat, Inc. website. The documentation for Red Hat Enterprise Linux is | ||
+ | | ||
+ | | ||
+ | |||
+ | If you are the website administrator: | ||
+ | |||
+ | You may now add content to the webroot directory. Note that until you | ||
+ | do so, people visiting your website will see this page, and not your | ||
+ | | ||
+ | |||
+ | For systems using the Apache HTTP Server: You may now add content to | ||
+ | the directory / | ||
+ | | ||
+ | | ||
+ | file / | ||
+ | |||
+ | For systems using NGINX: You should now put your content in a location | ||
+ | of your choice and edit the root configuration directive in the nginx | ||
+ | | ||
+ | [3][ Powered by Red Hat Enterprise Linux ] [ Powered by Red Hat | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | References | ||
+ | |||
+ | 1. http:// | ||
+ | 2. http:// | ||
+ | 3. https:// | ||
+ | 4. https:// | ||
+ | 5. https:// | ||
+ | 6. https:// | ||
+ | 7. https:// | ||
+ | </ | ||
+ | |||
+ | Notez que cette fois SELinux est en mode enforcing : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# getenforce | ||
+ | Enforcing | ||
</ | </ | ||
Ligne 1770: | Ligne 1532: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | type=USER_AVC msg=audit(1462020229.957: | + | type=AVC msg=audit(1729587121.979:17697): avc: denied |
- | type=AVC msg=audit(1524491216.546:616): avc: denied | + | type=AVC msg=audit(1729587121.979:17697): avc: denied |
- | type=AVC msg=audit(1524491220.766:622): avc: denied | + | type=AVC msg=audit(1729587121.979:17697): avc: denied |
- | type=AVC msg=audit(1529418883.052:818): avc: denied | + | type=AVC msg=audit(1729587426.204:17741): avc: denied |
- | type=AVC msg=audit(1529418883.052:819): avc: denied | + | type=AVC msg=audit(1729587481.218:17751): avc: denied |
- | type=AVC msg=audit(1529418919.091:822): avc: denied | + | type=AVC msg=audit(1729587481.218:17751): avc: denied |
- | type=AVC msg=audit(1529418919.092:823): avc: denied | + | type=AVC msg=audit(1729587481.218:17751): avc: denied |
- | type=AVC msg=audit(1529418954.500: | + | type=AVC msg=audit(1729587592.855:17788): avc: denied |
- | type=AVC msg=audit(1529418954.500:827): avc: denied | + | type=AVC msg=audit(1729588933.891:326): avc: denied |
- | type=AVC msg=audit(1529419054.949: | + | type=AVC msg=audit(1729588933.891:327): avc: denied |
- | type=AVC msg=audit(1529419054.949:866): avc: denied | + | |
- | type=USER_AVC msg=audit(1529421001.608: | + | |
- | type=USER_AVC msg=audit(1529421602.007: | + | |
- | type=AVC msg=audit(1529422368.058:1019): avc: denied | + | |
- | type=AVC msg=audit(1529422368.058:1020): avc: denied | + | |
</ | </ | ||
Ligne 1791: | Ligne 1548: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
Ligne 1797: | Ligne 1554: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
module httpdlocal 1.0; | module httpdlocal 1.0; | ||
require { | require { | ||
- | type httpd_t; | + | |
- | type default_t; | + | type default_t; |
- | class file getattr; | + | class capability net_admin; |
+ | | ||
} | } | ||
# | # | ||
+ | allow httpd_t default_t: | ||
- | #!!!! WARNING: | + | #!!!! This avc can be allowed using the boolean |
- | #!!!! The file '/ | + | allow httpd_t default_t:file map; |
- | #!!!! Fix with $ restorecon -R -v / | + | |
- | allow httpd_t | + | #!!!! This avc has a dontaudit rule in the current policy |
+ | allow httpd_t | ||
</ | </ | ||
Ligne 1818: | Ligne 1578: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
******************** IMPORTANT *********************** | ******************** IMPORTANT *********************** | ||
To make this policy package active, execute: | To make this policy package active, execute: | ||
Ligne 1828: | Ligne 1588: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
</ | </ | ||
Ligne 1834: | Ligne 1594: | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
- | httpdlocal 1.0 | + | httpdlocal |
</ | </ | ||
- | Redémarrez | + | Consultez |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | www test page | ||
</ | </ | ||
- | Videz le fichier | + | Les options |
< | < | ||
- | [root@centos7 | + | [root@redhat9 |
+ | Usage: audit2allow [options] | ||
+ | |||
+ | Options: | ||
+ | --version | ||
+ | -h, --help | ||
+ | -b, --boot | ||
+ | -a, --all read input from audit log - conflicts with -i | ||
+ | -p POLICY, --policy=POLICY | ||
+ | Policy file to use for analysis | ||
+ | -d, --dmesg | ||
+ | --input | ||
+ | -i INPUT, --input=INPUT | ||
+ | read input from < | ||
+ | -l, --lastreload | ||
+ | -r, --requires | ||
+ | -m MODULE, --module=MODULE | ||
+ | set the module name - implies --requires | ||
+ | -M MODULE_PACKAGE, | ||
+ | generate a module package - conflicts with -o and -m | ||
+ | -o OUTPUT, --output=OUTPUT | ||
+ | append output to < | ||
+ | -D, --dontaudit | ||
+ | -R, --reference | ||
+ | -N, --noreference | ||
+ | -v, --verbose | ||
+ | -e, --explain | ||
+ | -t TYPE, --type=TYPE | ||
+ | regex | ||
+ | --perm-map=PERM_MAP | ||
+ | --interface-info=INTERFACE_INFO | ||
+ | file name of interface information | ||
+ | -x, --xperms | ||
+ | -w, --why | ||
+ | of why the access was denied | ||
</ | </ | ||
- | Consultez | + | =====LAB #4 - Le Pare-feu Netfilter/ |
+ | |||
+ | **Netfilter** est composé de 5 //hooks// : | ||
+ | |||
+ | * NF_IP_PRE_ROUTING | ||
+ | * NF_IP_LOCAL_IN | ||
+ | * NF_IP_LOCAL_OUT | ||
+ | * NF_IP_FORWARD | ||
+ | * NF_IP_POSTROUTING | ||
+ | |||
+ | Ces hooks sont utilisés par deux branches, la première est celle concernée par les paquets qui entrent vers des services locaux : | ||
+ | |||
+ | * NF_IP_PRE_ROUTING > NF_IP_LOCAL_IN > NF_IP_LOCAL_OUT > NF_IP_POSTROUTING | ||
+ | |||
+ | tandis que la deuxième concerne les paquets qui traversent la passerelle: | ||
+ | |||
+ | * NF_IP_PRE_ROUTING > NF_IP_FORWARD > NF_IP_POSTROUTING | ||
+ | |||
+ | Si IPTABLES a été compilé en tant que module, son utilisation nécessite | ||
+ | |||
+ | * iptable_filter | ||
+ | * iptable_mangle | ||
+ | * iptable_net | ||
+ | * etc | ||
+ | |||
+ | Netfilter est organisé en **tables**. La commande **iptables** de netfilter permet d' | ||
+ | |||
+ | * La table **FILTER** | ||
+ | * La chaîne INPUT | ||
+ | * Concerne les paquets entrants | ||
+ | * Policies: ACCEPT, DROP, REJECT | ||
+ | * La chaîne OUTPUT | ||
+ | * Concerne les paquets sortants | ||
+ | * Policies: ACCEPT, DROP, REJECT | ||
+ | * La chaîne FORWARD | ||
+ | * Concerne les paquets traversant le par-feu. | ||
+ | * Policies: ACCEPT, DROP, REJECT | ||
+ | |||
+ | Si aucune table n'est précisée, c'est la table FILTER qui s' | ||
+ | |||
+ | * La table **NAT** | ||
+ | * La chaîne PREROUTING | ||
+ | * Permet de faire la translation d' | ||
+ | * Cibles: SNAT, DNAT, MASQUERADE | ||
+ | * La chaîne POSTROUTING | ||
+ | * Permet de faire la translation d' | ||
+ | * Cibles: SNAT, DNAT, MASQUERADE | ||
+ | * Le cas spécifique OUTPUT | ||
+ | * Permet la modification de la destination des paquets générés localement | ||
+ | |||
+ | * La table **MANGLE** | ||
+ | * Permet le marquage de paquets générés localement (OUTPUT) et entrants (PREROUTING) | ||
+ | |||
+ | Les **policies** sont: | ||
+ | |||
+ | * ACCEPT | ||
+ | * Permet d' | ||
+ | * DROP | ||
+ | * Permet de rejeter le paquet concerné sans générer un message d' | ||
+ | * REJECT | ||
+ | * Permet de rejeter le paquet concerné en générant une message d' | ||
+ | |||
+ | Les **cibles** sont: | ||
+ | |||
+ | * SNAT | ||
+ | * Permet de modifier l' | ||
+ | * DNAT | ||
+ | * Permet de modifier l' | ||
+ | * MASQUERADE | ||
+ | * Permet de remplacer l' | ||
+ | |||
+ | IPTABLES peut être configuré soit par des outils tels shorewall, soit en utilisant des lignes de commandes ou un script. Dans ce dernier cas, la ligne prend la forme: | ||
+ | |||
+ | # IPTABLES --action CHAINE --option1 --option2 | ||
+ | |||
+ | Les actions sont: | ||
+ | |||
+ | ^ Action | ||
+ | | - -append | -A | Ajouter une règle à la fin de la chaîne spécifiée | | ||
+ | | - -delete | -D | Supprimer une règle en spécifiant son numéro ou la règle à supprimer | | ||
+ | | - -replace | -R | Permet de remplacer la règle spécifée par son numéro | | ||
+ | | - -insert | -I | Permet d' | ||
+ | | - -list | -L | Permet d' | ||
+ | | - -flush | -F | Permet de vider toutes les règles d'une chaîne | | ||
+ | |||
+ | Les options sont: | ||
+ | |||
+ | ^ Option | ||
+ | | - -protocol | -p | Permet de spécifier un protocol - tcp, udp, icmp, all | | ||
+ | | - -source | -s | Permet de spécifier une adresse source | | ||
+ | | - -destination | -d | Permet de spécifier une adresse de destination | | ||
+ | | - -in-interface | -i | Permet de spécifier une interface réseau d' | ||
+ | | - -out-interface | -o | Permet de spécifier une interface réseau de sortie | | ||
+ | | - -fragment | -f | Permet de ne spécifier que les paquets fragmentés | | ||
+ | | - -source-port | -sport | ||
+ | | - -destination-port | -dport | ||
+ | | - -tcp-flags | s/o | Permet de spécifier un flag TCP à matcher - SYN, ACK, FIN, RST, URG, PSH, ALL, NONE | | ||
+ | | - -icmp-type | s/o | Permet de spécifier un type de paquet ICMP | | ||
+ | | - -mac-source | s/o | Permet de spécifier une adresse MAC | | ||
+ | |||
+ | Les options spécifiques à NET sont: | ||
+ | |||
+ | | - -to-destination | s/o | Permet de spécifier l' | ||
+ | | - -to-source | s/o | Permet spécifier l' | ||
+ | |||
+ | Les options spécifiques aux LOGS sont: | ||
+ | |||
+ | | - -log-level | s/o | Permet de spécifier le niveau de logs | | ||
+ | | - -log-prefix | s/o | Permet de spécifier un préfix pour les logs | | ||
+ | |||
+ | L' | ||
+ | |||
+ | | - -state | s/o | Permet de spécifier l' | ||
+ | |||
+ | Ce dernier cas fait référence au STATEFUL. Le STATEFUL est la capacité du par-feu à enregistrer dans une table spécifique, | ||
+ | |||
+ | Il existe 4 états: | ||
+ | |||
+ | * NEW | ||
+ | * Le paquet concerne une nouvelle connexion et contient donc un flag SYN à 1 | ||
+ | * ESTABLISHED | ||
+ | * Le paquet concerne une connexion déjà établie. Le paquet ne doit contenir **ni** flag SYN à 1, **ni** flag FIN à 1 | ||
+ | * RELATED | ||
+ | * Le paquet est d'une connexion qui présente une relation avec une autre connexion | ||
+ | * INVALID | ||
+ | * La paquet provient d'une connexion anormale. | ||
+ | |||
+ | ====4.1 - La Configuration par firewalld ==== | ||
+ | |||
+ | 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 50%> | ||
+ | **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 | + | [root@redhat9 |
+ | ● firewalld.service - firewalld - dynamic firewall daemon | ||
+ | | ||
+ | | ||
+ | Docs: man: | ||
+ | Main PID: 795 (firewalld) | ||
+ | Tasks: 2 (limit: 48800) | ||
+ | | ||
+ | CPU: 510ms | ||
+ | | ||
+ | | ||
+ | |||
+ | Oct 22 11:02:01 redhat9.ittraining.loc systemd[1]: Starting firewalld - dynamic firewall daemon... | ||
+ | Oct 22 11:02:04 redhat9.ittraining.loc systemd[1]: Started firewalld - dynamic firewall daemon. | ||
</ | </ | ||
- | Constatez que la consultation ne génère plus de messages | + | ====4.2 - La Configuration |
+ | |||
+ | La configuration par défaut de firewalld se trouve dans **/ | ||
< | < | ||
- | [root@centos7 | + | [root@redhat9 ~]# ls -l / |
- | [root@centos7 | + | total 20 |
+ | drwxr-xr-x. 2 root root 4096 Sep 25 12:05 helpers | ||
+ | drwxr-xr-x. 2 root root 4096 Sep 25 12:05 icmptypes | ||
+ | drwxr-xr-x. 2 root root 23 Sep 25 12:05 ipsets | ||
+ | drwxr-xr-x. 2 root root 33 Sep 25 12:05 policies | ||
+ | drwxr-xr-x. 2 root root 8192 Sep 25 12:06 services | ||
+ | drwxr-xr-x. 2 root root 184 Sep 25 12:05 zones | ||
+ | |||
+ | [root@redhat9 ~]# ls -l / | ||
+ | total 40 | ||
+ | -rw-r--r--. 1 root root 312 Nov 6 2023 block.xml | ||
+ | -rw-r--r--. 1 root root 306 Nov 6 2023 dmz.xml | ||
+ | -rw-r--r--. 1 root root 304 Nov 6 2023 drop.xml | ||
+ | -rw-r--r--. 1 root root 317 Nov 6 2023 external.xml | ||
+ | -rw-r--r--. 1 root root 410 Nov 6 2023 home.xml | ||
+ | -rw-r--r--. 1 root root 425 Nov 6 2023 internal.xml | ||
+ | -rw-r--r--. 1 root root 729 Feb 22 2024 nm-shared.xml | ||
+ | -rw-r--r--. 1 root root 356 Nov 6 2023 public.xml | ||
+ | -rw-r--r--. 1 root root 175 Nov 6 2023 trusted.xml | ||
+ | -rw-r--r--. 1 root root 352 Nov 6 2023 work.xml | ||
+ | |||
+ | [root@redhat9 ~]# ls -l / | ||
+ | total 884 | ||
+ | -rw-r--r--. 1 root root 352 Nov 6 2023 afp.xml | ||
+ | -rw-r--r--. 1 root root 399 Nov 6 2023 amanda-client.xml | ||
+ | -rw-r--r--. 1 root root 427 Nov 6 2023 amanda-k5-client.xml | ||
+ | -rw-r--r--. 1 root root 283 Nov 6 2023 amqps.xml | ||
+ | -rw-r--r--. 1 root root 273 Nov 6 2023 amqp.xml | ||
+ | -rw-r--r--. 1 root root 285 Nov 6 2023 apcupsd.xml | ||
+ | -rw-r--r--. 1 root root 301 Nov 6 2023 audit.xml | ||
+ | -rw-r--r--. 1 root root 436 Nov 6 2023 ausweisapp2.xml | ||
+ | -rw-r--r--. 1 root root 320 Nov 6 2023 bacula-client.xml | ||
+ | -rw-r--r--. 1 root root 346 Nov 6 2023 bacula.xml | ||
+ | -rw-r--r--. 1 root root 390 Nov 6 2023 bareos-director.xml | ||
+ | -rw-r--r--. 1 root root 255 Nov 6 2023 bareos-filedaemon.xml | ||
+ | -rw-r--r--. 1 root root 316 Nov 6 2023 bareos-storage.xml | ||
+ | -rw-r--r--. 1 root root 429 Nov 6 2023 bb.xml | ||
+ | -rw-r--r--. 1 root root 339 Nov 6 2023 bgp.xml | ||
+ | -rw-r--r--. 1 root root 275 Nov 6 2023 bitcoin-rpc.xml | ||
+ | -rw-r--r--. 1 root root 307 Nov 6 2023 bitcoin-testnet-rpc.xml | ||
+ | -rw-r--r--. 1 root root 281 Nov 6 2023 bitcoin-testnet.xml | ||
+ | -rw-r--r--. 1 root root 244 Nov 6 2023 bitcoin.xml | ||
+ | -rw-r--r--. 1 root root 410 Nov 6 2023 bittorrent-lsd.xml | ||
+ | -rw-r--r--. 1 root root 222 Nov 6 2023 ceph-exporter.xml | ||
+ | -rw-r--r--. 1 root root 294 Nov 6 2023 ceph-mon.xml | ||
+ | -rw-r--r--. 1 root root 329 Nov 6 2023 ceph.xml | ||
+ | -rw-r--r--. 1 root root 168 Nov 6 2023 cfengine.xml | ||
+ | -rw-r--r--. 1 root root 234 Nov 6 2023 checkmk-agent.xml | ||
+ | -rw-r--r--. 1 root root 211 Nov 6 2023 cockpit.xml | ||
+ | -rw-r--r--. 1 root root 296 Nov 6 2023 collectd.xml | ||
+ | -rw-r--r--. 1 root root 260 Nov 6 2023 condor-collector.xml | ||
+ | -rw-r--r--. 1 root root 343 Nov 6 2023 cratedb.xml | ||
+ | -rw-r--r--. 1 root root 296 Nov 6 2023 ctdb.xml | ||
+ | -rw-r--r--. 1 root root 981 Nov 6 2023 dds-multicast.xml | ||
+ | -rw-r--r--. 1 root root 947 Nov 6 2023 dds-unicast.xml | ||
+ | -rw-r--r--. 1 root root 574 Nov 6 2023 dds.xml | ||
+ | -rw-r--r--. 1 root root 305 Nov 6 2023 dhcpv6-client.xml | ||
+ | -rw-r--r--. 1 root root 234 Nov 6 2023 dhcpv6.xml | ||
+ | -rw-r--r--. 1 root root 227 Nov 6 2023 dhcp.xml | ||
+ | -rw-r--r--. 1 root root 205 Nov 6 2023 distcc.xml | ||
+ | -rw-r--r--. 1 root root 318 Nov 6 2023 dns-over-tls.xml | ||
+ | -rw-r--r--. 1 root root 346 Nov 6 2023 dns.xml | ||
+ | -rw-r--r--. 1 root root 374 Nov 6 2023 docker-registry.xml | ||
+ | -rw-r--r--. 1 root root 391 Nov 6 2023 docker-swarm.xml | ||
+ | -rw-r--r--. 1 root root 228 Nov 6 2023 dropbox-lansync.xml | ||
+ | -rw-r--r--. 1 root root 338 Nov 6 2023 elasticsearch.xml | ||
+ | -rw-r--r--. 1 root root 304 Nov 6 2023 etcd-client.xml | ||
+ | -rw-r--r--. 1 root root 304 Nov 6 2023 etcd-server.xml | ||
+ | -rw-r--r--. 1 root root 224 Nov 6 2023 finger.xml | ||
+ | -rw-r--r--. 1 root root 270 Nov 6 2023 foreman-proxy.xml | ||
+ | -rw-r--r--. 1 root root 408 Nov 6 2023 foreman.xml | ||
+ | -rw-r--r--. 1 root root 709 Nov 6 2023 freeipa-4.xml | ||
+ | -rw-r--r--. 1 root root 489 Nov 6 2023 freeipa-ldaps.xml | ||
+ | -rw-r--r--. 1 root root 488 Nov 6 2023 freeipa-ldap.xml | ||
+ | -rw-r--r--. 1 root root 242 Nov 6 2023 freeipa-replication.xml | ||
+ | -rw-r--r--. 1 root root 657 Nov 6 2023 freeipa-trust.xml | ||
+ | -rw-r--r--. 1 root root 361 Nov 6 2023 ftp.xml | ||
+ | -rw-r--r--. 1 root root 292 Nov 6 2023 galera.xml | ||
+ | -rw-r--r--. 1 root root 184 Nov 6 2023 ganglia-client.xml | ||
+ | -rw-r--r--. 1 root root 176 Nov 6 2023 ganglia-master.xml | ||
+ | -rw-r--r--. 1 root root 212 Nov 6 2023 git.xml | ||
+ | -rw-r--r--. 1 root root 406 Nov 6 2023 gpsd.xml | ||
+ | -rw-r--r--. 1 root root 218 Nov 6 2023 grafana.xml | ||
+ | -rw-r--r--. 1 root root 119 Nov 6 2023 gre.xml | ||
+ | -rw-r--r--. 1 root root 608 Nov 6 2023 high-availability.xml | ||
+ | -rw-r--r--. 1 root root 336 Nov 6 2023 http3.xml | ||
+ | -rw-r--r--. 1 root root 448 Nov 6 2023 https.xml | ||
+ | -rw-r--r--. 1 root root 353 Nov 6 2023 http.xml | ||
+ | -rw-r--r--. 1 root root 293 Nov 6 2023 ident.xml | ||
+ | -rw-r--r--. 1 root root 372 Nov 6 2023 imaps.xml | ||
+ | -rw-r--r--. 1 root root 327 Nov 6 2023 imap.xml | ||
+ | -rw-r--r--. 1 root root 315 Nov 6 2023 ipfs.xml | ||
+ | -rw-r--r--. 1 root root 454 Nov 6 2023 ipp-client.xml | ||
+ | -rw-r--r--. 1 root root 427 Nov 6 2023 ipp.xml | ||
+ | -rw-r--r--. 1 root root 895 Nov 6 2023 ipsec.xml | ||
+ | -rw-r--r--. 1 root root 255 Nov 6 2023 ircs.xml | ||
+ | -rw-r--r--. 1 root root 247 Nov 6 2023 irc.xml | ||
+ | -rw-r--r--. 1 root root 264 Nov 6 2023 iscsi-target.xml | ||
+ | -rw-r--r--. 1 root root 358 Nov 6 2023 isns.xml | ||
+ | -rw-r--r--. 1 root root 213 Nov 6 2023 jenkins.xml | ||
+ | -rw-r--r--. 1 root root 182 Nov 6 2023 kadmin.xml | ||
+ | -rw-r--r--. 1 root root 272 Nov 6 2023 kdeconnect.xml | ||
+ | -rw-r--r--. 1 root root 233 Nov 6 2023 kerberos.xml | ||
+ | -rw-r--r--. 1 root root 384 Nov 6 2023 kibana.xml | ||
+ | -rw-r--r--. 1 root root 249 Nov 6 2023 klogin.xml | ||
+ | -rw-r--r--. 1 root root 221 Nov 6 2023 kpasswd.xml | ||
+ | -rw-r--r--. 1 root root 182 Nov 6 2023 kprop.xml | ||
+ | -rw-r--r--. 1 root root 242 Nov 6 2023 kshell.xml | ||
+ | -rw-r--r--. 1 root root 308 Nov 6 2023 kube-apiserver.xml | ||
+ | -rw-r--r--. 1 root root 204 Nov 6 2023 kube-api.xml | ||
+ | -rw-r--r--. 1 root root 289 Nov 6 2023 kube-controller-manager-secure.xml | ||
+ | -rw-r--r--. 1 root root 280 Nov 6 2023 kube-controller-manager.xml | ||
+ | -rw-r--r--. 1 root root 560 Nov 6 2023 kube-control-plane-secure.xml | ||
+ | -rw-r--r--. 1 root root 537 Nov 6 2023 kube-control-plane.xml | ||
+ | -rw-r--r--. 1 root root 244 Nov 6 2023 kubelet-readonly.xml | ||
+ | -rw-r--r--. 1 root root 212 Nov 6 2023 kubelet-worker.xml | ||
+ | -rw-r--r--. 1 root root 239 Nov 6 2023 kubelet.xml | ||
+ | -rw-r--r--. 1 root root 224 Nov 6 2023 kube-nodeport-services.xml | ||
+ | -rw-r--r--. 1 root root 328 Nov 6 2023 kube-scheduler-secure.xml | ||
+ | -rw-r--r--. 1 root root 319 Nov 6 2023 kube-scheduler.xml | ||
+ | -rw-r--r--. 1 root root 374 Nov 6 2023 kube-worker.xml | ||
+ | -rw-r--r--. 1 root root 232 Nov 6 2023 ldaps.xml | ||
+ | -rw-r--r--. 1 root root 199 Nov 6 2023 ldap.xml | ||
+ | -rw-r--r--. 1 root root 385 Nov 6 2023 libvirt-tls.xml | ||
+ | -rw-r--r--. 1 root root 389 Nov 6 2023 libvirt.xml | ||
+ | -rw-r--r--. 1 root root 269 Nov 6 2023 lightning-network.xml | ||
+ | -rw-r--r--. 1 root root 468 Nov 6 2023 llmnr-client.xml | ||
+ | -rw-r--r--. 1 root root 410 Nov 6 2023 llmnr-tcp.xml | ||
+ | -rw-r--r--. 1 root root 463 Nov 6 2023 llmnr-udp.xml | ||
+ | -rw-r--r--. 1 root root 519 Nov 6 2023 llmnr.xml | ||
+ | -rw-r--r--. 1 root root 349 Nov 6 2023 managesieve.xml | ||
+ | -rw-r--r--. 1 root root 432 Nov 6 2023 matrix.xml | ||
+ | -rw-r--r--. 1 root root 424 Nov 6 2023 mdns.xml | ||
+ | -rw-r--r--. 1 root root 245 Nov 6 2023 memcache.xml | ||
+ | -rw-r--r--. 1 root root 334 Nov 6 2023 minidlna.xml | ||
+ | -rw-r--r--. 1 root root 237 Nov 6 2023 mongodb.xml | ||
+ | -rw-r--r--. 1 root root 473 Nov 6 2023 mosh.xml | ||
+ | -rw-r--r--. 1 root root 211 Nov 6 2023 mountd.xml | ||
+ | -rw-r--r--. 1 root root 296 Nov 6 2023 mqtt-tls.xml | ||
+ | -rw-r--r--. 1 root root 287 Nov 6 2023 mqtt.xml | ||
+ | -rw-r--r--. 1 root root 170 Nov 6 2023 mssql.xml | ||
+ | -rw-r--r--. 1 root root 180 Nov 6 2023 ms-wbt.xml | ||
+ | -rw-r--r--. 1 root root 242 Nov 6 2023 murmur.xml | ||
+ | -rw-r--r--. 1 root root 171 Nov 6 2023 mysql.xml | ||
+ | -rw-r--r--. 1 root root 250 Nov 6 2023 nbd.xml | ||
+ | -rw-r--r--. 1 root root 309 Nov 6 2023 nebula.xml | ||
+ | -rw-r--r--. 1 root root 262 Nov 6 2023 netbios-ns.xml | ||
+ | -rw-r--r--. 1 root root 243 Nov 6 2023 netdata-dashboard.xml | ||
+ | -rw-r--r--. 1 root root 342 Nov 6 2023 nfs3.xml | ||
+ | -rw-r--r--. 1 root root 324 Nov 6 2023 nfs.xml | ||
+ | -rw-r--r--. 1 root root 293 Nov 6 2023 nmea-0183.xml | ||
+ | -rw-r--r--. 1 root root 247 Nov 6 2023 nrpe.xml | ||
+ | -rw-r--r--. 1 root root 389 Nov 6 2023 ntp.xml | ||
+ | -rw-r--r--. 1 root root 368 Nov 6 2023 nut.xml | ||
+ | -rw-r--r--. 1 root root 335 Nov 6 2023 openvpn.xml | ||
+ | -rw-r--r--. 1 root root 260 Nov 6 2023 ovirt-imageio.xml | ||
+ | -rw-r--r--. 1 root root 343 Nov 6 2023 ovirt-storageconsole.xml | ||
+ | -rw-r--r--. 1 root root 235 Nov 6 2023 ovirt-vmconsole.xml | ||
+ | -rw-r--r--. 1 root root 869 Nov 6 2023 plex.xml | ||
+ | -rw-r--r--. 1 root root 433 Nov 6 2023 pmcd.xml | ||
+ | -rw-r--r--. 1 root root 474 Nov 6 2023 pmproxy.xml | ||
+ | -rw-r--r--. 1 root root 544 Nov 6 2023 pmwebapis.xml | ||
+ | -rw-r--r--. 1 root root 460 Nov 6 2023 pmwebapi.xml | ||
+ | -rw-r--r--. 1 root root 357 Nov 6 2023 pop3s.xml | ||
+ | -rw-r--r--. 1 root root 348 Nov 6 2023 pop3.xml | ||
+ | -rw-r--r--. 1 root root 181 Nov 6 2023 postgresql.xml | ||
+ | -rw-r--r--. 1 root root 509 Nov 6 2023 privoxy.xml | ||
+ | -rw-r--r--. 1 root root 226 Nov 6 2023 prometheus-node-exporter.xml | ||
+ | -rw-r--r--. 1 root root 213 Nov 6 2023 prometheus.xml | ||
+ | -rw-r--r--. 1 root root 261 Nov 6 2023 proxy-dhcp.xml | ||
+ | -rw-r--r--. 1 root root 262 Nov 6 2023 ps2link.xml | ||
+ | -rw-r--r--. 1 root root 173 Nov 6 2023 ps3netsrv.xml | ||
+ | -rw-r--r--. 1 root root 424 Nov 6 2023 ptp.xml | ||
+ | -rw-r--r--. 1 root root 414 Nov 6 2023 pulseaudio.xml | ||
+ | -rw-r--r--. 1 root root 297 Nov 6 2023 puppetmaster.xml | ||
+ | -rw-r--r--. 1 root root 273 Nov 6 2023 quassel.xml | ||
+ | -rw-r--r--. 1 root root 520 Nov 6 2023 radius.xml | ||
+ | -rw-r--r--. 1 root root 183 Nov 6 2023 rdp.xml | ||
+ | -rw-r--r--. 1 root root 212 Nov 6 2023 redis-sentinel.xml | ||
+ | -rw-r--r--. 1 root root 268 Nov 6 2023 redis.xml | ||
+ | -rw-r--r--. 1 root root 381 Nov 6 2023 RH-Satellite-6-capsule.xml | ||
+ | -rw-r--r--. 1 root root 556 Nov 6 2023 RH-Satellite-6.xml | ||
+ | -rw-r--r--. 1 root root 214 Nov 6 2023 rpc-bind.xml | ||
+ | -rw-r--r--. 1 root root 213 Nov 6 2023 rquotad.xml | ||
+ | -rw-r--r--. 1 root root 310 Nov 6 2023 rsh.xml | ||
+ | -rw-r--r--. 1 root root 311 Nov 6 2023 rsyncd.xml | ||
+ | -rw-r--r--. 1 root root 350 Nov 6 2023 rtsp.xml | ||
+ | -rw-r--r--. 1 root root 329 Nov 6 2023 salt-master.xml | ||
+ | -rw-r--r--. 1 root root 339 Nov 6 2023 samba-client.xml | ||
+ | -rw-r--r--. 1 root root 782 Nov 6 2023 samba-dc.xml | ||
+ | -rw-r--r--. 1 root root 382 Nov 6 2023 samba.xml | ||
+ | -rw-r--r--. 1 root root 324 Nov 6 2023 sane.xml | ||
+ | -rw-r--r--. 1 root root 283 Nov 6 2023 sips.xml | ||
+ | -rw-r--r--. 1 root root 496 Nov 6 2023 sip.xml | ||
+ | -rw-r--r--. 1 root root 299 Nov 6 2023 slp.xml | ||
+ | -rw-r--r--. 1 root root 231 Nov 6 2023 smtp-submission.xml | ||
+ | -rw-r--r--. 1 root root 577 Nov 6 2023 smtps.xml | ||
+ | -rw-r--r--. 1 root root 550 Nov 6 2023 smtp.xml | ||
+ | -rw-r--r--. 1 root root 359 Nov 6 2023 snmptls-trap.xml | ||
+ | -rw-r--r--. 1 root root 390 Nov 6 2023 snmptls.xml | ||
+ | -rw-r--r--. 1 root root 308 Nov 6 2023 snmptrap.xml | ||
+ | -rw-r--r--. 1 root root 342 Nov 6 2023 snmp.xml | ||
+ | -rw-r--r--. 1 root root 405 Nov 6 2023 spideroak-lansync.xml | ||
+ | -rw-r--r--. 1 root root 275 Nov 6 2023 spotify-sync.xml | ||
+ | -rw-r--r--. 1 root root 173 Nov 6 2023 squid.xml | ||
+ | -rw-r--r--. 1 root root 421 Nov 6 2023 ssdp.xml | ||
+ | -rw-r--r--. 1 root root 463 Nov 6 2023 ssh.xml | ||
+ | -rw-r--r--. 1 root root 631 Nov 6 2023 steam-streaming.xml | ||
+ | -rw-r--r--. 1 root root 287 Nov 6 2023 svdrp.xml | ||
+ | -rw-r--r--. 1 root root 231 Nov 6 2023 svn.xml | ||
+ | -rw-r--r--. 1 root root 297 Nov 6 2023 syncthing-gui.xml | ||
+ | -rw-r--r--. 1 root root 414 Nov 6 2023 syncthing-relay.xml | ||
+ | -rw-r--r--. 1 root root 350 Nov 6 2023 syncthing.xml | ||
+ | -rw-r--r--. 1 root root 496 Nov 6 2023 synergy.xml | ||
+ | -rw-r--r--. 1 root root 444 Nov 6 2023 syslog-tls.xml | ||
+ | -rw-r--r--. 1 root root 329 Nov 6 2023 syslog.xml | ||
+ | -rw-r--r--. 1 root root 393 Nov 6 2023 telnet.xml | ||
+ | -rw-r--r--. 1 root root 252 Nov 6 2023 tentacle.xml | ||
+ | -rw-r--r--. 1 root root 424 Nov 6 2023 tftp.xml | ||
+ | -rw-r--r--. 1 root root 221 Nov 6 2023 tile38.xml | ||
+ | -rw-r--r--. 1 root root 336 Nov 6 2023 tinc.xml | ||
+ | -rw-r--r--. 1 root root 771 Nov 6 2023 tor-socks.xml | ||
+ | -rw-r--r--. 1 root root 244 Nov 6 2023 transmission-client.xml | ||
+ | -rw-r--r--. 1 root root 264 Nov 6 2023 upnp-client.xml | ||
+ | -rw-r--r--. 1 root root 593 Nov 6 2023 vdsm.xml | ||
+ | -rw-r--r--. 1 root root 475 Nov 6 2023 vnc-server.xml | ||
+ | -rw-r--r--. 1 root root 443 Nov 6 2023 warpinator.xml | ||
+ | -rw-r--r--. 1 root root 310 Nov 6 2023 wbem-https.xml | ||
+ | -rw-r--r--. 1 root root 352 Nov 6 2023 wbem-http.xml | ||
+ | -rw-r--r--. 1 root root 285 Nov 6 2023 wireguard.xml | ||
+ | -rw-r--r--. 1 root root 355 Nov 6 2023 ws-discovery-client.xml | ||
+ | -rw-r--r--. 1 root root 320 Nov 6 2023 ws-discovery-tcp.xml | ||
+ | -rw-r--r--. 1 root root 375 Nov 6 2023 ws-discovery-udp.xml | ||
+ | -rw-r--r--. 1 root root 357 Nov 6 2023 ws-discovery.xml | ||
+ | -rw-r--r--. 1 root root 323 Nov 6 2023 wsmans.xml | ||
+ | -rw-r--r--. 1 root root 316 Nov 6 2023 wsman.xml | ||
+ | -rw-r--r--. 1 root root 329 Nov 6 2023 xdmcp.xml | ||
+ | -rw-r--r--. 1 root root 509 Nov 6 2023 xmpp-bosh.xml | ||
+ | -rw-r--r--. 1 root root 488 Nov 6 2023 xmpp-client.xml | ||
+ | -rw-r--r--. 1 root root 264 Nov 6 2023 xmpp-local.xml | ||
+ | -rw-r--r--. 1 root root 545 Nov 6 2023 xmpp-server.xml | ||
+ | -rw-r--r--. 1 root root 314 Nov 6 2023 zabbix-agent.xml | ||
+ | -rw-r--r--. 1 root root 315 Nov 6 2023 zabbix-server.xml | ||
+ | -rw-r--r--. 1 root root 242 Nov 6 2023 zerotier.xml | ||
+ | |||
+ | [root@redhat9 ~]# ls -l / | ||
+ | total 180 | ||
+ | -rw-r--r--. 1 root root 385 Nov 6 2023 address-unreachable.xml | ||
+ | -rw-r--r--. 1 root root 258 Nov 6 2023 bad-header.xml | ||
+ | -rw-r--r--. 1 root root 293 Nov 6 2023 beyond-scope.xml | ||
+ | -rw-r--r--. 1 root root 279 Nov 6 2023 communication-prohibited.xml | ||
+ | -rw-r--r--. 1 root root 222 Nov 6 2023 destination-unreachable.xml | ||
+ | -rw-r--r--. 1 root root 173 Nov 6 2023 echo-reply.xml | ||
+ | -rw-r--r--. 1 root root 210 Nov 6 2023 echo-request.xml | ||
+ | -rw-r--r--. 1 root root 261 Nov 6 2023 failed-policy.xml | ||
+ | -rw-r--r--. 1 root root 280 Nov 6 2023 fragmentation-needed.xml | ||
+ | -rw-r--r--. 1 root root 266 Nov 6 2023 host-precedence-violation.xml | ||
+ | -rw-r--r--. 1 root root 257 Nov 6 2023 host-prohibited.xml | ||
+ | -rw-r--r--. 1 root root 242 Nov 6 2023 host-redirect.xml | ||
+ | -rw-r--r--. 1 root root 239 Nov 6 2023 host-unknown.xml | ||
+ | -rw-r--r--. 1 root root 247 Nov 6 2023 host-unreachable.xml | ||
+ | -rw-r--r--. 1 root root 229 Nov 6 2023 ip-header-bad.xml | ||
+ | -rw-r--r--. 1 root root 355 Nov 6 2023 neighbour-advertisement.xml | ||
+ | -rw-r--r--. 1 root root 457 Nov 6 2023 neighbour-solicitation.xml | ||
+ | -rw-r--r--. 1 root root 250 Nov 6 2023 network-prohibited.xml | ||
+ | -rw-r--r--. 1 root root 248 Nov 6 2023 network-redirect.xml | ||
+ | -rw-r--r--. 1 root root 239 Nov 6 2023 network-unknown.xml | ||
+ | -rw-r--r--. 1 root root 247 Nov 6 2023 network-unreachable.xml | ||
+ | -rw-r--r--. 1 root root 239 Nov 6 2023 no-route.xml | ||
+ | -rw-r--r--. 1 root root 328 Nov 6 2023 packet-too-big.xml | ||
+ | -rw-r--r--. 1 root root 225 Nov 6 2023 parameter-problem.xml | ||
+ | -rw-r--r--. 1 root root 233 Nov 6 2023 port-unreachable.xml | ||
+ | -rw-r--r--. 1 root root 256 Nov 6 2023 precedence-cutoff.xml | ||
+ | -rw-r--r--. 1 root root 249 Nov 6 2023 protocol-unreachable.xml | ||
+ | -rw-r--r--. 1 root root 185 Nov 6 2023 redirect.xml | ||
+ | -rw-r--r--. 1 root root 244 Nov 6 2023 reject-route.xml | ||
+ | -rw-r--r--. 1 root root 241 Nov 6 2023 required-option-missing.xml | ||
+ | -rw-r--r--. 1 root root 227 Nov 6 2023 router-advertisement.xml | ||
+ | -rw-r--r--. 1 root root 223 Nov 6 2023 router-solicitation.xml | ||
+ | -rw-r--r--. 1 root root 248 Nov 6 2023 source-quench.xml | ||
+ | -rw-r--r--. 1 root root 236 Nov 6 2023 source-route-failed.xml | ||
+ | -rw-r--r--. 1 root root 253 Nov 6 2023 time-exceeded.xml | ||
+ | -rw-r--r--. 1 root root 233 Nov 6 2023 timestamp-reply.xml | ||
+ | -rw-r--r--. 1 root root 228 Nov 6 2023 timestamp-request.xml | ||
+ | -rw-r--r--. 1 root root 258 Nov 6 2023 tos-host-redirect.xml | ||
+ | -rw-r--r--. 1 root root 257 Nov 6 2023 tos-host-unreachable.xml | ||
+ | -rw-r--r--. 1 root root 272 Nov 6 2023 tos-network-redirect.xml | ||
+ | -rw-r--r--. 1 root root 269 Nov 6 2023 tos-network-unreachable.xml | ||
+ | -rw-r--r--. 1 root root 293 Nov 6 2023 ttl-zero-during-reassembly.xml | ||
+ | -rw-r--r--. 1 root root 256 Nov 6 2023 ttl-zero-during-transit.xml | ||
+ | -rw-r--r--. 1 root root 259 Nov 6 2023 unknown-header-type.xml | ||
+ | -rw-r--r--. 1 root root 249 Nov 6 2023 unknown-option.xml | ||
+ | </ | ||
+ | |||
+ | Ces fichiers sont au format **xml**, par exemple : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 | ||
+ | <?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@redhat9 ~]# ls -l / | ||
+ | total 8 | ||
+ | -rw-r--r--. 1 root root 2483 Nov 6 2023 firewalld.conf | ||
+ | drwxr-x---. 2 root root 6 Nov 6 2023 helpers | ||
+ | drwxr-x---. 2 root root 6 Nov 6 2023 icmptypes | ||
+ | drwxr-x---. 2 root root 6 Nov 6 2023 ipsets | ||
+ | -rw-r--r--. 1 root root 271 Nov 6 2023 lockdown-whitelist.xml | ||
+ | drwxr-x---. 2 root root 6 Nov 6 2023 policies | ||
+ | drwxr-x---. 2 root root 6 Nov 6 2023 services | ||
+ | drwxr-x---. 2 root root 46 Nov 6 2023 zones | ||
+ | |||
+ | [root@redhat9 ~]# ls -l / | ||
+ | total 8 | ||
+ | -rw-r--r--. 1 root root 356 Oct 19 2023 public.xml | ||
+ | -rw-r--r--. 1 root root 356 Oct 19 2023 public.xml.old | ||
+ | |||
+ | [root@redhat9 ~]# ls -l / | ||
+ | total 0 | ||
+ | |||
+ | [root@redhat9 ~]# ls -l / | ||
+ | total 0 | ||
+ | </ | ||
+ | |||
+ | Le fichier de configuration de firewalld est **/ | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# cat / | ||
+ | # firewalld config file | ||
+ | |||
+ | # default zone | ||
+ | # The default zone used if an empty zone string is used. | ||
+ | # Default: public | ||
+ | DefaultZone=public | ||
+ | |||
+ | # Clean up on exit | ||
+ | # If set to no or false the firewall configuration will not get cleaned up | ||
+ | # on exit or stop of firewalld. | ||
+ | # Default: yes | ||
+ | CleanupOnExit=yes | ||
+ | |||
+ | # Clean up kernel modules on exit | ||
+ | # If set to yes or true the firewall related kernel modules will be | ||
+ | # unloaded on exit or stop of firewalld. This might attempt to unload | ||
+ | # modules not originally loaded by firewalld. | ||
+ | # Default: no | ||
+ | CleanupModulesOnExit=no | ||
+ | |||
+ | # 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. | ||
+ | # Note: This feature has a performance impact. See man page FIREWALLD.CONF(5) | ||
+ | # for details. | ||
+ | # Default: yes | ||
+ | IPv6_rpfilter=yes | ||
+ | |||
+ | # IndividualCalls | ||
+ | # Do not use combined -restore calls, but individual calls. This increases the | ||
+ | # time that is needed to apply changes and to start the daemon, but is good for | ||
+ | # debugging. | ||
+ | # Default: no | ||
+ | IndividualCalls=no | ||
+ | |||
+ | # LogDenied | ||
+ | # Add logging rules right before reject and drop rules in the INPUT, FORWARD | ||
+ | # and OUTPUT chains for the default rules and also final reject and drop rules | ||
+ | # in zones. Possible values are: all, unicast, broadcast, multicast and off. | ||
+ | # Default: off | ||
+ | LogDenied=off | ||
+ | |||
+ | # FirewallBackend | ||
+ | # Selects the firewall backend implementation. | ||
+ | # Choices are: | ||
+ | # - nftables (default) | ||
+ | # - iptables (iptables, ip6tables, ebtables and ipset) | ||
+ | # Note: The iptables backend is deprecated. It will be removed in a future | ||
+ | # release. | ||
+ | FirewallBackend=nftables | ||
+ | |||
+ | # FlushAllOnReload | ||
+ | # Flush all runtime rules on a reload. In previous releases some runtime | ||
+ | # configuration was retained during a reload, namely; interface to zone | ||
+ | # assignment, and direct rules. This was confusing to users. To get the old | ||
+ | # behavior set this to " | ||
+ | # Default: yes | ||
+ | FlushAllOnReload=yes | ||
+ | |||
+ | # RFC3964_IPv4 | ||
+ | # As per RFC 3964, filter IPv6 traffic with 6to4 destination addresses that | ||
+ | # correspond to IPv4 addresses that should not be routed over the public | ||
+ | # internet. | ||
+ | # Defaults to " | ||
+ | RFC3964_IPv4=yes | ||
+ | </ | ||
+ | |||
+ | ====4.3 - La Commande firewall-cmd==== | ||
+ | |||
+ | firewalld s' | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **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. | ||
+ | </ | ||
+ | |||
+ | Pour obtenir la liste de toutes les zones prédéfinies, | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --get-zones | ||
+ | block dmz drop external home internal nm-shared public trusted work | ||
+ | </ | ||
+ | |||
+ | Pour obtenir la liste de toutes les services prédéfinis, | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --get-services | ||
+ | RH-Satellite-6 RH-Satellite-6-capsule afp amanda-client amanda-k5-client amqp amqps apcupsd | ||
+ | </code> | ||
+ | |||
+ | Pour obtenir la liste de toutes les types ICMP prédéfinis, | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --get-icmptypes | ||
+ | address-unreachable bad-header beyond-scope communication-prohibited destination-unreachable echo-reply echo-request failed-policy fragmentation-needed host-precedence-violation host-prohibited host-redirect host-unknown host-unreachable ip-header-bad neighbour-advertisement neighbour-solicitation network-prohibited network-redirect network-unknown network-unreachable no-route packet-too-big parameter-problem port-unreachable precedence-cutoff protocol-unreachable redirect reject-route required-option-missing router-advertisement router-solicitation source-quench source-route-failed time-exceeded timestamp-reply timestamp-request tos-host-redirect tos-host-unreachable tos-network-redirect tos-network-unreachable ttl-zero-during-reassembly ttl-zero-during-transit unknown-header-type unknown-option | ||
+ | </ | ||
+ | |||
+ | Pour obtenir la liste des zones de la configuration courante, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --get-active-zones | ||
+ | public | ||
+ | interfaces: ens18 | ||
+ | </ | ||
+ | |||
+ | Pour obtenir la liste des zones de la configuration courante pour une interface spécifique, | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --get-zone-of-interface=ens18 | ||
+ | public | ||
+ | </ | ||
+ | |||
+ | Pour obtenir la liste des services autorisés pour la zone public, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --zone=public --list-services | ||
+ | cockpit dhcpv6-client ssh | ||
+ | </ | ||
+ | |||
+ | Pour obtenir toute la configuration pour la zone public, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --zone=public --list-all | ||
+ | public (active) | ||
+ | target: default | ||
+ | icmp-block-inversion: | ||
+ | interfaces: ens18 | ||
+ | sources: | ||
+ | services: cockpit dhcpv6-client ssh | ||
+ | ports: | ||
+ | protocols: | ||
+ | forward: yes | ||
+ | masquerade: no | ||
+ | forward-ports: | ||
+ | source-ports: | ||
+ | icmp-blocks: | ||
+ | rich rules: | ||
+ | </ | ||
+ | |||
+ | Pour obtenir la liste complète de toutes les zones et leurs configurations, | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --list-all-zones | ||
+ | block | ||
+ | target: %%REJECT%% | ||
+ | icmp-block-inversion: | ||
+ | interfaces: | ||
+ | sources: | ||
+ | services: | ||
+ | ports: | ||
+ | protocols: | ||
+ | forward: yes | ||
+ | masquerade: no | ||
+ | forward-ports: | ||
+ | source-ports: | ||
+ | icmp-blocks: | ||
+ | rich rules: | ||
+ | |||
+ | dmz | ||
+ | target: default | ||
+ | icmp-block-inversion: | ||
+ | interfaces: | ||
+ | sources: | ||
+ | services: ssh | ||
+ | ports: | ||
+ | protocols: | ||
+ | forward: yes | ||
+ | masquerade: no | ||
+ | forward-ports: | ||
+ | source-ports: | ||
+ | icmp-blocks: | ||
+ | rich rules: | ||
+ | |||
+ | drop | ||
+ | target: DROP | ||
+ | icmp-block-inversion: | ||
+ | interfaces: | ||
+ | sources: | ||
+ | services: | ||
+ | ports: | ||
+ | protocols: | ||
+ | forward: yes | ||
+ | masquerade: no | ||
+ | forward-ports: | ||
+ | source-ports: | ||
+ | icmp-blocks: | ||
+ | rich rules: | ||
+ | |||
+ | external | ||
+ | target: default | ||
+ | icmp-block-inversion: | ||
+ | interfaces: | ||
+ | sources: | ||
+ | services: ssh | ||
+ | ports: | ||
+ | protocols: | ||
+ | forward: yes | ||
+ | masquerade: yes | ||
+ | forward-ports: | ||
+ | source-ports: | ||
+ | icmp-blocks: | ||
+ | rich rules: | ||
+ | |||
+ | home | ||
+ | target: default | ||
+ | icmp-block-inversion: | ||
+ | interfaces: | ||
+ | sources: | ||
+ | services: cockpit dhcpv6-client mdns samba-client ssh | ||
+ | ports: | ||
+ | protocols: | ||
+ | forward: yes | ||
+ | masquerade: no | ||
+ | forward-ports: | ||
+ | source-ports: | ||
+ | icmp-blocks: | ||
+ | rich rules: | ||
+ | |||
+ | internal | ||
+ | target: default | ||
+ | icmp-block-inversion: | ||
+ | interfaces: | ||
+ | sources: | ||
+ | services: cockpit dhcpv6-client mdns samba-client ssh | ||
+ | ports: | ||
+ | protocols: | ||
+ | forward: yes | ||
+ | masquerade: no | ||
+ | forward-ports: | ||
+ | source-ports: | ||
+ | icmp-blocks: | ||
+ | rich rules: | ||
+ | |||
+ | nm-shared | ||
+ | target: ACCEPT | ||
+ | icmp-block-inversion: | ||
+ | interfaces: | ||
+ | sources: | ||
+ | services: dhcp dns ssh | ||
+ | ports: | ||
+ | protocols: icmp ipv6-icmp | ||
+ | forward: no | ||
+ | masquerade: no | ||
+ | forward-ports: | ||
+ | source-ports: | ||
+ | icmp-blocks: | ||
+ | rich rules: | ||
+ | rule priority=" | ||
+ | |||
+ | public (active) | ||
+ | target: default | ||
+ | icmp-block-inversion: | ||
+ | interfaces: ens18 | ||
+ | sources: | ||
+ | services: cockpit dhcpv6-client ssh | ||
+ | ports: | ||
+ | protocols: | ||
+ | forward: yes | ||
+ | masquerade: no | ||
+ | forward-ports: | ||
+ | source-ports: | ||
+ | icmp-blocks: | ||
+ | rich rules: | ||
+ | |||
+ | trusted | ||
+ | target: ACCEPT | ||
+ | icmp-block-inversion: | ||
+ | interfaces: | ||
+ | sources: | ||
+ | services: | ||
+ | ports: | ||
+ | protocols: | ||
+ | forward: yes | ||
+ | masquerade: no | ||
+ | forward-ports: | ||
+ | source-ports: | ||
+ | icmp-blocks: | ||
+ | rich rules: | ||
+ | |||
+ | work | ||
+ | target: default | ||
+ | icmp-block-inversion: | ||
+ | interfaces: | ||
+ | sources: | ||
+ | services: cockpit dhcpv6-client ssh | ||
+ | ports: | ||
+ | protocols: | ||
+ | forward: yes | ||
+ | masquerade: no | ||
+ | forward-ports: | ||
+ | source-ports: | ||
+ | icmp-blocks: | ||
+ | rich rules: | ||
+ | </ | ||
+ | |||
+ | Pour changer la zone par défaut de public à work, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --set-default-zone=work | ||
+ | success | ||
+ | |||
+ | [root@redhat9 ~]# firewall-cmd --get-active-zones | ||
+ | work | ||
+ | interfaces: ens18 | ||
+ | </ | ||
+ | |||
+ | Pour ajouter l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --zone=work --add-interface=ip_fixe | ||
+ | success | ||
+ | |||
+ | [root@redhat9 ~]# firewall-cmd --get-active-zones | ||
+ | work | ||
+ | interfaces: ens18 ip_fixe | ||
+ | </ | ||
+ | |||
+ | Pour supprimer l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --zone=work --remove-interface=ip_fixe | ||
+ | success | ||
+ | |||
+ | [root@redhat9 ~]# firewall-cmd --get-active-zones | ||
+ | work | ||
+ | interfaces: ens18 | ||
+ | </ | ||
+ | |||
+ | Pour ajouter le service **http** à la zone **work**, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --zone=work --add-service=http | ||
+ | success | ||
+ | |||
+ | [root@redhat9 ~]# firewall-cmd --zone=work --list-services | ||
+ | cockpit dhcpv6-client http ssh | ||
+ | </ | ||
+ | |||
+ | Pour supprimer le service **http** de la zone **work**, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --zone=work --remove-service=http | ||
+ | success | ||
+ | |||
+ | [root@redhat9 ~]# firewall-cmd --zone=work --list-services | ||
+ | cockpit dhcpv6-client ssh | ||
+ | </ | ||
+ | |||
+ | Pour ajouter un nouveau bloc ICMP, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --zone=work --add-icmp-block=echo-reply | ||
+ | success | ||
+ | |||
+ | [root@redhat9 ~]# firewall-cmd --zone=work --list-icmp-blocks | ||
+ | echo-reply | ||
+ | </ | ||
+ | |||
+ | Pour supprimer un bloc ICMP, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --zone=work --remove-icmp-block=echo-reply | ||
+ | success | ||
+ | |||
+ | [root@redhat9 ~]# firewall-cmd --zone=work --list-icmp-blocks | ||
+ | |||
+ | [root@redhat9 ~]# | ||
+ | </ | ||
+ | |||
+ | Pour ajouter le port 591/tcp à la zone work, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --zone=work --add-port=591/ | ||
+ | success | ||
+ | |||
+ | [root@redhat9 ~]# firewall-cmd --zone=work --list-ports | ||
+ | 591/tcp | ||
+ | </ | ||
+ | |||
+ | Pour supprimer le port 591/tcp à la zone work, utilisez la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --zone=work --remove-port=591/ | ||
+ | success | ||
+ | |||
+ | [root@redhat9 ~]# firewall-cmd --zone=work --list-ports | ||
+ | |||
+ | [root@redhat9 ~]# | ||
+ | </ | ||
+ | |||
+ | 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@redhat9 ~]# cp / | ||
+ | |||
+ | [root@redhat9 ~]# vi / | ||
+ | |||
+ | [root@redhat9 ~]# cat / | ||
+ | <?xml version=" | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <port protocol=" | ||
+ | </ | ||
+ | |||
+ | [root@redhat9 ~]# firewall-cmd --reload | ||
+ | success | ||
+ | |||
+ | [root@redhat9 ~]# firewall-cmd --get-services | grep filemaker | ||
+ | RH-Satellite-6 RH-Satellite-6-capsule afp amanda-client amanda-k5-client amqp amqps apcupsd | ||
+ | </ | ||
+ | |||
+ | ====4.4 - La Configuration Avancée de firewalld==== | ||
+ | |||
+ | La configuration de base de firewalld ne permet que la configuration des zones, services, blocs ICMP et les ports non-standard. Cependant firewalld peut également être configuré avec des **Rich Rules** ou **//Règles Riches//**. Rich Rules ou Règles Riches évaluent des **critères** pour ensuite entreprendre une **action**. | ||
+ | |||
+ | Les **Critères** sont : | ||
+ | |||
+ | * **source address="< | ||
+ | * **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@redhat9 | ||
+ | success | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Notez que la Rich Rule doit être entourée de caractères **'**. | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - 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@redhat9 ~]# firewall-cmd --add-rich-rule=' | ||
+ | success | ||
+ | |||
+ | [root@redhat9 ~]# cat / | ||
+ | <?xml version=" | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <service name=" | ||
+ | <service name=" | ||
+ | <service name=" | ||
+ | < | ||
+ | <port port=" | ||
+ | < | ||
+ | </ | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <WRAP center round important 50%> | ||
+ | **Important** - Attention ! La règle ajoutée avec l' | ||
+ | </ | ||
+ | |||
+ | Redémarrez le service **firewalld** : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# systemctl restart firewalld.service | ||
+ | </ | ||
+ | |||
+ | Pour visualiser cette règle dans la configuration de firewalld, il convient de saisir la commande suivante : | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --zone=work --list-all | ||
+ | work (active) | ||
+ | target: default | ||
+ | icmp-block-inversion: | ||
+ | interfaces: ens18 | ||
+ | sources: | ||
+ | services: cockpit dhcpv6-client ssh | ||
+ | ports: | ||
+ | protocols: | ||
+ | forward: yes | ||
+ | masquerade: no | ||
+ | forward-ports: | ||
+ | source-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@redhat9 ~]# firewall-cmd --zone=public --add-rich-rule=' | ||
+ | success | ||
+ | |||
+ | [root@redhat9 ~]# firewall-cmd --zone=public --list-all | ||
+ | public | ||
+ | target: default | ||
+ | icmp-block-inversion: | ||
+ | interfaces: | ||
+ | sources: | ||
+ | services: cockpit dhcpv6-client ssh | ||
+ | ports: | ||
+ | protocols: | ||
+ | forward: yes | ||
+ | masquerade: no | ||
+ | forward-ports: | ||
+ | source-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@redhat9 ~]# firewall-cmd --zone=public --remove-rich-rule=' | ||
+ | success | ||
+ | |||
+ | [root@redhat9 ~]# firewall-cmd --zone=public --list-all | ||
+ | public | ||
+ | target: default | ||
+ | icmp-block-inversion: | ||
+ | interfaces: | ||
+ | sources: | ||
+ | services: cockpit dhcpv6-client ssh | ||
+ | ports: | ||
+ | protocols: | ||
+ | forward: yes | ||
+ | masquerade: no | ||
+ | forward-ports: | ||
+ | source-ports: | ||
+ | icmp-blocks: | ||
+ | rich rules: | ||
+ | </ | ||
+ | |||
+ | ====4.5 - Le mode Panic de firewalld==== | ||
+ | |||
+ | Le mode Panic de firewalld permet de bloquer tout le trafic avec une seule commande. Pour connaître l' | ||
+ | |||
+ | < | ||
+ | [root@redhat9 ~]# firewall-cmd --query-panic | ||
+ | no | ||
+ | </ | ||
+ | |||
+ | Pour activer le mode Panic, il convient de saisir la commande suivante : | ||
+ | |||
+ | < | ||
+ | # firewall-cmd --panic-on | ||
+ | </ | ||
+ | |||
+ | Pour désactiver le mode Panic, il convient de saisir la commande suivante : | ||
+ | |||
+ | < | ||
+ | # firewall-cmd --panic-off | ||
</ | </ | ||
----- | ----- | ||
- | < | + | Copyright © 2024 Hugh Norris.< |
- | <div align=" | + | |
- | Copyright © 2021 Hugh Norris.< | + | |
- | </ | + | |
- | </html> | + |