Différences

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

Lien vers cette vue comparative

Prochaine révision
Révision précédente
elearning:workbooks:lpic:21:450:l106 [2022/10/07 09:54] – created adminelearning:workbooks:lpic:21:450:l106 [2022/11/01 07:27] (Version actuelle) admin
Ligne 1: Ligne 1:
 ~~PDF:LANDSCAPE~~ ~~PDF:LANDSCAPE~~
  
-Dernière mise-à-jour ~~LASTMOD~~+Version **2022.01**
  
-======Topic 6Networking Configuration======+Dernière mise-à-jour ~~LASTMOD~~
  
-=====Contenu du Module=====+======Topic 205: Networking Configuration======
  
-  * **Topic 6: Networking Configuration** +  * **Topic 205: Networking Configuration**
-    * Contenu du Module+
     * Configuration du Réseau sous Debian 6     * Configuration du Réseau sous Debian 6
       * Configuration de TCP/IP       * Configuration de TCP/IP
Ligne 22: Ligne 21:
         * /etc/nsswitch.conf         * /etc/nsswitch.conf
         * /etc/hosts         * /etc/hosts
-    * Configuration du Réseau sous RHEL/CentOS 5 et 6+    * Configuration du Réseau sous Debian 11 
 +      * 1.1 - Connections et Profils 
 +      * 1.2 - Résolution des Noms  
 +      * 1.3 - Ajouter une Deuxième Adresse IP à un Profil 
 +      * 1.4 - La Commande hostname 
 +      * 1.5 - La Commande ip 
 +      * 1.6 - Activer/Désactiver une Interface Manuellement 
 +      * 1.7 - Routage Statique 
 +        * La commande ip 
 +        * Activer/désactiver le routage sur le serveur 
 +    * LAB #2 - Diagnostique du Réseau 
 +      * 2.1 - ping 
 +      * 2.2 - netstat -i 
 +      * 2.3 - traceroute 
 +    * LAB #3 - Connexions à Distance 
 +      * 3.1 - Telnet 
 +      * 3.2 - wget 
 +      * 3.3 - ftp 
 +      * 3.4 - SSH 
 +        * Présentation 
 +          * SSH-1 
 +          * SSH-2 
 +        * Authentification par mot de passe 
 +        * Authentification par clef asymétrique 
 +        * Configuration du Serveur 
 +        * Configuration du Client 
 +        * Tunnels SSH 
 +      * 3.5 - SCP 
 +        * Présentation 
 +        * Utilisation 
 +      * 3.6 - Mise en Place des Clefs Asymétriques 
 +      * 3.7 - Services réseaux 
 +        * inetd 
 +        * TCP Wrapper 
 +    * Configuration du Réseau sous RHEL/CentOS 6
       * Configuration de TCP/IP       * Configuration de TCP/IP
         * DHCP         * DHCP
Ligne 44: Ligne 77:
           * La Commande route           * La Commande route
           * Activer/désactiver le routage sur le serveur           * Activer/désactiver le routage sur le serveur
-    * Configuration du Réseau sous Debian 9+    * Configuration du Réseau sous RHEL/CentOS 7
       * La Commande nmcli       * La Commande nmcli
       * Connections et Profils       * Connections et Profils
Ligne 51: Ligne 84:
       * La Commande ip       * La Commande ip
       * Activer/Désactiver une Interface Manuellement       * Activer/Désactiver une Interface Manuellement
-     * Configuration du Réseau sous RHEL/CentOS 7 +      * Routage Statique 
-        * La Commande nmcli +        * La commande ip 
-        * Connections et Profils +        * Activer/désactiver le routage sur le serveur 
-        * Ajouter une Deuxième Adresse IP à un Profil +      * LAB #4 Utilisation de nmap et de netcat 
-        * La Commande hostname +        * 4.1 - nmap
-        * La Commande ip +
-        * Activer/Désactiver une Interface Manuellement +
-        * Routage Statique +
-          * La commande ip +
-          * Activer/désactiver le routage sur le serveur +
-    * Services réseaux +
-      * xinetd +
-      * TCP Wrapper +
-    * Diagnostique du Réseau +
-      * ping +
-      * netstat -+
-      * traceroute +
-    * Connexions à Distance +
-      * Telnet +
-      * wget +
-      * ftp +
-      * SSH +
-        * Introduction +
-          * SSH-1 +
-          * SSH-+
-        * L'authentification par mot de passe +
-        * L'authentification par clef asymétrique+
           * Installation           * Installation
-          * Configuration 
-            * Serveur 
           * Utilisation           * Utilisation
-          * Tunnels SSH +          * Fichiers de Configuration 
-      SCP +          Scripts 
-        * Introduction +        * 4.2 - netcat 
-        * Utilisation +          * Utilisation 
-        * Mise en place des clefs +      * LAB #5 - Utilisation de tcpdump 
-    Le Pare-feu Netfilter +        * 5.1 - Utilisation 
-      * Configuration du Pare-feu Netfilter/iptables +          * L'option -i 
-        * Introduction +          * L'option -x 
-        * Configuration par Scripts sous Debian 6 et 7 +          * L'option -X 
-      La Configuration par firewalld sous Debian 8 +          * L'option -w 
-        * La Configuration de Base de firewalld +          * L'option -v 
-        * La Commande firewall-cmd +        5.2 Filtrage à l'écoute 
-        La Configuration Avancée de firewalld +      * LAB #6 Mise en place d'un VPN avec OpenVPN 
-        Le mode Panic de firewalld+        * Présentation 
 +        * Configuration commune au client et au serveur 
 +        * Configuration du client 
 +        * Configuration du serveur 
 +        * Tests 
 +          Du client vers le serveur 
 +          Du serveur vers le client
     * Annexe #1 - Comprendre les Réseaux     * Annexe #1 - Comprendre les Réseaux
       * Présentation des Réseaux       * Présentation des Réseaux
Ligne 176: Ligne 191:
       * PKI       * PKI
         * Certificats X509         * Certificats X509
 +    * Annexe 4 - La Commande iw
  
 =====Configuration de TCP/IP sous Debian 6===== =====Configuration de TCP/IP sous Debian 6=====
Ligne 557: Ligne 573:
 </code> </code>
  
-==== Services réseaux ====+=====LAB #1 - Configuration du Réseau sous Debian 11=====
  
-Quand un client émet une demande de connexion vers une application réseau sur un serveur, il utilise un socket attaché à un port local **supérieur à 1023**, alloué d'une manière dynamique. La requête contient le port de destination sur le serveurCertaines applications serveurs se gèrent toutes seules, ce qui est la cas par exemple d'**httpd**. Par contre d'autres sont gérées par le service **xinetd**. +Debian 11 utilise **Network Manager** pour gérer le réseauNetwork Manager est composé de deux éléments :
  
-=== xinetd ===+  * un service qui gère les connexions réseaux et rapporte leurs états, 
 +  * des front-ends qui passent par un API de configuration du service.
  
-Sous Debian 6 xinetd n'est pas installé par défaut. Installez-le grâce à apt-get :+<WRAP center round important 60%> 
 +**Important** : Notez qu'avec cette version de NetworkManager, IPv6 est activée par défaut. 
 +</WRAP> 
 + 
 +Le service NetworkManager doit toujours être lancé :
  
 <code> <code>
-root@debian6:~# apt-get install xinetd +root@debian11:~# systemctl status NetworkManager.service 
-Lecture des listes de paquets... Fait +● NetworkManager.service - Network Manager 
-Construction de l'arbre des dépendances        +     Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor pres> 
-Lecture des informations d'état..Fait +     Activeactive (running) since Sun 2022-05-01 18:00:05 CEST; 20h ago 
-Les NOUVEAUX paquets suivants seront installés +       Docs: man:NetworkManager(8) 
-  xinetd +   Main PID: 499 (NetworkManager) 
-0 mis à jour, 1 nouvellement installés, 0 à enlever et 219 non mis à jour. +      Tasks: 3 (limit: 4632) 
-Il est nécessaire de prendre 136 ko dans les archives. +     Memory: 13.3M 
-Après cette opération, 311 ko d'espace disque supplémentaires seront utilisés+        CPU: 1.811s 
-Réception de : 1 http://ftp.fr.debian.org/debiansqueeze/main xinetd i386 1:2.3.14-[136 kB+     CGroup: /system.slice/NetworkManager.service 
-136 ko réceptionnés en 0s (427 ko/s) +             └─499 /usr/sbin/NetworkManager --no-daemon 
-Sélection du paquet xinetd précédemment désélectionné. + 
-(Lecture de la base de données... 130628 fichiers et répertoires déjà installés.) +May 01 18:00:05 debian11 NetworkManager[499]: <info>  [1651420805.4957] device (ens18> 
-Dépaquetage de xinetd (à partir de .../xinetd_1%3a2.3.14-7_i386.deb) ... +May 01 18:00:05 debian11 NetworkManager[499]: <info>  [1651420805.5102] device (ens18> 
-Traitement des actions différées (« triggers ») pour « man-db »..+May 01 18:00:05 debian11 NetworkManager[499]: <info>  [1651420805.5136] device (ens18> 
-Paramétrage de xinetd (1:2.3.14-7) ..+May 01 18:00:05 debian11 NetworkManager[499]: <info>  [1651420805.5141] device (ens18> 
-Stopping internet superserverxinetd+May 01 18:00:05 debian11 NetworkManager[499]: <info>  [1651420805.5147] manager: Netw> 
-Starting internet superserverxinetd.+May 01 18:00:05 debian11 NetworkManager[499]: <info>  [1651420805.5157] manager: Netw> 
 +May 01 18:00:05 debian11 NetworkManager[499]: <info>  [1651420805.5159] policy: set '> 
 +May 01 18:00:05 debian11 NetworkManager[499]: <info>  [1651420805.6555] device (ens18> 
 +May 01 18:00:05 debian11 NetworkManager[499]: <info>  [1651420805.6577] manager: Netw> 
 +May 01 18:00:05 debian11 NetworkManager[499]: <info>  [1651420805.6604] manager: star> 
 +lines 1-21/21 (END) 
 +[q]
 </code> </code>
  
-Le programme xinetd est configuré via le fichier **/etc/xinetd.conf** :+La commande **nmcli** (Network Manager Command Line Interface) est utilisée pour configurer NetworkManager. 
 + 
 +Les options et les sous-commandes peuvent être consultées en utilisant les commandes suivantes :
  
 <code> <code>
-root@debian6:~# cat /etc/xinetd.conf +root@debian11:~# nmcli help 
-# Simple configuration file for xinetd +Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }
-+
-# Some defaults, and include /etc/xinetd.d/+
  
-defaults +OPTIONS 
-{+  -a, --ask                                ask for missing parameters 
 +  -c, --colors auto|yes|no                 whether to use colors in output 
 +  -e, --escape yes|no                      escape columns separators in values 
 +  -f, --fields <field,...>|all|common      specify fields to output 
 +  -g, --get-values <field,...>|all|common  shortcut for -m tabular -t -f 
 +  -h, --help                               print this help 
 +  -m, --mode tabular|multiline             output mode 
 +  -o, --overview                           overview mode 
 +  -p, --pretty                             pretty output 
 +  -s, --show-secrets                       allow displaying passwords 
 +  -t, --terse                              terse output 
 +  -v, --version                            show program version 
 +  -w, --wait <seconds>                     set timeout waiting for finishing operations
  
-# Please note that you need a log_type line to be able to use log_on_success +OBJECT 
-and log_on_failure. The default is the following : +  g[eneral]       NetworkManager's general status and operations 
-# log_type = SYSLOG daemon info+  n[etworking]    overall networking control 
 +  r[adio]         NetworkManager radio switches 
 +  c[onnection]    NetworkManager's connections 
 +  d[evice]        devices managed by NetworkManager 
 +  a[gent]         NetworkManager secret agent or polkit agent 
 +  m[onitor]       monitor NetworkManager changes 
 +</code>
  
-}+====1.1 - Connections et Profils====
  
-includedir /etc/xinetd.d+NetworkManager inclus la notion de **connections** ou **profils** permettant des configurations différentes en fonction de la localisationPour voir les connections actuelles, utilisez la commande **nmcli c** avec la sous-commande **show** : 
 + 
 +<code> 
 +root@debian11:~# nmcli c show 
 +NAME                UUID                                  TYPE      DEVICE  
 +Wired connection 1  77c569e6-3176-4c10-8008-40d7634d2504  ethernet  ens18 
 </code> </code>
  
-Les valeurs des directives dans le fichier **/etc/xinetd.conf** sont héritées par toutes les configurations des services sauf dans le cas où une variable est explicitement fixée dans un des fichiers de définitions des services se trouvant dans **/etc/xinetd.d**.+Créez donc un profil IP fixe rattaché au périphérique **ens18** :
  
-Les variables les plus usuellement utilisées dans **/etc/xinetd.conf** sont :+<code> 
 +root@debian11:~# nmcli connection add con-name ip_fixe ifname ens18 type ethernet ip4 10.0.2.41/24 gw4 10.0.2.1 
 +Connection 'ip_fixe' (c52994fc-0918-4108-81d2-d86dade62c7a) successfully added. 
 +</code>
  
-^  Directive  ^  Déscription +Constatez sa présence :
-|  instances  | Le nombre de demandes d'accès simultanés | +
-|  log_type  | Indique à xinetd d'adresser les traces à SYSLOG avec l'étiquette de sous-système applicatif **daemon** et la priorité de **info** | +
-|  log_on_succes  | Indique que SYSLOG doit journaliser le PID, HOST, DURATION et EXIT en cas de succès | +
-|  log_on_failure  | Indique que SYSLOG doit journaliser le HOST en cas d'échec | +
-|  cps  | Indique 50 connexions par seconde avec un temps d'indisponibilité de 10 secondes si le seuil est atteint | +
  
-Les options concernant les journaux sont :+<code> 
 +root@debian11:~# nmcli c show 
 +NAME                UUID                                  TYPE      DEVICE  
 +Wired connection 1  77c569e6-3176-4c10-8008-40d7634d2504  ethernet  ens18   
 +ip_fixe             c52994fc-0918-4108-81d2-d86dade62c7a  ethernet  --   
 +</code>
  
-|  HOST  | Journalisation de l'adresse IP de l'hôte distant | +Notez que la sortie n'indique pas que le profil **ip_fixe** soit associé au periphérique **ens18** car le profil **ip_fixe** n'est pas activé :
-|  PID  | Journalisation du PID du processus qui reçoit la demande d'accès | +
-|  DURATION  | Journalisation des durées d'utilisation | +
-|  EXIT  | Journalisation de l'état ou di signal de fin de service | +
-|  ATTEMPT  | Journalisation des connexions en échec | +
-|  USERID  | Journalisation des données concernant l'utilisateur selon la RFC 1413 |+
  
-Examinons maintenant le répertoire **/etc/xinetd.d** +<code> 
 +root@debian11:~# nmcli d show 
 +GENERAL.DEVICE:                         ens18 
 +GENERAL.TYPE:                           ethernet 
 +GENERAL.HWADDR:                         F6:35:D1:39:09:72 
 +GENERAL.MTU:                            1500 
 +GENERAL.STATE:                          100 (connected) 
 +GENERAL.CONNECTION:                     Wired connection 1 
 +GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnect> 
 +WIRED-PROPERTIES.CARRIER:               on 
 +IP4.ADDRESS[1]:                         10.0.2.40/24 
 +IP4.GATEWAY:                            10.0.2.1 
 +IP4.ROUTE[1]:                           dst = 10.0.2.0/24, nh = 0.0.0.0, mt = 100 
 +IP4.ROUTE[2]:                           dst = 0.0.0.0/0, nh = 10.0.2.1, mt = 100 
 +IP4.DNS[1]:                             8.8.8.8 
 +IP4.DNS[2]:                             8.8.4.4 
 +IP6.ADDRESS[1]:                         fe80::f435:d1ff:fe39:972/64 
 +IP6.GATEWAY:                            -- 
 +IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 100 
 +IP6.ROUTE[2]:                           dst = ff00::/8, nh = ::, mt = 256, table=255 
 + 
 +GENERAL.DEVICE:                         lo 
 +GENERAL.TYPE:                           loopback 
 +GENERAL.HWADDR:                         00:00:00:00:00:00 
 +GENERAL.MTU:                            65536 
 +lines 1-23 
 +[q] 
 +</code> 
 + 
 +Pour activer le profil ip_fixe, utilisez la commande suivante :
  
 <code> <code>
-root@debian6:~# ls -l /etc/xinetd.d +[root@centos8 ~]nmcli connection up ip_fixe 
-total 20 +
--rw-r--r-- 1 root root 798 26 mars   2008 chargen +
--rw-r--r-- 1 root root 660 26 mars   2008 daytime +
--rw-r--r-- 1 root root 549 26 mars   2008 discard +
--rw-r--r-- 1 root root 580 26 mars   2008 echo +
--rw-r--r-- 1 root root 727 26 mars   2008 time+
 </code> </code>
  
-l'examen de ce répertoire vous noterez que celui-ci contient des fichiers nominatifs par application-serveur, par exemple pour le serveur chargen :+Notez que votre terminal est bloqué à cause du changement de l'adresse IP.  
 + 
 +<WRAP center round todo 60%> 
 +**A faire** Revenez à votre Gateway et re-connectez-vous à la VM en tant que trainee en utilisant l'adresse IP 10.0.2.41. 
 +</WRAP> 
 + 
 +Le profil ip_fixe est maintenant activé tandis que le profil enp0s3 a été désactivé :
  
 <code> <code>
-root@debian6:~# cat /etc/xinetd.d/chargen +root@debian11:~# nmcli c show 
-defaultoff +NAME                UUID                                  TYPE      DEVICE  
-# descriptionAn xinetd internal service which generate characters The +ip_fixe             c52994fc-0918-4108-81d2-d86dade62c7a  ethernet  ens18   
-# xinetd internal service which continuously generates characters until the +Wired connection 1  77c569e6-3176-4c10-8008-40d7634d2504  ethernet  --    
-# connection is dropped The characters look something like this+    
-# !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg +root@debian11:~nmcli d show 
-# This is the tcp version+GENERAL.DEVICE                        ens18 
-service chargen +GENERAL.TYPE                          ethernet 
-+GENERAL.HWADDR:                         F6:35:D1:39:09:72 
- disable yes +GENERAL.MTU                           1500 
- type INTERNAL +GENERAL.STATE:                          100 (connected) 
- id chargen-stream +GENERAL.CONNECTION                    ip_fixe 
- socket_type stream +GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveC> 
- protocol tcp +WIRED-PROPERTIES.CARRIER:               on 
- user root +IP4.ADDRESS[1]:                         10.0.2.41/24 
- wait no +IP4.GATEWAY:                            10.0.2.1 
-}                                                                               +IP4.ROUTE[1]:                           dst 10.0.2.0/24, nh 0.0.0.0, mt = 1> 
 +IP4.ROUTE[2]:                           dst 0.0.0.0/0, nh = 10.0.2.1, mt = 100 
 +IP6.ADDRESS[1]:                         fe80::7958:e23f:31e:62cd/64 
 +IP6.GATEWAY:                            -
 +IP6.ROUTE[1]:                           dst fe80::/64, nh ::, mt 100 
 +IP6.ROUTE[2]:                           dst ff00::/8, nh = ::, mt = 256, tabl>
  
-# This is the udp version+GENERAL.DEVICE:                         lo 
-service chargen +GENERAL.TYPE:                           loopback 
-+lines 1-19 
- disable = yes +[q]
- type = INTERNAL +
- id = chargen-dgram +
- socket_type = dgram +
- protocol = udp +
- user = root +
- wait = yes +
-}  +
 </code> </code>
  
-Les directives principales de ce fichier sont :+Pour consulter les paramètres du profil **Wired connection 1**, utilisez la commande suivante :
  
-^  Paramètre  ^  Déscription  ^ +<code> 
-|  disable  | **no** Le service est actif**yes** Le service est désactivé | +root@debian11:~# nmcli -p connection show "Wired connection 1" 
-|  port  | Le numéro de port ou, à défautle numéro indiqué pour le service dans le fichier /etc/services | +=============================================================================== 
-|  socket_type  | Nature du socket, soit **stream** pour TCP soit **dgram** pour UDP | +                Connection profile details (Wired connection 1) 
-|  protocol  | Protocole utilisé soit **TCP** soit **UDP** | +=============================================================================== 
-|  wait  | **no** indique si xinetd active un serveur par client**yes** indique que xinetd active un seul serveur pour tous les client |  +connection.id:                          Wired connection 1 
-|  user  | Indique le compte sous lequel le serveur est exécuté | +connection.uuid:                        77c569e6-3176-4c10-8008-40d7634d2504 
-|  server  | Indique le chemin d'accès de l'application serveur | +connection.stable-id:                   -- 
-|  env  | Définit un environnement système | +connection.type:                        802-3-ethernet 
-|  server_args  | Donne les arguments transmis à l'application serveur |+connection.interface-name:              -- 
 +connection.autoconnect:                 yes 
 +connection.autoconnect-priority       0 
 +connection.autoconnect-retries:         -1 (default) 
 +connection.multi-connect:               0 (default) 
 +connection.auth-retries:                -1 
 +connection.timestamp:                   1651494383 
 +connection.read-only:                   no 
 +connection.permissions:                 -- 
 +connection.zone:                        -- 
 +connection.master:                      -- 
 +connection.slave-type:                  -- 
 +connection.autoconnect-slaves:          -1 (default) 
 +connection.secondaries:                 -- 
 +connection.gateway-ping-timeout:        0 
 +connection.metered:                     unknown 
 +connection.lldp:                        default 
 +connection.mdns:                        -1 (default) 
 +connection.llmnr:                       -1 (default) 
 +connection.wait-device-timeout:         -1 
 +------------------------------------------------------------------------------- 
 +802-3-ethernet.port:                    -- 
 +802-3-ethernet.speed:                   0 
 +802-3-ethernet.duplex:                  -- 
 +802-3-ethernet.auto-negotiate:          no 
 +802-3-ethernet.mac-address:             -- 
 +802-3-ethernet.cloned-mac-address:      -- 
 +802-3-ethernet.generate-mac-address-mask:-- 
 +802-3-ethernet.mac-address-blacklist:   -- 
 +802-3-ethernet.mtu:                     auto 
 +802-3-ethernet.s390-subchannels:        -- 
 +802-3-ethernet.s390-nettype:            -- 
 +802-3-ethernet.s390-options:            -- 
 +802-3-ethernet.wake-on-lan:             default 
 +802-3-ethernet.wake-on-lan-password:    -- 
 +------------------------------------------------------------------------------- 
 +ipv4.method:                            manual 
 +ipv4.dns:                               8.8.8.8,8.8.4.4 
 +ipv4.dns-search:                        -- 
 +ipv4.dns-options:                       -- 
 +ipv4.dns-priority:                      0 
 +ipv4.addresses:                         10.0.2.40/24 
 +ipv4.gateway:                           10.0.2.1 
 +ipv4.routes:                            -- 
 +ipv4.route-metric                     -1 
 +ipv4.route-table                      0 (unspec) 
 +ipv4.routing-rules:                     -- 
 +ipv4.ignore-auto-routes:                no 
 +ipv4.ignore-auto-dns:                   no 
 +lines 1-56 
 +[q] 
 +</code>
  
-Cependant il est aussi possible d'utiliser les directives suivantes :+De même, pour consulter les paramètres du profil **ip_fixe**, utilisez la commande suivante :
  
-^  Paramètre  ^  Déscription  ^  Exemple  ^ +<code> 
-|  nice  | Fixe le niveau de nice entre -19 et +20 |  10  | +root@debian11:~# nmcli -p connection show ip_fixe 
-|  max_load  | Fixe la charge CPU maximum admiseAu delà aucune connexion supplémenatire en sera acceptée |  2.5  | +=============================================================================== 
-|  bind  | Limite le service à l'interface dont l'adresse IP est indiquée |  192.168.1.1  | +                     Connection profile details (ip_fixe) 
-|  only_from  | Limite le service aux seuls clients indiqués par la plage donnée |  192.168.1.0/24 fenestros.loc  | +=============================================================================== 
-|  no_access  | Interdit le service aux clients indiqués par la plage donnée |  192.168.2.0/24, i2tch.loc  |  +connection.id:                          ip_fixe 
-|  access_time  | Limite l'accès au service à une plage horaire |  09:00-19:00  | +connection.uuid:                        c52994fc-0918-4108-81d2-d86dade62c7a 
-|  redirect  | Redirige les requêtes sur un port donné à une autre adresse IP |  192.168.1.10 23  |+connection.stable-id:                   -- 
 +connection.type:                        802-3-ethernet 
 +connection.interface-name:              ens18 
 +connection.autoconnect:                 yes 
 +connection.autoconnect-priority:        0 
 +connection.autoconnect-retries:         -(default) 
 +connection.multi-connect:               0 (default) 
 +connection.auth-retries:                -
 +connection.timestamp:                   1651496105 
 +connection.read-only:                   no 
 +connection.permissions:                 -- 
 +connection.zone:                        -- 
 +connection.master:                      -- 
 +connection.slave-type:                  -- 
 +connection.autoconnect-slaves:          -(default) 
 +connection.secondaries:                 -- 
 +connection.gateway-ping-timeout:        0 
 +connection.metered:                     unknown 
 +connection.lldp:                        default 
 +connection.mdns:                        -1 (default) 
 +connection.llmnr:                       -1 (default) 
 +connection.wait-device-timeout:         -1 
 +------------------------------------------------------------------------------- 
 +802-3-ethernet.port:                    -- 
 +802-3-ethernet.speed:                   0 
 +802-3-ethernet.duplex:                  -- 
 +802-3-ethernet.auto-negotiate:          no 
 +802-3-ethernet.mac-address:             -- 
 +802-3-ethernet.cloned-mac-address:      -- 
 +802-3-ethernet.generate-mac-address-mask:-- 
 +802-3-ethernet.mac-address-blacklist:   -- 
 +802-3-ethernet.mtu:                     auto 
 +802-3-ethernet.s390-subchannels:        -- 
 +802-3-ethernet.s390-nettype:            -- 
 +802-3-ethernet.s390-options:            -- 
 +802-3-ethernet.wake-on-lan:             default 
 +802-3-ethernet.wake-on-lan-password:    -- 
 +------------------------------------------------------------------------------- 
 +ipv4.method:                            manual 
 +ipv4.dns:                               -- 
 +ipv4.dns-search:                        -- 
 +ipv4.dns-options:                       -- 
 +ipv4.dns-priority:                      0 
 +ipv4.addresses:                         10.0.2.41/24 
 +ipv4.gateway:                           10.0.2.1 
 +ipv4.routes                           -
 +ipv4.route-metric                     -1 
 +ipv4.route-table:                       0 (unspec) 
 +ipv4.routing-rules:                     -- 
 +ipv4.ignore-auto-routes:                no 
 +ipv4.ignore-auto-dns:                   no 
 +lines 1-56 
 +[q] 
 +</code>
  
-Afin d'activer une application serveuril suffit de modifier le paramètre **disable** dans le fichier concerné et de relancer le service xinetd.+Pour consulter la liste profils associés à un périphériqueutilisez la commande suivante :
  
-=== TCP Wrapper ===+<code> 
 +root@debian11:~# nmcli -f CONNECTIONS device show ens18 
 +CONNECTIONS.AVAILABLE-CONNECTION-PATHS: /org/freedesktop/NetworkManager/Settings/1,/o> 
 +CONNECTIONS.AVAILABLE-CONNECTIONS[1]:   77c569e6-3176-4c10-8008-40d7634d2504 | Wired > 
 +CONNECTIONS.AVAILABLE-CONNECTIONS[2]:   c52994fc-0918-4108-81d2-d86dade62c7a | ip_fixe 
 +lines 1-3/3 (END) 
 +[q] 
 +</code>
  
-**TCP Wrapper** contrôle l'accès à des services réseaux grâce à des **ACL**+Les fichiers de configuration pour le periphérique **ens18** se trouvent dans le répertoire **/etc/NetworkManager/system-connections/** :
  
-Quand une requête arrive pour un serveur, xinetd active le wrapper **tcpd** au lieu d'activer le serveur directement.+<code> 
 +root@debian11:~# ls -l /etc/NetworkManager/system-connections 
 +total 8 
 +-rw------- 1 root root 284 May  2 14:23  ip_fixe.nmconnection 
 +-rw------- 1 root root 249 Apr 25 07:01 'Wired connection 1' 
 +</code>
  
-**tcpd** met à jour un journal et vérifie si le client a le droit d'utiliser le service concernéLes ACL se trouvent dans deux fichiers:+====1.2 - Résolution des Noms====
  
-  * **/etc/hosts.allow** +L'étude du fichier **/etc/NetworkManager/system-connections/ip_fixe.nmconnection** démontre l'abscence de directives concernant les DNS :
-  * **/etc/hosts.deny**+
  
-Il faut noter que si ces fichiers n'existent pas ou sont vides, il n'y a pas de contrôle d'accès.+<code> 
 +root@debian11:~# cat /etc/NetworkManager/system-connections/ip_fixe.nmconnection  
 +[connection] 
 +id=ip_fixe 
 +uuid=c52994fc-0918-4108-81d2-d86dade62c7a 
 +type=ethernet 
 +interface-name=ens18 
 +permissions=
  
-Le format d'une ligne dans un de ces deux fichiers est:+[ethernet] 
 +mac-address-blacklist=
  
-<file> +[ipv4] 
-démon : liste_de_clients +address1=10.0.2.41/24,10.0.2.1 
-</file>+dns-search= 
 +method=manual
  
-Par exemple dans le cas d'un serveur **démon**, on verrait une ligne dans le fichier **/etc/hosts.allow** similaire à:+[ipv6] 
 +addr-gen-mode=stable-privacy 
 +dns-search= 
 +method=auto
  
-<file> +[proxy] 
-démon : LOCAL, .fenestros.loc +</code>
-</file>+
  
-ce qui implique que les machines dont le nom ne comporte pas de point ainsi que les machines du domaine **fenestros.loc** sont autorisées à utiliser le service.+La résolution des noms est donc inactive :
  
-Le mot clef **ALL** peut être utilisé pour indiquer toutPar exemple, **ALL:ALL** dans le fichier **/etc/host.deny** bloque effectivement toute tentative de connexion à un service xinetd sauf pour les ACL inclus dans le fichier /etc/host.allow.+<code> 
 +root@debian11:~# ping www.free.fr 
 +pingwww.free.fr: Temporary failure in name resolution 
 +</code>
  
-====Routage Statique====+Modifiez donc la configuration du profil **ip_fixe** :
  
-===La Commande route===+<code> 
 +root@debian11:~# nmcli connection mod ip_fixe ipv4.dns 8.8.8.8 
 +</code>
  
-Pour afficher la table de routage de la machine vous pouvez utiliser la commande **route** :+L'étude du fichier **/etc/NetworkManager/system-connections/ip_fixe.nmconnection** démontre que la directive concernant le serveur DNS a été ajoutée :
  
 <code> <code>
-root@debian6:~# route +root@debian11:~# cat /etc/NetworkManager/system-connections/ip_fixe.nmconnection 
-Table de routage IP du noyau +[connection] 
-Destination     Passerelle      Genmask         Indic Metric Ref    Use Iface +id=ip_fixe 
-192.168.1.0                   255.255.255.0            0        0 eth0 +uuid=c52994fc-0918-4108-81d2-d86dade62c7a 
-10.0.2.0        *               255.255.255.0            0        0 eth0 +type=ethernet 
-default         10.0.2.2        0.0.0.0         UG    0      0        0 eth0+interface-name=ens18 
 +permissions= 
 +timestamp=1651499105 
 + 
 +[ethernet] 
 +mac-address-blacklist= 
 + 
 +[ipv4] 
 +address1=10.0.2.41/24,10.0.2.
 +dns=8.8.8.8; 
 +dns-search= 
 +method=manual 
 + 
 +[ipv6] 
 +addr-gen-mode=stable-privacy 
 +dns-search= 
 +method=auto 
 + 
 +[proxy]
 </code> </code>
  
-La table issue de la commande **route** indique les informations suivantes:+Afin que la modification du serveur DNS soit prise en compte, re-démarrez le service NetworkManager :
  
-  * La destination qui peut être un hôte ou un réseau et est identifiée par les champs **Destination** et **Genmask** +<code> 
-  * La route à prendre identifiée par les champs **Gateway** et **Iface**. Dans le cas d'une valeur de 0.0.0.0 ceci spécifie une route directe. La valeur d'Iface spécifie la carte à utiliser, +root@debian11:~# systemctl restart NetworkManager.service 
-  * Le champ **Indic** qui peux prendre un ou plusieurs de svaleurs suivantes: +</code>
-    * U - **Up** - la route est active +
-    * H - **Host** - la route conduit à un hôte +
-    * G - **Gateways** - la route passe par une passerelle +
-  * Le champ **Metric** indique le nombre de sauts (passerelles) pour atteindre la destination, +
-  * Le champ **Ref** indique le nombre de références à cette routeCe champs est usilisé par le Noyau de Linux, +
-  * Le champ **Use** indique le nombre de recherches associés à cette route.+
  
-La commande **route** permet aussi de paramétrer le routage indirect. Par exemple pour supprimer la route vers le réseau 192.168.1.0 :+Vérifiez que le fichier **/etc/resolv.conf** ait été modifié par NetworkManager :
  
 <code> <code>
-root@debian6:~# route del -net 192.168.1.0 netmask 255.255.255.0 +root@debian11:~# cat /etc/resolv.conf 
-root@debian6:~# route +# Generated by NetworkManager 
-Table de routage IP du noyau +nameserver 8.8.8.8 
-Destination     Passerelle      Genmask         Indic Metric Ref    Use Iface +</code> 
-10.0.2.0                      255.255.255.0   U                 0 eth0 + 
-default         10.0.2.2        0.0.0.0         UG                eth0+Dernièrement vérifiez la resolution des noms : 
 + 
 +<code> 
 +root@debian11:~# ping www.free.fr 
 +PING www.free.fr (212.27.48.10) 56(84) bytes of data. 
 +64 bytes from www.free.fr (212.27.48.10): icmp_seq=1 ttl=47 time=10.8 ms 
 +64 bytes from www.free.fr (212.27.48.10): icmp_seq=2 ttl=47 time=11.1 ms 
 +^C 
 +--- www.free.fr ping statistics --- 
 +2 packets transmitted, 2 received, 0% packet loss, time 1002ms 
 +rtt min/avg/max/mdev = 10.804/10.931/11.058/0.127 ms 
 +</code> 
 + 
 +<WRAP center round important 60%> 
 +**Important** : Notez qu'il existe un front-end graphique en mode texte, **nmtui**, pour configurer NetworkManager. 
 +</WRAP> 
 + 
 +====1.3 - Ajouter une Deuxième Adresse IP à un Profil==== 
 + 
 +Pour ajouter une deuxième adresse IP à un profil sous Debian 11, il convient d'utiliser la commande suivante : 
 + 
 +<code> 
 +root@debian11:~# nmcli connection mod ip_fixe +ipv4.addresses 192.168.1.2/24 
 +</code> 
 + 
 +Rechargez la configuration du profil : 
 + 
 +<code> 
 +root@debian11:~# nmcli con up ip_fixe 
 +Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2) 
 +</code> 
 + 
 +Saisissez ensuite la commande suivante : 
 + 
 +<code> 
 +root@debian11:~# nmcli connection show ip_fixe 
 +connection.id:                          ip_fixe 
 +connection.uuid:                        c52994fc-0918-4108-81d2-d86dade62c7a 
 +connection.stable-id:                   -- 
 +connection.type:                        802-3-ethernet 
 +connection.interface-name:              ens18 
 +connection.autoconnect:                 yes 
 +connection.autoconnect-priority:        0 
 +connection.autoconnect-retries:         -1 (default) 
 +connection.multi-connect:               0 (default) 
 +connection.auth-retries:                -1 
 +connection.timestamp:                   1651499367 
 +connection.read-only:                   no 
 +connection.permissions:                 -- 
 +connection.zone:                        -- 
 +connection.master:                      -- 
 +connection.slave-type:                  -- 
 +connection.autoconnect-slaves:          -1 (default) 
 +connection.secondaries:                 -- 
 +connection.gateway-ping-timeout:        0 
 +connection.metered:                     unknown 
 +connection.lldp:                        default 
 +connection.mdns:                        -1 (default) 
 +connection.llmnr:                       -1 (default) 
 +connection.wait-device-timeout:         -1 
 +802-3-ethernet.port:                    -- 
 +802-3-ethernet.speed:                   0 
 +802-3-ethernet.duplex:                  -- 
 +802-3-ethernet.auto-negotiate:          no 
 +802-3-ethernet.mac-address:             -- 
 +802-3-ethernet.cloned-mac-address:      -- 
 +802-3-ethernet.generate-mac-address-mask:-- 
 +802-3-ethernet.mac-address-blacklist:   -- 
 +802-3-ethernet.mtu:                     auto 
 +802-3-ethernet.s390-subchannels:        -- 
 +802-3-ethernet.s390-nettype:            -- 
 +802-3-ethernet.s390-options:            -- 
 +802-3-ethernet.wake-on-lan:             default 
 +802-3-ethernet.wake-on-lan-password:    -- 
 +ipv4.method:                            manual 
 +ipv4.dns:                               8.8.8.8 
 +ipv4.dns-search:                        -- 
 +ipv4.dns-options:                       -- 
 +ipv4.dns-priority:                      0 
 +ipv4.addresses:                         10.0.2.41/24, 192.168.1.2/24 
 +ipv4.gateway:                           10.0.2.1 
 +ipv4.routes:                            -- 
 +ipv4.route-metric:                      -1 
 +ipv4.route-table:                       0 (unspec) 
 +ipv4.routing-rules:                     -- 
 +ipv4.ignore-auto-routes:                no 
 +ipv4.ignore-auto-dns:                   no 
 +ipv4.dhcp-client-id:                    -- 
 +ipv4.dhcp-iaid:                         -- 
 +ipv4.dhcp-timeout:                      0 (default) 
 +ipv4.dhcp-send-hostname:                yes 
 +ipv4.dhcp-hostname:                     -- 
 +lines 1-56 
 +[Space Bar] 
 +IP4.ADDRESS[1]:                         10.0.2.41/24 
 +IP4.ADDRESS[2]:                         192.168.1.2/24 
 +IP4.GATEWAY:                            10.0.2.
 +IP4.ROUTE[1]:                           dst = 10.0.2.0/24, nh = 0.0.0.0, mt = 100 
 +IP4.ROUTE[2]:                           dst = 192.168.1.0/24, nh = 0.0.0.0, mt = 100 
 +IP4.ROUTE[3]:                           dst = 0.0.0.0/0, nh = 10.0.2.1, mt = 100 
 +IP4.DNS[1]:                             8.8.8.8 
 +lines 57-112 
 +[q] 
 +</code> 
 + 
 +<WRAP center round important 60%> 
 +**Important** : Notez l'ajout de l'adresse secondaire à la ligne **ipv4.addresses: ** ainsi que l'ajout de la ligne **IP4.ADDRESS[2]:**. 
 +</WRAP> 
 + 
 +Consultez maintenant le contenu du fichier **/etc/NetworkManager/system-connections/ip_fixe.nmconnection** : 
 + 
 +<code> 
 +root@debian11:~# cat /etc/NetworkManager/system-connections/ip_fixe.nmconnection 
 +[connection] 
 +id=ip_fixe 
 +uuid=c52994fc-0918-4108-81d2-d86dade62c7a 
 +type=ethernet 
 +interface-name=ens18 
 +permissions= 
 +timestamp=1651499263 
 + 
 +[ethernet] 
 +mac-address-blacklist= 
 + 
 +[ipv4] 
 +address1=10.0.2.41/24,10.0.2.1 
 +address2=192.168.1.2/24 
 +dns=8.8.8.8; 
 +dns-search= 
 +method=manual 
 + 
 +[ipv6] 
 +addr-gen-mode=stable-privacy 
 +dns-search= 
 +method=auto 
 + 
 +[proxy] 
 +</code> 
 + 
 +<WRAP center round important 60%> 
 +**Important** : Notez l'ajout de la ligne **address2=192.168.1.2/24**. 
 +</WRAP> 
 + 
 +====1.4 - La Commande hostname==== 
 + 
 +La procédure de la modification du hostname est simplifiée et sa prise en compte est immédiate : 
 + 
 +<code> 
 +root@debian11:~# hostname 
 +debian11 
 + 
 +root@debian11:~# nmcli general hostname debian11.ittraining.loc 
 + 
 +root@debian11:~# cat /etc/hostname 
 +debian11.ittraining.loc 
 + 
 +root@debian11:~# hostname 
 +debian11.ittraining.loc 
 +</code> 
 + 
 +====1.5 - La Commande ip==== 
 + 
 +Sous Debian 11 la commande **ip** est préférée par rapport à la commande ifconfig : 
 + 
 +<code> 
 +root@debian11:~# ip address 
 +1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 
 +    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 
 +    inet 127.0.0.1/8 scope host lo 
 +       valid_lft forever preferred_lft forever 
 +    inet6 ::1/128 scope host  
 +       valid_lft forever preferred_lft forever 
 +2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 
 +    link/ether f6:35:d1:39:09:72 brd ff:ff:ff:ff:ff:ff 
 +    altname enp0s18 
 +    inet 10.0.2.41/24 brd 10.0.2.255 scope global noprefixroute ens18 
 +       valid_lft forever preferred_lft forever 
 +    inet 192.168.1.2/24 brd 192.168.1.255 scope global noprefixroute ens18 
 +       valid_lft forever preferred_lft forever 
 +    inet6 fe80::7958:e23f:31e:62cd/64 scope link noprefixroute  
 +       valid_lft forever preferred_lft forever 
 +</code> 
 + 
 +En cas de besoin, pour extraire les adresses IP de cette sortie, utilisez les commandes suivantes : 
 + 
 +<code> 
 +root@debian11:~# ip addr show ens18 | grep "inet" | grep -v "inet6" | awk '{ print $2; }' | sed 's/\/.*$//' 
 +10.0.2.41 
 +192.168.1.2 
 +</code> 
 + 
 +Les options de cette commande sont : 
 + 
 +<code> 
 +root@debian11:~# ip --help 
 +Usage: ip [ OPTIONS ] OBJECT { COMMAND | help } 
 +       ip [ -force ] -batch filename 
 +where  OBJECT := { link | address | addrlabel | route | rule | neigh | ntable | 
 +                   tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm | 
 +                   netns | l2tp | fou | macsec | tcp_metrics | token | netconf | ila | 
 +                   vrf | sr | nexthop | mptcp } 
 +       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] | 
 +                    -h[uman-readable] | -iec | -j[son] | -p[retty] | 
 +                    -f[amily] { inet | inet6 | mpls | bridge | link } | 
 +                    -4 | -6 | -I | -D | -M | -B | -
 +                    -l[oops] { maximum-addr-flush-attempts } | -br[ief] | 
 +                    -o[neline] | -t[imestamp] | -ts[hort] | -b[atch] [filename] | 
 +                    -rc[vbuf] [size] | -n[etns] name | -N[umeric] | -a[ll] | 
 +                    -c[olor]} 
 +</code> 
 + 
 +====1.6 - Activer/Désactiver une Interface Manuellement==== 
 + 
 +Deux commandes existent pour désactiver et activer manuellement une interface réseau : 
 + 
 +<code> 
 +# nmcli device disconnect enp0s3 
 +# nmcli device connect enp0s3 
 +</code> 
 + 
 +<WRAP center round important 60%> 
 +**Important** : Veuillez ne **PAS** exécuter ces deux commandes. 
 +</WRAP> 
 + 
 +====1.7 - Routage Statique==== 
 + 
 +===La commande ip=== 
 + 
 +Sous Debian 11, pour supprimer la route vers le réseau 192.168.1.il convient d'utiliser la commande ip et non pas la commande route : 
 + 
 +<code> 
 +root@debian11:~# ip route 
 +default via 10.0.2.1 dev ens18 proto static metric 100  
 +10.0.2.0/24 dev ens18 proto kernel scope link src 10.0.2.41 metric 100  
 +192.168.1.0/24 dev ens18 proto kernel scope link src 192.168.1.2 metric 100  
 + 
 +root@debian11:~# ip route del 192.168.1.0/24 via 0.0.0.0 
 + 
 +root@debian11:~# ip route 
 +default via 10.0.2.1 dev ens18 proto static metric 100  
 +10.0.2.0/24 dev ens18 proto kernel scope link src 10.0.2.41 metric 100
 </code> </code>
  
Ligne 768: Ligne 1227:
  
 <code> <code>
-root@debian6:~# route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.2 +root@debian11:~# ip route add 192.168.1.0/24 via 10.0.2.1 
-root@debian6:~# route + 
-Table de routage IP du noyau +root@debian11:~# ip route 
-Destination     Passerelle      Genmask         Indic Metric Ref    Use Iface +default via 10.0.2.1 dev ens18 proto static metric 100  
-192.168.1.0     mdt34.formation 255.255.255.0   UG    0      0        0 eth0 +10.0.2.0/24 dev ens18 proto kernel scope link src 10.0.2.41 metric 100  
-10.0.2.0        *               255.255.255.0   U          0        0 eth0 +192.168.1.0/24 via 10.0.2.1 dev ens18 
-default         10.0.2.2        0.0.0.0         UG    0      0        0 eth0+
 </code> </code>
  
-<WRAP center round important> +<WRAP center round important 60%
-La commande utilisée pour ajouter une passerelle par défaut prend la forme suivante **route add default gw //numéro_ip// //interface//**.+**Important** - La commande utilisée pour ajouter une passerelle par défaut prend la forme suivante **ip route add default via //adresse ip//**.
 </WRAP> </WRAP>
  
-Les options cette commande sont :+===Activer le routage sur le serveur=== 
 + 
 +Pour activer le routage sur le serveur, il convient d'activer la retransmission des paquets:
  
 <code> <code>
-root@debian6:~# route --help +root@debian11:~# echo 1 > /proc/sys/net/ipv4/ip_forward 
-Syntaxeroute [-nNvee] [-FC] [<AF>]           Liste les tables de routage noyau +root@debian11:~# cat /proc/sys/net/ipv4/ip_forward 
-       route [-v] [-FC] {add|del|flush} ...  Modifie la table de routage pour AF.+
 +</code>
  
-       route {-h|--help} [<AF>             Utilisation détaillée pour l'AF spécifié. +=====LAB #2 Diagnostique du Réseau=====
-       route {-V|--version}                  Affiche la version/auteur et termine.+
  
-        -v, --verbose            mode verbeux+====2.1 - ping==== 
 + 
 +Pour tester l'accessibilité d'une machine, vous devez utiliser la commande **ping** : 
 + 
 +<code> 
 +root@debian11:~# ping -c4 10.0.2.1 
 +PING 10.0.2.1 (10.0.2.1) 56(84) bytes of data. 
 +64 bytes from 10.0.2.1: icmp_seq=1 ttl=64 time=0.184 ms 
 +64 bytes from 10.0.2.1: icmp_seq=2 ttl=64 time=0.167 ms 
 +64 bytes from 10.0.2.1: icmp_seq=3 ttl=64 time=0.168 ms 
 +^C 
 +--- 10.0.2.1 ping statistics --- 
 +3 packets transmitted, 3 received, 0% packet loss, time 2036ms 
 +rtt min/avg/max/mdev = 0.167/0.173/0.184/0.007 ms 
 +</code> 
 + 
 +Les options de cette commande sont : 
 + 
 +<code> 
 +root@debian11:~# ping --help 
 +ping: invalid option -- '-' 
 + 
 +Usage 
 +  ping [options] <destination> 
 + 
 +Options: 
 +  <destination>      dns name or ip address 
 +  -a                 use audible ping 
 +  -A                 use adaptive ping 
 +  -B                 sticky source address 
 +  -c <count>         stop after <count> replies 
 +  -D                 print timestamps 
 +  -d                 use SO_DEBUG socket option 
 +  -f                 flood ping 
 +  -h                 print help and exit 
 +  -I <interface>     either interface name or address 
 +  -i <interval>      seconds between sending each packet 
 +  -L                 suppress loopback of multicast packets 
 +  -l <preload>       send <preload> number of packages while waiting replies 
 +  -m <mark>          tag the packets going out 
 +  -M <pmtud opt>     define mtu discovery, can be one of <do|dont|want> 
 +  -n                 no dns name resolution 
 +  -O                 report outstanding replies 
 +  -p <pattern>       contents of padding byte 
 +  -q                 quiet output 
 +  -Q <tclass>        use quality of service <tclass> bits 
 +  -s <size>          use <size> as number of data bytes to be sent 
 +  -S <size>          use <size> as SO_SNDBUF socket option value 
 +  -t <ttl>           define time to live 
 +  -U                 print user-to-user latency 
 +  -v                 verbose output 
 +  -V                 print version and exit 
 +  -w <deadline>      reply wait <deadline> in seconds 
 +  -W <timeout>       time to wait for response 
 + 
 +IPv4 options: 
 +  -4                 use IPv4 
 +  -b                 allow pinging broadcast 
 +  -R                 record route 
 +  -T <timestamp>     define timestamp, can be one of <tsonly|tsandaddr|tsprespec> 
 + 
 +IPv6 options: 
 +  -6                 use IPv6 
 +  -F <flowlabel>     define flow label, default is random 
 +  -N <nodeinfo opt>  use icmp6 node info query, try <help> as argument 
 + 
 +For more details see ping(8). 
 +</code> 
 + 
 +====2.2 - netstat -i==== 
 + 
 +Pour visualiser les statistiques réseaux, vous disposez de la commande **netstat** : 
 + 
 +<code> 
 +root@debian11:~# netstat -i 
 +-bash: netstat: command not found 
 + 
 +root@debian11:~# apt -y install net-tools 
 + 
 +root@debian11:~# netstat -i 
 +Kernel Interface table 
 +Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg 
 +ens18     1500     7861      0      0 0          7299      0      0      0 BMRU 
 +lo       65536       82      0      0 0            82      0      0      0 LRU 
 +</code> 
 + 
 +Les options de cette commande sont : 
 + 
 +<code> 
 +root@debian11:~# netstat --help 
 +usage: netstat [-vWeenNcCF] [<Af>] -r         netstat {-V|--version|-h|--help} 
 +       netstat [-vWnNcaeol] [<Socket> ...] 
 +       netstat { [-vWeenNac] -i | [-cnNe] -M | -s [-6tuw] } 
 + 
 +        -r, --route              display routing table 
 +        -i, --interfaces         display interface table 
 +        -g, --groups             display multicast group memberships 
 +        -s, --statistics         display networking statistics (like SNMP) 
 +        -M, --masquerade         display masqueraded connections 
 + 
 +        -v, --verbose            be verbose 
 +        -W, --wide               don't truncate IP addresses
         -n, --numeric            don't resolve names         -n, --numeric            don't resolve names
 +        --numeric-hosts          don't resolve host names
 +        --numeric-ports          don't resolve port names
 +        --numeric-users          don't resolve user names
 +        -N, --symbolic           resolve hardware names
         -e, --extend             display other/more information         -e, --extend             display other/more information
 +        -p, --programs           display PID/Program name for sockets
 +        -o, --timers             display timers
 +        -c, --continuous         continuous listing
 +
 +        -l, --listening          display listening server sockets
 +        -a, --all                display all sockets (default: connected)
         -F, --fib                display Forwarding Information Base (default)         -F, --fib                display Forwarding Information Base (default)
-        -C, --cache              affiche le cache de routage au lieu de FIB+        -C, --cache              display routing cache instead of FIB 
 +        -Z, --context            display SELinux security context for sockets
  
-  <AF>=Use '-A <af>' or '--<af>'; default: inet +  <Socket>={-t|--tcp} {-u|--udp} {-U|--udplite} {-S|--sctp} {-w|--raw} 
-  Liste les familles d'adresses possibles (supportant le routage):+           {-x|--unix} --ax25 --ipx --netrom 
 +  <AF>=Use '-6|-4' or '-A <af>' or '--<af>'; default: inet 
 +  List of possible address families (which support routing):
     inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25)      inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25) 
     netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP)      netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP) 
Ligne 804: Ligne 1378:
 </code> </code>
  
-Vous pouvez aussi utiliser la commande **netstat** pour afficher la table de routage de la machine :+====2.3 - traceroute==== 
 + 
 +La commande ping est à la base de la commande **traceroute**. Cette commande sert à découvrir la route empruntée pour accéder à un site donné :
  
 <code> <code>
-root@debian6:~# netstat -nr +root@debian11:~# traceroute www.free.fr 
-Table de routage IP du noyau +traceroute to www.free.fr (212.27.48.10), 30 hops max, 60 byte packets 
-Destination     Passerelle      Genmask         Indic   MSS Fenêtre irtt Iface +  10.0.2.1 (10.0.2.1)  0.476 ms  0.440 ms  0.419 ms 
-192.168.1.0     192.168.1.2     255.255.255.0   UG        0 0          0 eth0 + 2  51.68.180.253 (51.68.180.253)  2.730 ms  2.786 ms  2.927 ms 
-10.0.2.0        0.0.0.0         255.255.255.0   U         0 0          eth0 +  10.161.41.253 (10.161.41.253)  0.315 ms 10.161.41.252 (10.161.41.252)  0.293 ms  0.274 ms 
-0.0.0.0         10.0.2.2        0.0.0.0         UG        0 0          0 eth0+ 4  10.17.242.66 (10.17.242.66)  0.467 ms 10.17.242.62 (10.17.242.62)  0.620 ms 10.17.242.66 (10.17.242.66)  0.795 ms 
 + 5  10.73.40.38 (10.73.40.38)  0.189 ms  2.403 ms 10.73.40.42 (10.73.40.42)  2.339 ms 
 +  10.73.249.68 (10.73.249.68)  4.894 ms * * 
 +  fra-fr5-sbb1-nc5.de.eu (91.121.215.116)  1.909 ms  1.491 ms fra-fr5-sbb2-nc5.de.eu (94.23.122.246)  1.475 ms 
 +  be101.sbg-g1-nc5.fr.eu (94.23.122.136)  4.182 ms be101.sbg-g2-nc5.fr.eu (91.121.215.196)  4.504 ms  4.918 ms 
 +  be103.par-gsw-sbb1-nc5.fr.eu (91.121.215.219)  10.471 ms be103.par-th2-sbb1-nc5.fr.eu (94.23.122.139)  10.448 ms  10.198 ms 
 +10  10.200.2.65 (10.200.2.65)  10.174 ms 10.200.2.71 (10.200.2.71)  10.211 ms 10.200.2.65 (10.200.2.65)  10.111 ms 
 +11  * * * 
 +12  194.149.166.61 (194.149.166.61)  10.289 ms *  10.111 ms 
 +13  * * * 
 +14  * * * 
 +15  * * * 
 +16  * * * 
 +17  * * * 
 +18  * * * 
 +19  * * * 
 +20  * * * 
 +21  * * * 
 +22  * * * 
 +23  * * * 
 +24  * * * 
 +25  * * * 
 +26  * * * 
 +27  * * * 
 +28  * * * 
 +29  * * * 
 +30  * * *
 </code> </code>
  
-La table issue de la commande **netstat -nr** indique les informations suivantes:+Les options de cette commande sont :
  
-  * La champ **MSS** indique la taille maximale des segments TCP sur la route+<code> 
-  * Le champ **Window** indique la taille de la fenêtre sur cette route+root@debian11:~# traceroute --help 
-  * Le champ **irrt** indique le paramètre IRRT pour la route.+Usage: 
 +  traceroute [ -46dFITnreAUDV ] [ -f first_ttl ] [ -g gate,... ] [ -i device ] [ -m max_ttl ] [ -N squeries ] [ -p port ] [ -t tos ] [ -l flow_label ] [ -w MAX,HERE,NEAR ] [ -q nqueries ] [ -s src_addr ] [ -z sendwait ] [ --fwmark=num ] host [ packetlen ] 
 +Options: 
 +  -4                          Use IPv4 
 +  -6                          Use IPv6 
 +  -d  --debug                 Enable socket level debugging 
 +  -F  --dont-fragment         Do not fragment packets 
 +  -f first_ttl  --first=first_ttl 
 +                              Start from the first_ttl hop (instead from 1) 
 +  -g gate,...  --gateway=gate,... 
 +                              Route packets through the specified gateway 
 +                              (maximum 8 for IPv4 and 127 for IPv6) 
 +  -I  --icmp                  Use ICMP ECHO for tracerouting 
 +  -T  --tcp                   Use TCP SYN for tracerouting (default port is 80) 
 +  -i device  --interface=device 
 +                              Specify a network interface to operate with 
 +  -m max_ttl  --max-hops=max_ttl 
 +                              Set the max number of hops (max TTL to be 
 +                              reached). Default is 30 
 +  -N squeries  --sim-queries=squeries 
 +                              Set the number of probes to be tried 
 +                              simultaneously (default is 16) 
 +  -n                          Do not resolve IP addresses to their domain names 
 +  -p port  --port=port        Set the destination port to use. It is either 
 +                              initial udp port value for "default" method 
 +                              (incremented by each probedefault is 33434), or 
 +                              initial seq for "icmp" (incremented as well, 
 +                              default from 1), or some constant destination 
 +                              port for other methods (with default of 80 for 
 +                              "tcp", 53 for "udp", etc.) 
 +  -t tos  --tos=tos           Set the TOS (IPv4 type of service) or TC (IPv6 
 +                              traffic class) value for outgoing packets 
 +  -l flow_label  --flowlabel=flow_label 
 +                              Use specified flow_label for IPv6 packets 
 +  -w MAX,HERE,NEAR  --wait=MAX,HERE,NEAR 
 +                              Wait for a probe no more than HERE (default 3) 
 +                              times longer than a response from the same hop, 
 +                              or no more than NEAR (default 10) times than some 
 +                              next hop, or MAX (default 5.0) seconds (float 
 +                              point values allowed too) 
 +  -q nqueries  --queries=nqueries 
 +                              Set the number of probes per each hopDefault is 
 +                              3 
 +  -r                          Bypass the normal routing and send directly to a 
 +                              host on an attached network 
 +  -s src_addr  --source=src_addr 
 +                              Use source src_addr for outgoing packets 
 +  -z sendwait  --sendwait=sendwait 
 +                              Minimal time interval between probes (default 0). 
 +                              If the value is more than 10, then it specifies a 
 +                              number in milliseconds, else it is a number of 
 +                              seconds (float point values allowed too) 
 +  -e  --extensions            Show ICMP extensions (if present), including MPLS 
 +  -A  --as-path-lookups       Perform AS path lookups in routing registries and 
 +                              print results directly after the corresponding 
 +                              addresses 
 +  -M name  --module=name      Use specified module (either builtin or external) 
 +                              for traceroute operations. Most methods have 
 +                              their shortcuts (`-I' means `-M icmp' etc.) 
 +  -O OPTS,...  --options=OPTS,... 
 +                              Use module-specific option OPTS for the 
 +                              traceroute module. Several OPTS allowed, 
 +                              separated by comma. If OPTS is "help", print info 
 +                              about available options 
 +  --sport=num                 Use source port num for outgoing packets. Implies 
 +                              `-N 1' 
 +  --fwmark=num                Set firewall mark for outgoing packets 
 +  -U  --udp                   Use UDP to particular port for tracerouting 
 +                              (instead of increasing the port per each probe), 
 +                              default port is 53 
 +  -UL                         Use UDPLITE for tracerouting (default dest port 
 +                              is 53) 
 +  -D  --dccp                  Use DCCP Request for tracerouting (default port 
 +                              is 33434) 
 +  -P prot  --protocol=prot    Use raw packet of protocol prot for tracerouting 
 +  --mtu                       Discover MTU along the path being traced. Implies 
 +                              `-F -N 1' 
 +  --back                      Guess the number of hops in the backward path and 
 +                              print if it differs 
 +  -V  --version               Print version info and exit 
 +  --help                      Read this help and exit
  
-===Activer/désactiver le routage sur le serveur===+Arguments: 
 ++     host          The host to traceroute to 
 +      packetlen     The full packet length (default is the length of an IP 
 +                    header plus 40). Can be ignored or increased to a minimal 
 +                    allowed value 
 +</code>
  
-Pour activer le routage sur le serveur, il convient d'activer la retransmission des paquets:+=====LAB #3 - Connexions à Distance===== 
 + 
 +==== 3.1 - Telnet ==== 
 + 
 +La commande **telnet** est utilisée pour établir une connexion à distance avec un serveur telnet : 
 + 
 +<file> 
 +  # telnet numero_ip 
 +</file> 
 + 
 +<WRAP center round important 60%> 
 +**Important** - Le service telnet revient à une redirection des canaux standards d'entrée et de sortie. Notez que la connexion n'est **pas** sécurisée. Pour fermer la connexion, il faut saisir la commande **exit**. La commande telnet n'offre pas de services de transfert de fichiers. Pour cela, il convient d'utiliser la command **ftp**. 
 +</WRAP> 
 + 
 +Les options de cette commande sont :
  
 <code> <code>
-root@debian6:~# echo 1 > /proc/sys/net/ipv4/ip_forward +root@debian11:~# which telnet 
-root@debian6:~# cat /proc/sys/net/ipv4/ip_forward +/usr/bin/telnet 
-1+root@debian11:~# telnet --help 
 +telnet: invalid option -- '-' 
 +Usage: telnet [-4] [-6] [-8] [-E] [-L] [-a] [-d] [-e char] [-l user] 
 +        [-n tracefile] [ -b addr ] [-r] [host-name [port]]
 </code> </code>
  
-Pour désactiver le routage sur le serveuril convient de désactiver la retransmission des paquets:+==== 3.2 - wget ==== 
 + 
 +La commande **wget** est utilisée pour récupérer un fichier via httphttps ou ftp 
  
 <code> <code>
-root@debian6:~# echo 0 > /proc/sys/net/ipv4/ip_forward +root@debian11:~# wget https://www.dropbox.com/s/wk79lkfr6f12u9j/wget_file.txt 
-root@debian6:~# cat /proc/sys/net/ipv4/ip_forward +--2022-05-03 10:07:50--  https://www.dropbox.com/s/wk79lkfr6f12u9j/wget_file.txt 
 +Resolving www.dropbox.com (www.dropbox.com)... 162.125.67.18, 2620:100:6023:18::a27d:4312 
 +Connecting to www.dropbox.com (www.dropbox.com)|162.125.67.18|:443... connected. 
 +HTTP request sent, awaiting response... 301 Moved Permanently 
 +Location: /s/raw/wk79lkfr6f12u9j/wget_file.txt [following] 
 +--2022-05-03 10:07:51--  https://www.dropbox.com/s/raw/wk79lkfr6f12u9j/wget_file.txt 
 +Reusing existing connection to www.dropbox.com:443. 
 +HTTP request sent, awaiting response... 302 Found 
 +Location: https://uc64dcd84ee4be2a0c2f111bd2ab.dl.dropboxusercontent.com/cd/0/inline/BkjB7WuIg8oRJsAnsjaq0YeQrof8LaM6svUdazV8cmiN5MWJqHVYZlMfbR33nIokof9ZHmK551ixoOU8CgteUybofFdo_vD62VcF-WNi4ACD8o6JsjdD7kiiuge-8mfbD1unwz4UtpyHIuVPQ9sUrh0QNNTVtsj3kcjDJAgEDg-uKQ/file# [following] 
 +--2022-05-03 10:07:51--  https://uc64dcd84ee4be2a0c2f111bd2ab.dl.dropboxusercontent.com/cd/0/inline/BkjB7WuIg8oRJsAnsjaq0YeQrof8LaM6svUdazV8cmiN5MWJqHVYZlMfbR33nIokof9ZHmK551ixoOU8CgteUybofFdo_vD62VcF-WNi4ACD8o6JsjdD7kiiuge-8mfbD1unwz4UtpyHIuVPQ9sUrh0QNNTVtsj3kcjDJAgEDg-uKQ/file 
 +Resolving uc64dcd84ee4be2a0c2f111bd2ab.dl.dropboxusercontent.com (uc64dcd84ee4be2a0c2f111bd2ab.dl.dropboxusercontent.com)... 162.125.67.15, 2620:100:6023:15::a27d:430f 
 +Connecting to uc64dcd84ee4be2a0c2f111bd2ab.dl.dropboxusercontent.com (uc64dcd84ee4be2a0c2f111bd2ab.dl.dropboxusercontent.com)|162.125.67.15|:443... connected. 
 +HTTP request sent, awaiting response... 200 OK 
 +Length: 46 [text/plain] 
 +Saving to: ‘wget_file.txt’ 
 + 
 +wget_file.txt         100%[=======================>     46  --.-KB/   in 0s       
 + 
 +2022-05-03 10:07:51 (26.8 MB/s) - ‘wget_file.txt’ saved [46/46] 
 + 
 +root@debian11:~# cat wget_file.txt  
 +This is a file retrieved by the wget command.
 </code> </code>
  
-=====Configuration du Réseau sous RHEL/CentOS 5 et 6=====+Les options de cette commande sont : 
 + 
 +<code> 
 +root@debian11:~# wget --help | more 
 +GNU Wget 1.21, a non-interactive network retriever. 
 +Usage: wget [OPTION]... [URL]... 
 + 
 +Mandatory arguments to long options are mandatory for short options too. 
 + 
 +Startup: 
 +  -V,  --version                   display the version of Wget and exit 
 +  -h,  --help                      print this help 
 +  -b,  --background                go to background after startup 
 +  -e,  --execute=COMMAND           execute a `.wgetrc'-style command 
 + 
 +Logging and input file: 
 +  -o,  --output-file=FILE          log messages to FILE 
 +  -a,  --append-output=FILE        append messages to FILE 
 +  -d,  --debug                     print lots of debugging information 
 +  -q,  --quiet                     quiet (no output) 
 +  -v,  --verbose                   be verbose (this is the default) 
 +  -nv, --no-verbose                turn off verboseness, without being quiet 
 +       --report-speed=TYPE         output bandwidth as TYPE.  TYPE can be bits 
 +  -i,  --input-file=FILE           download URLs found in local or external FILE 
 +  -F,  --force-html                treat input file as HTML 
 +  -B,  --base=URL                  resolves HTML input-file links (-i -F) 
 +                                     relative to URL 
 +       --config=FILE               specify config file to use 
 +       --no-config                 do not read any config file 
 +       --rejected-log=FILE         log reasons for URL rejection to FILE 
 + 
 +Download: 
 +  -t,  --tries=NUMBER              set number of retries to NUMBER (0 unlimits) 
 +       --retry-connrefused         retry even if connection is refused 
 +       --retry-on-http-error=ERRORS    comma-separated list of HTTP errors to retry 
 +  -O,  --output-document=FILE      write documents to FILE 
 +  -nc, --no-clobber                skip downloads that would download to 
 +                                     existing files (overwriting them) 
 +       --no-netrc                  don't try to obtain credentials from .netrc 
 +  -c,  --continue                  resume getting a partially-downloaded file 
 +       --start-pos=OFFSET          start downloading from zero-based position OFFSET 
 +       --progress=TYPE             select progress gauge type 
 +       --show-progress             display the progress bar in any verbosity mode 
 +  -N,  --timestamping              don't re-retrieve files unless newer than 
 +                                     local 
 +       --no-if-modified-since      don't use conditional if-modified-since get 
 +                                     requests in timestamping mode 
 +       --no-use-server-timestamps  don't set the local file's timestamp by 
 +                                     the one on the server 
 +  -S,  --server-response           print server response 
 +       --spider                    don't download anything 
 +  -T,  --timeout=SECONDS           set all timeout values to SECONDS 
 +       --dns-timeout=SECS          set the DNS lookup timeout to SECS 
 +       --connect-timeout=SECS      set the connect timeout to SECS 
 +       --read-timeout=SECS         set the read timeout to SECS 
 +  -w,  --wait=SECONDS              wait SECONDS between retrievals 
 +                                     (applies if more then 1 URL is to be retrieved) 
 +--More-- 
 +[q] 
 +</code> 
 + 
 +==== 3.3 - ftp ==== 
 + 
 +<WRAP center round important 60%> 
 +**Important** - Si la commande **ftp** n'est pas installée sous Debian 11, installez-le à l'aide de la commande **apt install ftp** en tant que root. 
 +</WRAP> 
 + 
 +La commande **ftp** est utilisée pour le transfert de fichiers. Une fois connecté, il convient d'utiliser la commande **help** pour afficher la liste des commandes disponibles : 
 + 
 +<code> 
 +ftp> help 
 +Commands may be abbreviated.  Commands are: 
 + 
 +!               dir             mdelete         qc              site 
 +$               disconnect      mdir            sendport        size 
 +account         exit            mget            put             status 
 +append          form            mkdir           pwd             struct 
 +ascii           get             mls             quit            system 
 +bell            glob            mode            quote           sunique 
 +binary          hash            modtime         recv            tenex 
 +bye             help            mput            reget           tick 
 +case            idle            newer           rstatus         trace 
 +cd              image           nmap            rhelp           type 
 +cdup            ipany           nlist           rename          user 
 +chmod           ipv4            ntrans          reset           umask 
 +close           ipv6            open            restart         verbose 
 +cr              lcd             prompt          rmdir           ? 
 +delete          ls              passive         runique 
 +debug           macdef          proxy           send 
 +ftp>  
 +</code> 
 + 
 +Le caractère **!** permet d'exécuter une commande sur la machine cliente 
 + 
 +<code> 
 +ftp> !pwd 
 +/root 
 +</code> 
 + 
 +Pour transférer un fichier vers le serveur, il convient d'utiliser la commande **put** : 
 + 
 +<file> 
 +ftp> put nom_fichier_local nom_fichier_distant 
 +</file> 
 + 
 +Vous pouvez également transférer plusieurs fichiers à la fois grâce à la commande **mput**. Dans ce cas précis, il convient de saisir la commande suivante: 
 + 
 +<file> 
 +ftp> mput nom*.* 
 +</file> 
 + 
 +Pour transférer un fichier du serveur, il convient d'utiliser la commande **get** : 
 + 
 +<file> 
 +ftp> get nom_fichier 
 +</file> 
 + 
 +Vous pouvez également transférer plusieurs fichiers à la fois grâce à la commande **mget** ( voir la commande **mput** ci-dessus ). 
 + 
 +Pour supprimer un fichier sur le serveur, il convient d'utiliser la commande **del** : 
 + 
 +<file> 
 +ftp> del nom_fichier 
 +</file> 
 + 
 +Pour fermer la session, il convient d'utiliser la commande **quit** : 
 + 
 +<code> 
 +ftp> quit 
 +root@debian11:~#  
 +</code> 
 + 
 +====3.4 - SSH==== 
 + 
 +===Présentation=== 
 + 
 +La commande **[[wpfr>Ssh|ssh]]** est le successeur et la remplaçante de la commande **[[wpfr>Rlogin|rlogin]]**. Il permet d'établir des connexions sécurisées avec une machine distante. SSH comporte cinq acteurs : 
 + 
 +  * Le **serveur SSH** 
 +    * le démon sshd, qui s'occupe des authentifications et autorisations des clients,  
 +  * Le **client SSH** 
 +    * ssh ou scp, qui assure la connexion et le dialogue avec le serveur, 
 +  * La **session** qui représente la connexion courante et qui commence juste après l'authentification réussie, 
 +  * Les **clefs** 
 +    * **Couple de clef utilisateur asymétriques** et persistantes qui assurent l'identité d'un utilisateur et qui sont stockés sur disque dur, 
 +    * **Clef hôte asymétrique et persistante** garantissant l'identité du serveur er qui est conservé sur disque dur 
 +    * **Clef serveur asymétrique et temporaire** utilisée par le protocole SSH1 qui sert au chiffrement de la clé de session, 
 +    * **Clef de session symétrique qui est générée aléatoirement** et qui permet le chiiffrement de la communication entre le client et le serveur. Elle est détruite en fin de session. SSH-1 utilise une seule clef tandis que SSH-2 utilise une clef par direction de la communication, 
 +  * La **base de données des hôtes connus** qui stocke les clés des connexions précédentes. 
 + 
 +SSH fonctionne de la manière suivante pour la la mise en place d'un canal sécurisé: 
 + 
 +  * Le client contacte le serveur sur son port 22, 
 +  * Les client et le serveur échangent leur version de SSH. En cas de non-compatibilité de versions, l'un des deux met fin au processus, 
 +  * Le serveur SSH s'identifie auprès du client en lui fournissant : 
 +    * Sa clé hôte, 
 +    * Sa clé serveur, 
 +    * Une séquence aléatoire de huit octets à inclure dans les futures réponses du client, 
 +    * Une liste de méthodes de chiffrage, compression et authentification, 
 +  * Le client et le serveur produisent un identifiant identique, un haché MD5 long de 128 bits contenant la clé hôte, la clé serveur et la séquence aléatoire, 
 +  * Le client génère sa clé de session symétrique et la chiffre deux fois de suite, une fois avec la clé hôte du serveur et la deuxième fois avec la clé serveur. Le client envoie cette clé au serveur accompagnée de la séquence aléatoire et un choix d'algorithmes supportés, 
 +  * Le serveur déchiffre la clé de session, 
 +  * Le client et le serveur mettent en place le canal sécurisé. 
 + 
 +==SSH-1== 
 + 
 +SSH-1 utilise une paire de clefs de type RSA1. Il assure l'intégrité des données par une **[[wpfr>Contrôle_de_redondance_cyclique|Contrôle de Redondance Cyclique]]** (CRC) et est un bloc dit **monolithique**. 
 + 
 +Afin de s'identifier, le client essaie chacune des six méthodes suivantes : 
 + 
 +  * **Kerberos**, 
 +  * **Rhosts**, 
 +  * **%%RhostsRSA%%**, 
 +  * Par **clef asymétrique**, 
 +  * **TIS**, 
 +  * Par **mot de passe**. 
 + 
 +==SSH-2== 
 + 
 +SSH-2 utilise **DSA** ou **RSA**. Il assure l'intégrité des données par l'algorithme **HMAC**. SSH-2 est organisé en trois **couches** : 
 + 
 +  * **SSH-TRANS** – Transport Layer Protocol, 
 +  * **SSH-AUTH** – Authentification Protocol, 
 +  * **SSH-CONN** – Connection Protocol. 
 + 
 +SSH-2 diffère de SSH-1 essentiellement dans la phase authentification.  
 + 
 +Trois méthodes d'authentification : 
 + 
 +  * Par **clef asymétrique**, 
 +    * Identique à SSH-1 sauf avec l'algorithme DSA, 
 +  * **%%RhostsRSA%%**, 
 +  * Par **mot de passe**. 
 + 
 +Les options de cette commande sont : 
 + 
 +<code> 
 +root@debian11:~# ssh --help 
 +unknown option -- - 
 +usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] 
 +           [-b bind_address] [-c cipher_spec] [-D [bind_address:]port] 
 +           [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11] 
 +           [-i identity_file] [-J [user@]host[:port]] [-L address] 
 +           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] 
 +           [-Q query_option] [-R address] [-S ctl_path] [-W host:port] 
 +           [-w local_tun[:remote_tun]] destination [command] 
 +</code> 
 + 
 +===Authentification par mot de passe=== 
 + 
 +L'utilisateur fournit un mot de passe au client ssh. Le client ssh le transmet de façon sécurisée au serveur ssh puis  le serveur vérifie le mot de passe et l'accepte ou non. 
 + 
 +Avantage: 
 +  * Aucune configuration de clef asymétrique n'est nécessaire. 
 + 
 +Inconvénients: 
 +  * L'utilisateur doit fournir à chaque connexion un identifiant et un mot de passe, 
 +  * Moins sécurisé qu'un système par clef asymétrique. 
 + 
 +===Authentification par clef asymétrique=== 
 + 
 +  * Le **client** envoie au serveur une requête d'authentification par clé asymétrique qui contient le module de la clé à utiliser, 
 +  * Le **serveur** recherche une correspondance pour ce module dans le fichier des clés autorisés **~/.ssh/authorized_keys**, 
 +    * Dans le cas où une correspondance n'est pas trouvée, le serveur met fin à la communication, 
 +    * Dans le cas contraire le serveur génère une chaîne aléatoire de 256 bits appelée un **challenge** et la chiffre avec la **clé publique du client**, 
 +  * Le **client** reçoit le challenge et le décrypte avec la partie privée de sa clé. Il combine le challenge avec l'identifiant de session et chiffre le résultat. Ensuite il envoie le résultat chiffré au serveur. 
 +  * Le **serveur** génère le même haché et le compare avec celui reçu du client. Si les deux hachés sont identiques, l'authentification est réussie. 
 + 
 +===Configuration du Serveur=== 
 + 
 +La configuration du serveur s'effectue dans le fichier **/etc/ssh/sshd_config** : 
 + 
 +<code> 
 +root@debian11:~# cat /etc/ssh/sshd_config 
 +#       $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $ 
 + 
 +# This is the sshd server system-wide configuration file.  See 
 +# sshd_config(5) for more information. 
 + 
 +# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin 
 + 
 +# The strategy used for options in the default sshd_config shipped with 
 +# OpenSSH is to specify options with their default value where 
 +# possible, but leave them commented.  Uncommented options override the 
 +# default value. 
 + 
 +Include /etc/ssh/sshd_config.d/*.conf 
 + 
 +#Port 22 
 +#AddressFamily any 
 +#ListenAddress 0.0.0.0 
 +#ListenAddress :: 
 + 
 +#HostKey /etc/ssh/ssh_host_rsa_key 
 +#HostKey /etc/ssh/ssh_host_ecdsa_key 
 +#HostKey /etc/ssh/ssh_host_ed25519_key 
 + 
 +# Ciphers and keying 
 +#RekeyLimit default none 
 + 
 +# Logging 
 +#SyslogFacility AUTH 
 +#LogLevel INFO 
 + 
 +# Authentication: 
 + 
 +#LoginGraceTime 2m 
 +PermitRootLogin yes  
 +#StrictModes yes 
 +#MaxAuthTries 6 
 +#MaxSessions 10 
 + 
 +#PubkeyAuthentication yes 
 + 
 +# Expect .ssh/authorized_keys2 to be disregarded by default in future. 
 +#AuthorizedKeysFile     .ssh/authorized_keys .ssh/authorized_keys2 
 + 
 +#AuthorizedPrincipalsFile none 
 + 
 +#AuthorizedKeysCommand none 
 +#AuthorizedKeysCommandUser nobody 
 + 
 +# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts 
 +#HostbasedAuthentication no 
 +# Change to yes if you don't trust ~/.ssh/known_hosts for 
 +# HostbasedAuthentication 
 +#IgnoreUserKnownHosts no 
 +# Don't read the user's ~/.rhosts and ~/.shosts files 
 +#IgnoreRhosts yes 
 + 
 +# To disable tunneled clear text passwords, change to no here! 
 +#PasswordAuthentication yes 
 +#PermitEmptyPasswords no 
 + 
 +# Change to yes to enable challenge-response passwords (beware issues with 
 +# some PAM modules and threads) 
 +ChallengeResponseAuthentication no 
 + 
 +# Kerberos options 
 +#KerberosAuthentication no 
 +#KerberosOrLocalPasswd yes 
 +#KerberosTicketCleanup yes 
 +#KerberosGetAFSToken no 
 + 
 +# GSSAPI options 
 +#GSSAPIAuthentication no 
 +#GSSAPICleanupCredentials yes 
 +#GSSAPIStrictAcceptorCheck yes 
 +#GSSAPIKeyExchange no 
 + 
 +# Set this to 'yes' to enable PAM authentication, account processing, 
 +# and session processing. If this is enabled, PAM authentication will 
 +# be allowed through the ChallengeResponseAuthentication and 
 +# PasswordAuthentication.  Depending on your PAM configuration, 
 +# PAM authentication via ChallengeResponseAuthentication may bypass 
 +# the setting of "PermitRootLogin without-password"
 +# If you just want the PAM account and session checks to run without 
 +# PAM authentication, then enable this but set PasswordAuthentication 
 +# and ChallengeResponseAuthentication to 'no'
 +UsePAM yes 
 + 
 +#AllowAgentForwarding yes 
 +#AllowTcpForwarding yes 
 +#GatewayPorts no 
 +X11Forwarding yes 
 +#X11DisplayOffset 10 
 +#X11UseLocalhost yes 
 +#PermitTTY yes 
 +PrintMotd no 
 +#PrintLastLog yes 
 +#TCPKeepAlive yes 
 +#PermitUserEnvironment no 
 +#Compression delayed 
 +#ClientAliveInterval 0 
 +#ClientAliveCountMax 3 
 +#UseDNS no 
 +#PidFile /var/run/sshd.pid 
 +#MaxStartups 10:30:100 
 +#PermitTunnel no 
 +#ChrootDirectory none 
 +#VersionAddendum none 
 + 
 +# no default banner path 
 +#Banner none 
 + 
 +# Allow client to pass locale environment variables 
 +AcceptEnv LANG LC_* 
 + 
 +# override default of no subsystems 
 +Subsystem       sftp    /usr/lib/openssh/sftp-server 
 + 
 +# Example of overriding settings on a per-user basis 
 +#Match User anoncvs 
 +#       X11Forwarding no 
 +#       AllowTcpForwarding no 
 +#       PermitTTY no 
 +#       ForceCommand cvs server 
 +</code> 
 + 
 +Pour ôter les lignes de commentaires dans ce fichier, utilisez la commande suivante : 
 + 
 +<code> 
 +root@debian11:~# cd /tmp ; grep -E -v '^(#|$)'  /etc/ssh/sshd_config > sshd_config 
 +root@debian11:/tmp# cat sshd_config 
 +Include /etc/ssh/sshd_config.d/*.conf 
 +PermitRootLogin yes  
 +ChallengeResponseAuthentication no 
 +UsePAM yes 
 +X11Forwarding yes 
 +PrintMotd no 
 +AcceptEnv LANG LC_* 
 +Subsystem       sftp    /usr/lib/openssh/sftp-server 
 +</code> 
 + 
 +Pour sécuriser le serveur ssh, ajoutez ou modifiez les directives suivantes : 
 + 
 +<file> 
 +AllowGroups adm 
 +Banner /etc/issue.net 
 +HostbasedAuthentication no 
 +IgnoreRhosts yes 
 +LoginGraceTime 60 
 +LogLevel INFO 
 +PermitEmptyPasswords no 
 +PermitRootLogin no 
 +PrintLastLog yes 
 +Protocol 2 
 +StrictModes yes 
 +X11Forwarding no 
 +</file> 
 + 
 +Votre fichier ressemblera à celui-ci : 
 + 
 +<code> 
 +root@debian11:/tmp# vi sshd_config 
 +root@debian11:/tmp# cat sshd_config 
 +AllowGroups adm 
 +Banner /etc/issue.net 
 +HostbasedAuthentication no 
 +IgnoreRhosts yes 
 +LoginGraceTime 60 
 +LogLevel INFO 
 +PermitEmptyPasswords no 
 +PermitRootLogin no 
 +PrintLastLog yes 
 +Protocol 2 
 +StrictModes yes 
 +X11Forwarding no 
 +Include /etc/ssh/sshd_config.d/*.conf 
 +ChallengeResponseAuthentication no 
 +UsePAM yes 
 +PrintMotd no 
 +AcceptEnv LANG LC_* 
 +Subsystem       sftp    /usr/lib/openssh/sftp-server 
 +</code> 
 + 
 +Renommez le fichier **/etc/ssh/sshd_config** en **/etc/ssh/sshd_config.old** : 
 + 
 +<code> 
 +[root@centos11 tmp]# cp /etc/ssh/sshd_config /etc/ssh/sshd_config.old 
 +</code> 
 + 
 +Copiez le fichier **/tmp/sshd_config** vers **/etc/ssh/** : 
 + 
 +<code> 
 +root@debian11:/tmp# cp /tmp/sshd_config /etc/ssh 
 +</code> 
 + 
 +Redémarrez le service sshd : 
 + 
 +<code> 
 +root@debian11:/tmp# systemctl restart sshd 
 +root@debian11:/tmp# systemctl status sshd 
 +● ssh.service - OpenBSD Secure Shell server 
 +     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled) 
 +     Active: active (running) since Tue 2022-05-03 11:01:24 CEST; 7s ago 
 +       Docs: man:sshd(8) 
 +             man:sshd_config(5) 
 +    Process: 4885 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS) 
 +   Main PID: 4888 (sshd) 
 +      Tasks: 1 (limit: 4632) 
 +     Memory: 1.1M 
 +        CPU: 24ms 
 +     CGroup: /system.slice/ssh.service 
 +             └─4888 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups 
 + 
 +May 03 11:01:24 debian11.ittraining.loc sshd[4888]: Server listening on 0.0.0.0 port > 
 +May 03 11:01:24 debian11.ittraining.loc systemd[1]: Stopping OpenBSD Secure Shell ser> 
 +May 03 11:01:24 debian11.ittraining.loc sshd[4888]: Server listening on :: port 22. 
 +May 03 11:01:24 debian11.ittraining.loc systemd[1]: ssh.service: Succeeded. 
 +May 03 11:01:24 debian11.ittraining.loc systemd[1]: Stopped OpenBSD Secure Shell serv> 
 +May 03 11:01:24 debian11.ittraining.loc systemd[1]: Starting OpenBSD Secure Shell ser> 
 +May 03 11:01:24 debian11.ittraining.loc systemd[1]: Started OpenBSD Secure Shell serv> 
 +lines 1-20/20 (END) 
 +[q] 
 +</code> 
 + 
 +Mettez l'utilisateur **trainee** dans le groupe **adm** : 
 + 
 +<code> 
 +root@debian11:/tmp# groups trainee 
 +trainee : trainee cdrom floppy audio dip src video plugdev netdev lpadmin scanner 
 +root@debian11:/tmp# usermod -aG adm trainee 
 +root@debian11:/tmp# groups trainee 
 +trainee : trainee adm cdrom floppy audio dip src video plugdev netdev lpadmin scanner 
 +</code> 
 + 
 +Pour générer les clefs du serveur, saisissez la commande suivante en tant que **root**. Notez que la passphrase doit être **vide**. 
 + 
 +<code> 
 +root@debian11:/tmp# ssh-keygen -t dsa 
 +Generating public/private dsa key pair. 
 +Enter file in which to save the key (/root/.ssh/id_dsa): /etc/ssh/ssh_host_dsa_key 
 +Enter passphrase (empty for no passphrase):  
 +Enter same passphrase again:  
 +Your identification has been saved in /etc/ssh/ssh_host_dsa_key 
 +Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub 
 +The key fingerprint is: 
 +SHA256:emwF3Bq/2H+JGk5dNXgKBLTtbuC04byZmFJDxkUxso4 root@debian11.ittraining.loc 
 +The key's randomart image is: 
 ++---[DSA 1024]----+ 
 +|       .o*o.     | 
 +|       .oo=   
 +|      ..=..o . o.| 
 +|      o+ =. . o..| 
 +|     Eo.S+o. ..  | 
 +|       ==+=o .   | 
 +|      o *==o.. . | 
 +|     . ooo=o. o  | 
 +|      .o +o...   | 
 ++----[SHA256]-----+ 
 +root@debian11:/tmp# ssh-keygen -t rsa 
 +Generating public/private rsa key pair. 
 +Enter file in which to save the key (/root/.ssh/id_rsa): /etc/ssh/ssh_host_rsa_key 
 +/etc/ssh/ssh_host_rsa_key already exists. 
 +Overwrite (y/n)? y 
 +Enter passphrase (empty for no passphrase):  
 +Enter same passphrase again:  
 +Your identification has been saved in /etc/ssh/ssh_host_rsa_key 
 +Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub 
 +The key fingerprint is: 
 +SHA256:xrkpZ6lfF1hQIZEYJuH1L+Z2QGhQCf8Xwt9HPwTuT7Y root@debian11.ittraining.loc 
 +The key's randomart image is: 
 ++---[RSA 3072]----+ 
 +|      =+=+++oo   | 
 +|     . *o+.o. .  | 
 +|      . + = o. ..| 
 +|       o + *.o...| 
 +|        S * =..+o| 
 +|       . * + .+.o| 
 +|      . * + o  E | 
 +|       = o o     | 
 +|      ...        | 
 ++----[SHA256]-----+ 
 +root@debian11:/tmp# ssh-keygen -t ecdsa 
 +Generating public/private ecdsa key pair. 
 +Enter file in which to save the key (/root/.ssh/id_ecdsa): /etc/ssh/ssh_host_ecdsa_key 
 +/etc/ssh/ssh_host_ecdsa_key already exists. 
 +Overwrite (y/n)? y 
 +Enter passphrase (empty for no passphrase):  
 +Enter same passphrase again:  
 +Your identification has been saved in /etc/ssh/ssh_host_ecdsa_key 
 +Your public key has been saved in /etc/ssh/ssh_host_ecdsa_key.pub 
 +The key fingerprint is: 
 +SHA256:38O9lqa1AHvviceNEbQ1AOUMspkYBpIpLlu/U05ymqo root@debian11.ittraining.loc 
 +The key's randomart image is: 
 ++---[ECDSA 256]---+ 
 +|   .o..o . ooo.  | 
 +| . o. . o = + ...| 
 +|. .    . +   + o.| 
 +|...           
 +|.o .    S .    . | 
 +|.   o +  . = ..  | 
 +|        o *.o= | 
 +|    = .    . *B+.| 
 +|E... .      o**  | 
 ++----[SHA256]-----+ 
 +root@debian11:/tmp# ssh-keygen -t ed25519 
 +Generating public/private ed25519 key pair. 
 +Enter file in which to save the key (/root/.ssh/id_ed25519): /etc/ssh/ssh_host_ed25519_key 
 +/etc/ssh/ssh_host_ed25519_key already exists. 
 +Overwrite (y/n)? y 
 +Enter passphrase (empty for no passphrase):  
 +Enter same passphrase again:  
 +Your identification has been saved in /etc/ssh/ssh_host_ed25519_key 
 +Your public key has been saved in /etc/ssh/ssh_host_ed25519_key.pub 
 +The key fingerprint is: 
 +SHA256:f8arQ5MBRGNJoj4eARYapvxf/MLxFFMZcKf1eLkgeow root@debian11.ittraining.loc 
 +The key's randomart image is: 
 ++--[ED25519 256]--+ 
 +|..+.  .+*o.+oo   | 
 +|++ . . oo.o.+ o .| 
 +|o.  o    + o o + | 
 +|  .. ..   B . o .| 
 +|   .+  +SE =   . | 
 +|   ..oo =.=.     | 
 +|    .. o +..+    | 
 +|        . .o .   | 
 +|          .o.    | 
 ++----[SHA256]-----+ 
 +</code> 
 + 
 +Les clefs publiques générées possèdent l'extension **.pub**. Les clefs privées n'ont pas d'extension : 
 + 
 +<code> 
 +root@debian11:/tmp# ls /etc/ssh 
 +moduli        sshd_config.d         ssh_host_ecdsa_key        ssh_host_rsa_key 
 +ssh_config    sshd_config.old       ssh_host_ecdsa_key.pub    ssh_host_rsa_key.pub 
 +ssh_config.d  ssh_host_dsa_key      ssh_host_ed25519_key 
 +sshd_config   ssh_host_dsa_key.pub  ssh_host_ed25519_key.pub 
 +</code> 
 + 
 +Re-démarrez ensuite le service sshd : 
 + 
 +<code> 
 +root@debian11:/tmp# systemctl restart sshd.service 
 +root@debian11:/tmp# systemctl status sshd.service 
 +● ssh.service - OpenBSD Secure Shell server 
 +     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled) 
 +     Active: active (running) since Tue 2022-05-03 11:30:09 CEST; 8s ago 
 +       Docs: man:sshd(8) 
 +             man:sshd_config(5) 
 +    Process: 4942 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS) 
 +   Main PID: 4943 (sshd) 
 +      Tasks: 1 (limit: 4632) 
 +     Memory: 1.1M 
 +        CPU: 24ms 
 +     CGroup: /system.slice/ssh.service 
 +             └─4943 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups 
 + 
 +May 03 11:30:09 debian11.ittraining.loc systemd[1]: Starting OpenBSD Secure Shell ser> 
 +May 03 11:30:09 debian11.ittraining.loc sshd[4943]: Server listening on 0.0.0.0 port > 
 +May 03 11:30:09 debian11.ittraining.loc sshd[4943]: Server listening on :: port 22. 
 +May 03 11:30:09 debian11.ittraining.loc systemd[1]: Started OpenBSD Secure Shell serv> 
 +lines 1-17/17 (END) 
 +[q] 
 +</code> 
 + 
 +===Configuration du Client=== 
 + 
 +Saisissez maintenant les commandes suivantes en tant que **trainee** : 
 + 
 +<WRAP center round important 60%> 
 +**Important** - Lors de la génération des clefs, la passphrase doit être **vide**. 
 +</WRAP> 
 + 
 +<code> 
 +root@debian11:/tmp# exit 
 +logout 
 +trainee@debian11:~$ ssh-keygen -t dsa 
 +Generating public/private dsa key pair. 
 +Enter file in which to save the key (/home/trainee/.ssh/id_dsa):  
 +Created directory '/home/trainee/.ssh'
 +Enter passphrase (empty for no passphrase):  
 +Enter same passphrase again:  
 +Your identification has been saved in /home/trainee/.ssh/id_dsa 
 +Your public key has been saved in /home/trainee/.ssh/id_dsa.pub 
 +The key fingerprint is: 
 +SHA256:WijVQNwc9klBZxW4R8ZY5LwZK08/FaZCkWP0yKNj+20 trainee@debian11.ittraining.loc 
 +The key's randomart image is: 
 ++---[DSA 1024]----+ 
 +|     ooooo=++B=. | 
 +|      .+oo.B*o+ 
 +|      . . +=.=+o | 
 +|     . .  o o +=.| 
 +|    . . S+ ..o= .| 
 +|     . o. o .+ ..| 
 +|      .  .    ...| 
 +|          . .E  .| 
 +|           ...   | 
 ++----[SHA256]-----+ 
 +trainee@debian11:~$ ssh-keygen -t rsa 
 +Generating public/private rsa key pair. 
 +Enter file in which to save the key (/home/trainee/.ssh/id_rsa):  
 +Enter passphrase (empty for no passphrase):  
 +Enter same passphrase again:  
 +Your identification has been saved in /home/trainee/.ssh/id_rsa 
 +Your public key has been saved in /home/trainee/.ssh/id_rsa.pub 
 +The key fingerprint is: 
 +SHA256:r8id4Px97b9t7GMybe7OTaQU5lgaRjsTK/EAyMFdgjo trainee@debian11.ittraining.loc 
 +The key's randomart image is: 
 ++---[RSA 3072]----+ 
 +|     o.=oo+ o    | 
 +|      = .. = +   | 
 +|        . O +  | 
 +|    E      o X . | 
 +|      S   o o .| 
 +|           . o | 
 +|      .    .o..| 
 +|     + + +  .oo*=| 
 +|      =.= .. .XXB| 
 ++----[SHA256]-----+ 
 +trainee@debian11:~$ ssh-keygen -t ecdsa 
 +Generating public/private ecdsa key pair. 
 +Enter file in which to save the key (/home/trainee/.ssh/id_ecdsa):  
 +Enter passphrase (empty for no passphrase):  
 +Enter same passphrase again:  
 +Your identification has been saved in /home/trainee/.ssh/id_ecdsa 
 +Your public key has been saved in /home/trainee/.ssh/id_ecdsa.pub 
 +The key fingerprint is: 
 +SHA256:IL44+ZzExDxBFCt9nZtMgCQB/iuq9UtJC6uq/RhrPvg trainee@debian11.ittraining.loc 
 +The key's randomart image is: 
 ++---[ECDSA 256]---+ 
 +|..o+=o.          | 
 +|.  +.. o .       | 
 +| .. = o +        | 
 +|  .= + + o       | 
 +|  ..B          | 
 +|   O.=           | 
 +| oB.B            | 
 +|o++@ .           | 
 +|X+EoB.           | 
 ++----[SHA256]-----+ 
 +trainee@debian11:~$ ssh-keygen -t ed25519 
 +Generating public/private ed25519 key pair. 
 +Enter file in which to save the key (/home/trainee/.ssh/id_ed25519):  
 +Enter passphrase (empty for no passphrase):  
 +Enter same passphrase again:  
 +Your identification has been saved in /home/trainee/.ssh/id_ed25519 
 +Your public key has been saved in /home/trainee/.ssh/id_ed25519.pub 
 +The key fingerprint is: 
 +SHA256:yQ9mtIx1nK7D1vSZjkkbofXHZsTDp5P0rywiJIMX35M trainee@debian11.ittraining.loc 
 +The key's randomart image is: 
 ++--[ED25519 256]--+ 
 +|                 | 
 +|         . .     | 
 +|        o +      | 
 +|      .* =     | 
 +|     ..oS.=.  * .| 
 +|    . ++oOE+ * * | 
 +|     . +* =.= O .| 
 +|       ..o.*.= ..| 
 +|         .+...o..| 
 ++----[SHA256]-----+ 
 +</code> 
 + 
 +Les clés générées seront placées dans le répertoire **~/.ssh/** : 
 + 
 +<code> 
 +trainee@debian11:~$ ls .ssh 
 +id_dsa      id_ecdsa      id_ed25519      id_rsa 
 +id_dsa.pub  id_ecdsa.pub  id_ed25519.pub  id_rsa.pub 
 +</code> 
 + 
 +===Tunnels SSH=== 
 + 
 +Le protocole SSH peut être utilisé pour sécuriser les protocoles tels telnet, pop3 etc.. En effet, on peut créer un //tunnel// SSH dans lequel passe les communications du protocole non-sécurisé. 
 + 
 +La commande pour créer un tunnel ssh prend la forme suivante : 
 + 
 +  ssh -N -f compte@hôte -Lport-local:localhost:port_distant 
 + 
 +Dans votre cas, vous allez créer un tunnel dans votre propre VM entre le port 15023 et le port 23 : 
 + 
 +<code> 
 +trainee@debian11:~$ su - 
 +Password: fenestros 
 +root@debian11:~# ssh -N -f trainee@localhost -L15023:localhost:23 
 +The authenticity of host 'localhost (::1)' can't be established. 
 +ECDSA key fingerprint is SHA256:38O9lqa1AHvviceNEbQ1AOUMspkYBpIpLlu/U05ymqo. 
 +Are you sure you want to continue connecting (yes/no/[fingerprint])? yes 
 +Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. 
 +Debian GNU/Linux 11 
 +trainee@localhost's password: trainee 
 +</code> 
 + 
 +Installez maintenant le serveur telnet : 
 + 
 +<code> 
 +root@debian11:~# apt -y install telnetd 
 +</code> 
 + 
 +Vérifiez que le service **inetd** est démarré : 
 + 
 +<code> 
 +root@debian11:~# systemctl status inetd 
 +● inetd.service - Internet superserver 
 +     Loaded: loaded (/lib/systemd/system/inetd.service; enabled; vendor preset: enabl> 
 +     Active: active (running) since Tue 2022-05-03 11:55:27 CEST; 44s ago 
 +       Docs: man:inetd(8) 
 +   Main PID: 5110 (inetd) 
 +      Tasks: 1 (limit: 4632) 
 +     Memory: 576.0K 
 +        CPU: 7ms 
 +     CGroup: /system.slice/inetd.service 
 +             └─5110 /usr/sbin/inetd 
 + 
 +May 03 11:55:27 debian11.ittraining.loc systemd[1]: Starting Internet superserver... 
 +May 03 11:55:27 debian11.ittraining.loc systemd[1]: Started Internet superserver. 
 +</code> 
 + 
 +Connectez-vous ensuite via telnet sur le port 15023, vous constaterez que votre connexion n'aboutit pas : 
 + 
 +<code> 
 +root@debian11:~# telnet localhost 15023 
 +Trying ::1... 
 +Connected to localhost. 
 +Escape character is '^]'
 +Debian GNU/Linux 11 
 +debian11.ittraining.loc login: trainee 
 +Password: trainee 
 +Linux debian11.ittraining.loc 5.17.0-1-amd64 #1 SMP PREEMPT Debian 5.17.3-1 (2022-04-18) x86_64 
 + 
 +The programs included with the Debian GNU/Linux system are free software; 
 +the exact distribution terms for each program are described in the 
 +individual files in /usr/share/doc/*/copyright. 
 + 
 +Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent 
 +permitted by applicable law. 
 +Last login: Tue May  3 08:57:59 CEST 2022 from 10.0.2.1 on pts/0 
 + 
 +trainee@debian11:~$ whoami 
 +trainee 
 + 
 +trainee@debian11:~$ pwd 
 +/home/trainee 
 + 
 +trainee@debian11:~$ exit 
 +logout 
 +Connection closed by foreign host. 
 +</code> 
 + 
 +<WRAP center round important 60%> 
 +**Important** - Notez bien que votre communication telnet passe par le tunnel SSH. 
 +</WRAP> 
 + 
 +====3.5 - SCP==== 
 + 
 +===Présentation=== 
 + 
 +La commande **scp** est le successeur et la remplaçante de la commande **rcp** de la famille des commandes **remote**. Il permet de faire des transferts sécurisés à partir d'une machine distante : 
 + 
 +  $ scp compte@numero_ip(nom_de_machine):/chemin_distant/fichier_distant /chemin_local/fichier_local 
 + 
 +ou vers une machine distante : 
 + 
 +  $ scp /chemin_local/fichier_local compte@numero_ip(nom_de_machine):/chemin_distant/fichier_distant 
 + 
 +===Utilisation=== 
 + 
 +Nous allons maintenant utiliser **scp** pour chercher un fichier sur le <<serveur>>
 + 
 +Créez le fichier **/home/trainee/scp_test** : 
 + 
 +<code> 
 +[trainee@centos8 ~]$ touch scp-test 
 +[trainee@centos8 ~]$ exit 
 +logout 
 +Connection closed by foreign host. 
 +[root@centos8 ~]#  
 +</code> 
 + 
 +Récupérez le fichier **scp_test** en utilisant scp : 
 + 
 +<code> 
 +[root@centos8 ~]# scp trainee@127.0.0.1:/home/trainee/scp-test . 
 +The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established. 
 +ECDSA key fingerprint is SHA256:Q7T/CP0SLiMbMAIgVzTuEHegYS/spPE5zzQchCHD5Vw. 
 +Are you sure you want to continue connecting (yes/no/[fingerprint])? yes 
 +Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts. 
 +\S 
 +Kernel \r on an \m 
 +trainee@127.0.0.1's password: trainee 
 +scp-test                                                                                                           100%    0     0.0KB/  00:00     
 + 
 +[root@centos8 ~]# ls -l 
 +total 32 
 +-rw-------. 1 root root 1358 Jun 16 06:40 anaconda-ks.cfg 
 +drwxr-xr-x. 3 root root   21 Jun 16 06:39 home 
 +-rw-r--r--. 1 root root 1749 Aug 24 11:20 I2TCH.asc 
 +-rw-r--r--. 1 root root 1853 Jun 16 06:54 initial-setup-ks.cfg 
 +-rw-r--r--. 1 root root   31 Aug 24 11:22 message.txt 
 +-rw-r--r--. 1 root root  561 Aug 24 11:32 message.txt.asc 
 +-rw-r--r--. 1 root root  367 Aug 24 11:30 message.txt.gpg 
 +-rw-r--r--. 1 root root  329 Aug 24 11:23 message.txt.sig 
 +-rw-r--r--. 1 root root    0 Aug 30 03:55 scp-test 
 +-rw-r--r--. 1 root root   46 Aug 29 06:22 wget_file.txt 
 +</code> 
 + 
 +====3.6 - Mise en Place des Clefs Asymétriques==== 
 + 
 +Il convient maintenant de se connecter sur le <<serveur>> en utilisant ssh et vérifiez la présence du répertoire ~/.ssh : 
 + 
 +<code> 
 +[root@centos8 ~]# ssh -l trainee 127.0.0.1 
 +\S 
 +Kernel \r on an \m 
 +trainee@127.0.0.1's password: trainee 
 +Activate the web console with: systemctl enable --now cockpit.socket 
 + 
 +[trainee@centos8 ~]$ ls -la | grep .ssh 
 +drwx------.  2 trainee trainee      4096 Aug 30 02:26 .ssh 
 +</code> 
 + 
 +<WRAP center round important 60%> 
 +**Important** - Si le dossier distant .ssh n'existe pas dans le répertoire personnel de l'utilisateur connecté, il faut le créer avec des permissions de 700. Dans votre cas, puisque votre machine joue le rôle de serveur **et** du client, le dossier /home/trainee/.ssh existe **déjà**. 
 +</WRAP> 
 + 
 +Ensuite, il convient de transférer le fichier local **.ssh/id_ecdsa.pub** du <<client>> vers le <<serveur>> en le renommant en **authorized_keys** : 
 + 
 +<code> 
 +[trainee@centos8 ~]$ exit 
 +logout 
 +Connection to 127.0.0.1 closed. 
 + 
 +[root@centos8 ~]# exit 
 +logout 
 + 
 +[trainee@centos8 ~]$ scp .ssh/id_ecdsa.pub trainee@127.0.0.1:/home/trainee/.ssh/authorized_keys 
 +The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established. 
 +ECDSA key fingerprint is SHA256:Q7T/CP0SLiMbMAIgVzTuEHegYS/spPE5zzQchCHD5Vw. 
 +Are you sure you want to continue connecting (yes/no/[fingerprint])? yes 
 +Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts. 
 +\S 
 +Kernel \r on an \m 
 +trainee@127.0.0.1's password: trainee 
 +id_ecdsa.pub                                                                                                       100%  192   497.6KB/  00:00 
 +</code> 
 + 
 +Connectez-vous via telnet : 
 + 
 +<code> 
 +[trainee@centos8 ~]$ ssh -l trainee localhost 
 +The authenticity of host 'localhost (::1)' can't be established. 
 +ECDSA key fingerprint is SHA256:Q7T/CP0SLiMbMAIgVzTuEHegYS/spPE5zzQchCHD5Vw. 
 +Are you sure you want to continue connecting (yes/no/[fingerprint])? yes 
 +Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. 
 +\S 
 +Kernel \r on an \m 
 +Activate the web console with: systemctl enable --now cockpit.socket 
 + 
 +Last login: Mon Aug 30 03:57:14 2021 from 127.0.0.1 
 +[trainee@centos8 ~]$ 
 +</code> 
 + 
 +<WRAP center round important 60%> 
 +**Important** - Lors de la connexion au serveur, l'authentification utilise le couple de clefs asymétrique au format ecdsa et aucun mot de passe n'est requis. 
 +</WRAP> 
 + 
 +Insérez maintenant les clefs publiques restantes dans le fichier .ssh/authorized_keys : 
 + 
 +<code> 
 +[trainee@centos8 ~]$ cd .ssh 
 +[trainee@centos8 .ssh]$ ls 
 +authorized_keys  id_dsa  id_dsa.pub  id_ecdsa  id_ecdsa.pub  id_ed25519  id_ed25519.pub  id_rsa  id_rsa.pub  known_hosts 
 +[trainee@centos8 .ssh]$ cat authorized_keys  
 +ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHDrzSXP+Ecxf/sQ18VwCRNm7rrSrrsaJmuIw/RgTH5puKF5E+Yy15cvAAKBXpJPxUmrOaOyhab84PevV7XSHcI= trainee@centos8.ittraining.loc 
 + 
 +[trainee@centos8 .ssh]$ cat id_rsa.pub >> authorized_keys 
 +[trainee@centos8 .ssh]$ cat id_dsa.pub >> authorized_keys 
 +[trainee@centos8 .ssh]$ cat id_ed25519.pub >> authorized_keys 
 + 
 +[trainee@centos8 .ssh]$ cat authorized_keys 
 +ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHDrzSXP+Ecxf/sQ18VwCRNm7rrSrrsaJmuIw/RgTH5puKF5E+Yy15cvAAKBXpJPxUmrOaOyhab84PevV7XSHcI= trainee@centos8.ittraining.loc 
 +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD3ZSMn/GIAHtaDFc6ZNnKJam9hzq8TxqMN5IopUr8QhwODyPadbB+FgH4r50qTux4ubwr1BlymgIdqRVWy32mE15M8tdtKc3j8DNMpUwPGEh+s/PT7GW+3E3shoyPvpLc1kKaKXKGl/JwfCK/8IYsubk2BmiiJYkzLECotPlaaxm4w1K0AtlnZQuLHt1HK3/rHChxo2o2w1t59/QwNcMLiKve1Z+zQ1POKo8VJ/DDrf90y2QWC28ejUs/ZjP6f6C4bn5Jjol4TbHls3ArMsbU6C1Ev5jqbzZ0kmognQ2CnRjeNM51YdFo6nRsLoPQKpeLRMBpT/87HK1bPUOBVCyhXxSkqkVhMlgg8tgcD/MRlBaUVFoZ1wQ0L26Fe+q7c2Oykj54pdXCAK2ZTpCXGfhd/FxrfqGw7cSeKlGX4QUzHMjMk2oHFC9h30BUk1gGN21KJPTh7/S1OZVrnCc3GUi5fXPvEpral0IU0sws+j03dj0sWm5ICQFKRkmZN11HCyT0= trainee@centos8.ittraining.loc 
 +ssh-dss AAAAB3NzaC1kc3MAAACBALIdwEEqHrMWSUdzARm9ldsZK9ebbtZShtmwgdjphOk77fxymK0y6wV7QEmLL25LOcLb12uZ1F0LtRt/t2oqgrwqk3vUSpCPLr09AXpcD/nxL9kc+rUxHyl6u1mHtyfCVLCPSvavCMR8TaA8egVMk3EwGRfHTiuDOKi7Iwus7gXPAAAAFQDHEQPGVRI7gVYKzCT6nrjDsQQ6jwAAAIEAhhhH7fEjdldASXY0qTWkCvcs3cfK9/Ff315zByn47O02y9Vdo3QG5nOr1Oo8fc2xEkIBNmFr8Rr2g60cpvEev5hy4XZ1ghxnQ53iwKuiS72ZATwhD6bZBrsiH0k1Et25gRcj5KCvDe/jHhbxCxsCuHUH2qvWsQNVwztE7hD0sxkAAACAQ8Dkpy8zXj7jW8o1txxf2W6J4r2+1lPldymA45ywZokN4SCwvXlpPAuyBt0/HiU0R2PI9aqOAMosCLcy9WmnSwLQ2Z7QcD2i3XlAih2+1q9NJP22sPT3jSK9UZcdRjoZ/eNiz84sXZucNape32tFxjvcV4txobH/vD53q8g63fA= trainee@centos8.ittraining.loc 
 +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOfFQULLU8IZyKiSU63D2Zz6yGLqyHcBHnCRdSR9JSmc trainee@centos8.ittraining.loc 
 +</code> 
 + 
 +====3.7 - Services réseaux ==== 
 + 
 +Quand un client émet une demande de connexion vers une application réseau sur un serveur, il utilise un socket attaché à un port local **supérieur à 1023**, alloué d'une manière dynamique. La requête contient le port de destination sur le serveur. Certaines applications serveurs se gèrent toutes seules, ce qui est la cas par exemple d'**apache2**. Par contre d'autres sont gérées par le service **xinetd**.  
 + 
 +=== inetd === 
 + 
 +Le programme inetd est configuré via le fichier **/etc/inetd.conf** : 
 + 
 +<code> 
 +root@debian11:~# cat /etc/inetd.conf 
 +# /etc/inetd.conf:  see inetd(8) for further informations. 
 +
 +# Internet superserver configuration database 
 +
 +
 +# Lines starting with "#:LABEL:" or "#<off>#" should not 
 +# be changed unless you know what you are doing! 
 +
 +# If you want to disable an entry so it isn't touched during 
 +# package updates just comment it out with a single '#' character. 
 +
 +# Packages should modify this file by using update-inetd(8) 
 +
 +# <service_name> <sock_type> <proto> <flags> <user> <server_path> <args> 
 +
 +#:INTERNAL: Internal services 
 +#discard                stream  tcp     nowait  root    internal 
 +#discard                dgram   udp     wait    root    internal 
 +#daytime                stream  tcp     nowait  root    internal 
 +#time           stream  tcp     nowait  root    internal 
 + 
 +#:STANDARD: These are standard services. 
 +telnet          stream  tcp     nowait  telnetd /usr/sbin/tcpd  /usr/sbin/in.telnetd 
 + 
 +#:BSD: Shell, login, exec and talk are BSD protocols. 
 + 
 +#:MAIL: Mail, news and uucp services. 
 + 
 +#:INFO: Info services 
 + 
 +#:BOOT: TFTP service is provided primarily for booting.  Most sites 
 +#       run this only on machines acting as "boot servers." 
 + 
 +#:RPC: RPC based services 
 + 
 +#:HAM-RADIO: amateur-radio services 
 + 
 +#:OTHER: Other services 
 +</code> 
 + 
 +Les lignes de configuration des serveurs ressemblent à : 
 + 
 +<code> 
 +telnet          stream  tcp     nowait  telnetd /usr/sbin/tcpd  /usr/sbin/in.telnetd 
 +</code> 
 + 
 +Le premier champs de la ligne identifie le nom du port qui identifie l'application. Inetd lit ensuite le fichier **/etc/services** pour déduire le numéro de port concerné et se met à l'écoute de celui-ci.  
 + 
 +Le deuxième et le troisième champs définissent le type de protocole, à savoir: 
 + 
 +  * stream tcp pour le tcp 
 +  * dgram udp pour l'udp 
 + 
 +Le quatrième champs prend un de deux valeurs: 
 + 
 +  * nowait 
 +    * indique qu'il y aura un serveur par client 
 +  * wait 
 +    * indique qu'il y aura un seul serveur pour l'ensemble des clients 
 + 
 +Le cinquième champs indique l'identité sous laquelle sera exécuté le serveur. 
 + 
 +Le sixième champs indique l'exécutable. Dans ce cas c'est **/usr/sbin/tcpd**. 
 + 
 +Le septième champs indique les arguments de l'application serveur dont l'argument **0** est le nom de l'application. 
 + 
 +== TCP Wrapper == 
 + 
 +Lors de l'utilisation d'inetd, **TCP Wrapper** est utilisé pour contrôler l'accès à des services réseaux grâce à des **ACL** : 
 + 
 +<file> 
 +telnet          stream  tcp     nowait  telnetd /usr/sbin/tcpd  /usr/sbin/in.telnetd 
 +</file> 
 + 
 +Quand une requête arrive pour le serveur telnet, inetd active le wrapper **tcpd** au lieu d'activer **/usr/sbin/in.telnetd** directement. 
 + 
 +**tcpd** met à jour un journal et vérifie si le client a le droit d'utiliser le service concerné. Les ACL se trouvent dans deux fichiers: 
 + 
 +<code> 
 +root@debian11:~# cat /etc/hosts.allow 
 +# /etc/hosts.allow: list of hosts that are allowed to access the system. 
 +#                   See the manual pages hosts_access(5) and hosts_options(5). 
 +
 +# Example:    ALL: LOCAL @some_netgroup 
 +#             ALL: .foobar.edu EXCEPT terminalserver.foobar.edu 
 +
 +# If you're going to protect the portmapper use the name "rpcbind" for the 
 +# daemon name. See rpcbind(8) and rpc.mountd(8) for further information. 
 +
 + 
 +root@debian11:~# cat /etc/hosts.deny 
 +# /etc/hosts.deny: list of hosts that are _not_ allowed to access the system. 
 +#                  See the manual pages hosts_access(5) and hosts_options(5). 
 +
 +# Example:    ALL: some.host.name, .some.domain 
 +#             ALL EXCEPT in.fingerd: other.host.name, .other.domain 
 +
 +# If you're going to protect the portmapper use the name "rpcbind" for the 
 +# daemon name. See rpcbind(8) and rpc.mountd(8) for further information. 
 +
 +# The PARANOID wildcard matches any host whose name does not match its 
 +# address. 
 +
 +# You may wish to enable this to ensure any programs that don'
 +# validate looked up hostnames still leave understandable logs. In past 
 +# versions of Debian this has been the default. 
 +# ALL: PARANOID 
 +</code> 
 + 
 +Il faut noter que si ces fichiers n'existent pas ou sont vides, il n'y a pas de contrôle d'accès. 
 + 
 +Le format d'une ligne dans un de ces deux fichiers est: 
 + 
 +<file> 
 +démon: liste_de_clients 
 +</file> 
 + 
 +Par exemple dans le cas de notre serveur telnetd, une ligne dans le fichier **/etc/hosts.allow** similaire à: 
 + 
 +<file> 
 +in.telnetd: 192.168.1.10, .fenestros.com 
 +</file> 
 + 
 +implique que la machine dont le numéro IP est le 192.168.1.10 ainsi que les machines du domaine **fenestros.com** sont autorisées à utiliser le service. 
 + 
 +Le mot clef **ALL** peut être utilisé pour indiquer tout. Par exemple, **ALL:ALL** dans le fichier **/etc/host.deny** bloque effectivement toute tentative de connexion à un service inetd sauf pour les ACL inclus dans le fichier /etc/host.allow. 
 + 
 +=====Configuration du Réseau sous RHEL/CentOS 6=====
  
 ==== Configuration de TCP/IP ==== ==== Configuration de TCP/IP ====
Ligne 1255: Ligne 3037:
 ;; WHEN: Mon Jan 22 18:00:27 CET 2018 ;; WHEN: Mon Jan 22 18:00:27 CET 2018
 ;; MSG SIZE  rcvd: 72 ;; MSG SIZE  rcvd: 72
-</code> 
- 
-==== Services réseaux ==== 
- 
-Quand un client émet une demande de connexion vers une application réseau sur un serveur, il utilise un socket attaché à un port local **supérieur à 1023**, alloué d'une manière dynamique. La requête contient le port de destination sur le serveur. Certaines applications serveurs se gèrent toutes seules, ce qui est la cas par exemple d'**httpd**. Par contre d'autres sont gérées par le service **xinetd**.  
- 
-=== xinetd === 
- 
-Sous RHEL/CentOS 6 xinetd n'est pas installé par défaut. Installez-le grâce à yum : 
- 
-<code> 
-[root@centos6 ~]# yum install xinetd 
-Loaded plugins: fastestmirror, refresh-packagekit 
-Loading mirror speeds from cached hostfile 
- * base: fr2.rpmfind.net 
- * extras: fr2.rpmfind.net 
- * updates: fr2.rpmfind.net 
-Setting up Install Process 
-Resolving Dependencies 
---> Running transaction check 
----> Package xinetd.i686 2:2.3.14-33.el6 set to be updated 
---> Finished Dependency Resolution 
- 
-Dependencies Resolved 
- 
-================================================================================ 
- Package          Arch           Version                   Repository      Size 
-================================================================================ 
-Installing: 
- xinetd           i686           2:2.3.14-33.el6           base           121 k 
- 
-Transaction Summary 
-================================================================================ 
-Install       1 Package(s) 
-Upgrade       0 Package(s) 
- 
-Total download size: 121 k 
-Installed size: 258 k 
-Is this ok [y/N]: y 
-Downloading Packages: 
-xinetd-2.3.14-33.el6.i686.rpm                            | 121 kB     00:00      
-Running rpm_check_debug 
-Running Transaction Test 
-Transaction Test Succeeded 
-Running Transaction 
-  Installing     : 2:xinetd-2.3.14-33.el6.i686                              1/1  
- 
-Installed: 
-  xinetd.i686 2:2.3.14-33.el6                                                    
- 
-Complete! 
-</code> 
- 
-Le programme xinetd est configuré via le fichier **/etc/xinetd.conf** : 
- 
-<code> 
-[root@centos6 ~]# cat /etc/xinetd.conf 
-# 
-# This is the master xinetd configuration file. Settings in the 
-# default section will be inherited by all service configurations 
-# unless explicitly overridden in the service configuration. See 
-# xinetd.conf in the man pages for a more detailed explanation of 
-# these attributes. 
- 
-defaults 
-{ 
-# The next two items are intended to be a quick access place to 
-# temporarily enable or disable services. 
-# 
-# enabled = 
-# disabled = 
- 
-# Define general logging characteristics. 
- log_type = SYSLOG daemon info  
- log_on_failure = HOST 
- log_on_success = PID HOST DURATION EXIT 
- 
-# Define access restriction defaults 
-# 
-# no_access = 
-# only_from = 
-# max_load = 0 
- cps = 50 10 
- instances = 50 
- per_source = 10 
- 
-# Address and networking defaults 
-# 
-# bind = 
-# mdns = yes 
- v6only = no 
- 
-# setup environmental attributes 
-# 
-# passenv = 
- groups = yes 
- umask = 002 
- 
-# Generally, banners are not used. This sets up their global defaults 
-# 
-# banner = 
-# banner_fail = 
-# banner_success = 
-} 
- 
-includedir /etc/xinetd.d 
-</code> 
- 
-Les valeurs des directives dans le fichier **/etc/xinetd.conf** sont héritées par toutes les configurations des services sauf dans le cas où une variable est explicitement fixée dans un des fichiers de définitions des services se trouvant dans **/etc/xinetd.d**. 
- 
-Les variables les plus importantes dans **/etc/xinetd.conf** : 
- 
-^  Directive  ^  Déscription  ^ 
-|  instances  | Le nombre de demandes d'accès simultanés | 
-|  log_type  | Indique à xinetd d'adresser les traces à SYSLOG avec l'étiquette de sous-système applicatif **daemon** et la priorité de **info** | 
-|  log_on_succes  | Indique que SYSLOG doit journaliser le PID, HOST, DURATION et EXIT en cas de succès | 
-|  log_on_failure  | Indique que SYSLOG doit journaliser le HOST en cas d'échec | 
-|  cps  | Indique 50 connexions par seconde avec un temps d'indisponibilité de 10 secondes si le seuil est atteint |  
- 
-Les options concernant les journaux sont : 
- 
-|  HOST  | Journalisation de l'adresse IP de l'hôte distant | 
-|  PID  | Journalisation du PID du processus qui reçoit la demande d'accès | 
-|  DURATION  | Journalisation des durées d'utilisation | 
-|  EXIT  | Journalisation de l'état ou di signal de fin de service | 
- 
-Il est aussi possible de trouver les options suivantes pour les journaux : 
- 
-|  ATTEMPT  | Journalisation des connexions en échec | 
-|  USERID  | Journalisation des données concernant l'utilisateur selon la RFC 1413 | 
- 
-Examinons maintenant le répertoire **/etc/xinetd.d** :  
- 
-<code> 
-[root@centos6 ~]# ls -l /etc/xinetd.d 
-total 52 
--rw-------. 1 root root 1157  7 déc.  22:07 chargen-dgram 
--rw-------. 1 root root 1159  7 déc.  22:07 chargen-stream 
--rw-r--r--. 1 root root  523 25 juin   2011 cvs 
--rw-------. 1 root root 1157  7 déc.  22:07 daytime-dgram 
--rw-------. 1 root root 1159  7 déc.  22:07 daytime-stream 
--rw-------. 1 root root 1157  7 déc.  22:07 discard-dgram 
--rw-------. 1 root root 1159  7 déc.  22:07 discard-stream 
--rw-------. 1 root root 1148  7 déc.  22:07 echo-dgram 
--rw-------. 1 root root 1150  7 déc.  22:07 echo-stream 
--rw-r--r--. 1 root root  332 20 mai    2009 rsync 
--rw-------. 1 root root 1212  7 déc.  22:07 tcpmux-server 
--rw-------. 1 root root 1149  7 déc.  22:07 time-dgram 
--rw-------. 1 root root 1150  7 déc.  22:07 time-stream 
-</code> 
- 
-A l'examen de ce répertoire vous noterez que celui-ci contient des fichiers nominatifs par application-serveur, par exemple pour le serveur cvs : 
- 
-<code> 
-[root@centos6 ~]# cat /etc/xinetd.d/cvs 
-# default: off 
-# description: The CVS service can record the history of your source \ 
-#              files. CVS stores all the versions of a file in a single \ 
-#              file in a clever way that only stores the differences \ 
-#              between versions. 
-service cvspserver 
-{ 
- disable = yes 
- port = 2401 
- socket_type = stream 
- protocol = tcp 
- wait = no 
- user = root 
- passenv = PATH 
- server = /usr/bin/cvs 
- env = HOME=/var/cvs 
- server_args = -f --allow-root=/var/cvs pserver 
-# bind = 127.0.0.1 
-} 
-</code> 
- 
-Les directives principales de ce fichier sont : 
- 
-^  Paramètre  ^  Déscription  ^ 
-|  disable  | **no** : Le service est actif. **yes** : Le service est désactivé | 
-|  port  | Le numéro de port ou, à défaut, le numéro indiqué pour le service dans le fichier /etc/services | 
-|  socket_type  | Nature du socket, soit **stream** pour TCP soit **dgram** pour UDP | 
-|  protocol  | Protocole utilisé soit **TCP** soit **UDP** | 
-|  wait  | **no** : indique si xinetd active un serveur par client. **yes** : indique que xinetd active un seul serveur pour tous les client |  
-|  user  | Indique le compte sous lequel le serveur est exécuté | 
-|  server  | Indique le chemin d'accès de l'application serveur | 
-|  env  | Définit un environnement système | 
-|  server_args  | Donne les arguments transmis à l'application serveur | 
- 
-Cependant il est aussi possible d'utiliser les directives suivantes : 
- 
-^  Paramètre  ^  Déscription  ^  Exemple  ^ 
-|  nice  | Fixe le niveau de nice entre -19 et +20 |  10  | 
-|  max_load  | Fixe la charge CPU maximum admise. Au delà aucune connexion supplémenatire en sera acceptée |  2.5  | 
-|  bind  | Limite le service à l'interface dont l'adresse IP est indiquée |  192.168.1.1  | 
-|  only_from  | Limite le service aux seuls clients indiqués par la plage donnée |  192.168.1.0/24 fenestros.loc  | 
-|  no_access  | Interdit le service aux clients indiqués par la plage donnée |  192.168.2.0/24, i2tch.loc  
-|  access_time  | Limite l'accès au service à une plage horaire |  09:00-19:00  | 
-|  redirect  | Redirige les requêtes sur un port donné à une autre adresse IP |  192.168.1.10 23  | 
- 
-Afin d'activer une application serveur, il suffit de modifier le paramètre **disable** dans le fichier concerné et de relancer le service xinetd. 
- 
-=== TCP Wrapper === 
- 
-**TCP Wrapper** contrôle l'accès à des services réseaux grâce à des **ACL**.  
- 
-Quand une requête arrive pour un serveur, xinetd active le wrapper **tcpd** au lieu d'activer le serveur directement. 
- 
-**tcpd** met à jour un journal et vérifie si le client a le droit d'utiliser le service concerné. Les ACL se trouvent dans deux fichiers: 
- 
-  * **/etc/hosts.allow** 
-  * **/etc/hosts.deny** 
- 
-Il faut noter que si ces fichiers n'existent pas ou sont vides, il n'y a pas de contrôle d'accès. 
- 
-Le format d'une ligne dans un de ces deux fichiers est: 
- 
-<file> 
-démon : liste_de_clients 
-</file> 
- 
-Par exemple dans le cas d'un serveur **démon**, on verrait une ligne dans le fichier **/etc/hosts.allow** similaire à: 
- 
-<file> 
-démon : LOCAL, .fenestros.loc 
-</file> 
- 
-ce qui implique que les machines dont le nom ne comporte pas de point ainsi que les machines du domaine **fenestros.loc** sont autorisées à utiliser le service. 
- 
-Le mot clef **ALL** peut être utilisé pour indiquer tout. Par exemple, **ALL:ALL** dans le fichier **/etc/host.deny** bloque effectivement toute tentative de connexion à un service xinetd sauf pour les ACL inclus dans le fichier /etc/host.allow. 
- 
-====Routage Statique==== 
- 
-===La Commande route=== 
- 
-Pour afficher la table de routage de la machine vous pouvez utiliser la commande **route** : 
- 
-<code> 
-[root@centos6 ~]# route 
-Table de routage IP du noyau 
-Destination     Passerelle      Genmask         Indic Metric Ref    Use Iface 
-192.168.1.0                   255.255.255.0            0        0 eth0 
-10.0.2.0        *               255.255.255.0            0        0 eth0 
-link-local      *               255.255.0.0         1002          0 eth0 
-default         10.0.2.2        0.0.0.0         UG    0      0        0 eth0 
-</code> 
- 
-La table issue de la commande **route** indique les informations suivantes: 
- 
-  * La destination qui peut être un hôte ou un réseau et est identifiée par les champs **Destination** et **Genmask** 
-  * La route à prendre identifiée par les champs **Gateway** et **Iface**. Dans le cas d'une valeur de 0.0.0.0 ceci spécifie une route directe. La valeur d'Iface spécifie la carte à utiliser, 
-  * Le champ **Indic** qui peux prendre un ou plusieurs de svaleurs suivantes: 
-    * U - **Up** - la route est active 
-    * H - **Host** - la route conduit à un hôte 
-    * G - **Gateways** - la route passe par une passerelle 
-  * Le champ **Metric** indique le nombre de sauts (passerelles) pour atteindre la destination, 
-  * Le champ **Ref** indique le nombre de références à cette route. Ce champs est usilisé par le Noyau de Linux, 
-  * Le champ **Use** indique le nombre de recherches associés à cette route. 
- 
-La commande **route** permet aussi de paramétrer le routage indirect. Par exemple pour supprimer la route vers le réseau 192.168.1.0 : 
- 
-<code> 
-[root@centos6 ~]# route del -net 192.168.1.0 netmask 255.255.255.0 
-[root@centos6 ~]# route 
-Table de routage IP du noyau 
-Destination     Passerelle      Genmask         Indic Metric Ref    Use Iface 
-10.0.2.0        *               255.255.255.0            0        0 eth0 
-link-local      *               255.255.0.0         1002          0 eth0 
-default         10.0.2.2        0.0.0.0         UG    0      0        0 eth0 
-</code> 
- 
-Pour ajouter la route vers le réseau 192.168.1.0 : 
- 
-<code> 
-[root@centos6 ~]# route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.2 
-[root@centos6 ~]# route 
-Table de routage IP du noyau 
-Destination     Passerelle      Genmask         Indic Metric Ref    Use Iface 
-192.168.1.0     192.168.1.2     255.255.255.0   UG    0      0        0 eth0 
-10.0.2.0        *               255.255.255.0            0        0 eth0 
-link-local      *               255.255.0.0         1002          0 eth0 
-default         10.0.2.2        0.0.0.0         UG    0      0        0 eth0 
-</code> 
- 
-<WRAP center round important> 
-La commande utilisée pour ajouter une passerelle par défaut prend la forme suivante **route add default gw //numéro_ip// //interface//**. 
-</WRAP> 
- 
-Les options cette commande sont : 
- 
-<code> 
-[root@centos6 ~]# route --help 
-Syntaxe: route [-nNvee] [-FC] [<AF>          Liste les tables de routage noyau 
-       route [-v] [-FC] {add|del|flush} ...  Modifie la table de routage pour AF. 
- 
-       route {-h|--help} [<AF>             Utilisation détaillée pour l'AF spécifié. 
-       route {-V|--version}                  Affiche la version/auteur et termine. 
- 
-        -v, --verbose            mode verbeux 
-        -n, --numeric            don't resolve names 
-        -e, --extend             display other/more information 
-        -F, --fib                display Forwarding Information Base (default) 
-        -C, --cache              affiche le cache de routage au lieu de FIB 
- 
-  <AF>=Use '-A <af>' or '--<af>'; default: inet 
-  Liste les familles d'adresses possibles (supportant le routage): 
-    inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25)  
-    netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP)  
-    x25 (CCITT X.25)  
-</code> 
- 
-Vous pouvez aussi utiliser la commande **netstat** pour afficher la table de routage de la machine : 
- 
-<code> 
-[root@centos6 ~]# netstat -nr 
-Table de routage IP du noyau 
-Destination     Passerelle      Genmask         Indic   MSS Fenêtre irtt Iface 
-192.168.1.0     192.168.1.2     255.255.255.0   UG        0 0          0 eth0 
-192.168.1.0     0.0.0.0         255.255.255.0           0 0          0 eth0 
-10.0.2.0        0.0.0.0         255.255.255.0           0 0          0 eth0 
-0.0.0.0         10.0.2.2        0.0.0.0         UG        0 0          0 eth0 
-</code> 
- 
-La table issue de la commande **netstat -nr** indique les informations suivantes: 
- 
-  * La champ **MSS** indique la taille maximale des segments TCP sur la route, 
-  * Le champ **Window** indique la taille de la fenêtre sur cette route, 
-  * Le champ **irrt** indique le paramètre IRRT pour la route. 
- 
-===Activer/désactiver le routage sur le serveur=== 
- 
-Pour activer le routage sur le serveur, il convient d'activer la retransmission des paquets: 
- 
-<code> 
-[root@centos6 ~]# echo 1 > /proc/sys/net/ipv4/ip_forward 
-[root@centos6 ~]# cat /proc/sys/net/ipv4/ip_forward 
-1 
-</code> 
- 
-Pour désactiver le routage sur le serveur, il convient de désactiver la retransmission des paquets: 
- 
-<code> 
-[root@centos6 ~]# echo 0 > /proc/sys/net/ipv4/ip_forward 
-[root@centos6 ~]# cat /proc/sys/net/ipv4/ip_forward 
-0 
-</code> 
- 
-=====Configuration du Réseau sous Debian 8===== 
- 
-Debian 8 utilise exclusivement **Network Manager** pour gérer le réseau. Network Manager est composé de deux éléments : 
- 
-  * un service qui gère les connexions réseaux et rapporte leurs états, 
-  * des front-ends qui passent par un API de configuration du service. 
- 
-<WRAP center round important> 
-**Important** : Notez qu'avec cette version de NetworkManager, IPv6 est activée par défaut. 
-</WRAP> 
- 
-Le service NetworkManager doit toujours être lancé : 
- 
-<code> 
-root@debian8:~# systemctl status NetworkManager.service 
-● NetworkManager.service - Network Manager 
-   Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled) 
-   Active: active (running) since Mon 2015-11-02 14:01:23 CET; 20h ago 
- Main PID: 510 (NetworkManager) 
-   CGroup: /system.slice/NetworkManager.service 
-           ├─ 510 /usr/sbin/NetworkManager --no-daemon 
-           └─1715 /sbin/dhclient -d -q -sf /usr/lib/NetworkManager/nm-dhcp-helper -pf /var/run/dhclient-eth0.pid -lf /var/lib/NetworkManager/dhclie... 
- 
-Nov 03 09:10:12 debian8 NetworkManager[510]: <info> Activation (eth0) Stage 5 of 5 (IPv4 Commit) started... 
-Nov 03 09:10:12 debian8 NetworkManager[510]: <info> (eth0): device state change: ip-config -> ip-check (reason 'none') [70 80 0] 
-Nov 03 09:10:12 debian8 NetworkManager[510]: <info> Activation (eth0) Stage 5 of 5 (IPv4 Commit) complete. 
-Nov 03 09:10:12 debian8 NetworkManager[510]: <info> (eth0): device state change: ip-check -> secondaries (reason 'none') [80 90 0] 
-Nov 03 09:10:12 debian8 NetworkManager[510]: <info> (eth0): device state change: secondaries -> activated (reason 'none') [90 100 0] 
-Nov 03 09:10:12 debian8 NetworkManager[510]: <info> NetworkManager state is now CONNECTED_LOCAL 
-Nov 03 09:10:12 debian8 dhclient[1715]: bound to 10.0.2.15 -- renewal in 42103 seconds. 
-Nov 03 09:10:12 debian8 NetworkManager[510]: <info> NetworkManager state is now CONNECTED_GLOBAL 
-Nov 03 09:10:12 debian8 NetworkManager[510]: <info> Policy set 'Wired connection 1' (eth0) as default for IPv4 routing and DNS. 
-Nov 03 09:10:12 debian8 NetworkManager[510]: <info> Activation (eth0) successful, device activated. 
-</code> 
- 
-====La Commande nmcli==== 
- 
-La commande **nmcli** (Network Manager Command Line Interface) est utilisée pour configurer NetworkManager. 
- 
-Les options et les sous-commandes peuvent être consultées en utilisant les commandes suivantes : 
- 
-<code> 
-root@debian8:~# nmcli --help 
-Usage: nmcli [OPTIONS] OBJECT { COMMAND | help } 
- 
-OPTIONS 
-  -t[erse]                                   terse output 
-  -p[retty]                                  pretty output 
-  -m[ode] tabular|multiline                  output mode 
-  -f[ields] <field1,field2,...>|all|common   specify fields to output 
-  -e[scape] yes|no                           escape columns separators in values 
-  -n[ocheck]                                 don't check nmcli and NetworkManager versions 
-  -a[sk]                                     ask for missing parameters 
-  -w[ait] <seconds>                          set timeout waiting for finishing operations 
-  -v[ersion]                                 show program version 
-  -h[elp]                                    print this help 
- 
-OBJECT 
-  g[eneral]       NetworkManager's general status and operations 
-  n[etworking]    overall networking control 
-  r[adio]         NetworkManager radio switches 
-  c[onnection]    NetworkManager's connections 
-  d[evice]        devices managed by NetworkManager 
- 
-root@debian8:~# nmcli g help 
-Usage: nmcli general { COMMAND | help } 
- 
-COMMAND := { status | hostname | permissions | logging } 
- 
-  status 
- 
-  hostname [<hostname>] 
- 
-  permissions 
- 
-  logging [level <log level>] [domains <log domains>] 
- 
-root@debian8:~# nmcli g status help 
-Usage: nmcli general status { help } 
- 
-Show overall status of NetworkManager. 
-'status' is the default action, which means 'nmcli gen' calls 'nmcli gen status' 
-</code> 
- 
-====Connections et Profils==== 
- 
-NetworkManager inclus la notion de **connections** ou **profils** permettant des configurations différentes en fonction de la localisation. Pour voir les connections actuelles, utilisez la commande **nmcli c** avec la sous-commande **show** : 
- 
-<code> 
-root@debian8:~# nmcli c show 
-NAME                UUID                                  TYPE            DEVICE  
-Wired connection 1  0caa0d4f-0222-415a-8a4f-753ca284911e  802-3-ethernet  eth0  
-</code> 
- 
-Comme on peut constater ici, il n'existe pour le moment, qu'un seul profil. 
- 
-Si vous constatez que vous n'avez pas de profil dans la sortie de la commande **nmcli c show**, ceci indique que NetworkManager ne gère pas la carte : 
- 
-<code> 
-root@debian8:~# nmcli c show 
-NAME     UUID      TYPE      DEVICE  
-</code> 
- 
-Dans ce cas, le fichier **/etc/network/interfaces** contiendra une entrée pour la carte **eth0** : 
- 
-<code> 
-root@debian8:~# cat /etc/network/interfaces 
-# This file describes the network interfaces available on your system 
-# and how to activate them. For more information, see interfaces(5). 
- 
-source /etc/network/interfaces.d/* 
- 
-# The loopback network interface 
-auto lo 
-iface lo inet loopback 
- 
-# The primary network interface 
-allow-hotplug eth0 
-iface eth0 inet dhcp 
-</code> 
- 
-Afin de permettre NetworkManager de gérer la carte malgré cette configuration, il convient d'éditer le fichier **/etc/NetworkManager/NetworkManager.conf** et passer la directive **managed=false** à **managed=true** : 
- 
-<code> 
-root@debian8:~# cat /etc/NetworkManager/NetworkManager.conf 
-[main] 
-plugins=ifupdown,keyfile 
- 
-[ifupdown] 
-managed=true 
-</code> 
- 
-Il faut ensuite re-démarrer le service NetworkManager : 
- 
-<code> 
-root@debian8:~# systemctl restart NetworkManager.service  
-</code> 
- 
-Créez maintenant un profil IP fixe rattaché au périphérique **eth0** : 
- 
-<code> 
-root@debian8:~# nmcli connection add con-name ip_fixe ifname eth0 type ethernet ip4 10.0.2.16/24 gw4 10.0.2.2 
-Connection 'ip_fixe' (ec7e2b5f-0d19-4a40-8639-24af88a59d79) successfully added. 
-</code> 
- 
-Constatez sa présence : 
- 
-<code> 
-root@debian8:~# nmcli c show 
-NAME                UUID                                  TYPE            DEVICE  
-ip_fixe             ec7e2b5f-0d19-4a40-8639-24af88a59d79  802-3-ethernet  --      
-Wired connection 1  0caa0d4f-0222-415a-8a4f-753ca284911e  802-3-ethernet  eth0    
-</code> 
- 
-Notez que la sortie n'indique pas que le profil **ip_fixe** soit associé au periphérique **enp0s3** car le profil **ip_fixe** n'est pas activé : 
- 
-<code> 
-root@debian8:~# nmcli d show 
-GENERAL.DEVICE:                         eth0 
-GENERAL.TYPE:                           ethernet 
-GENERAL.HWADDR:                         08:00:27:F2:8C:8F 
-GENERAL.MTU:                            1500 
-GENERAL.STATE:                          100 (connected) 
-GENERAL.CONNECTION:                     Wired connection 1 
-GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/2 
-WIRED-PROPERTIES.CARRIER:               on 
-IP4.ADDRESS[1]:                         ip = 10.0.2.15/24, gw = 10.0.2.2 
-IP4.ROUTE[1]:                           dst = 169.254.0.0/16, nh = 0.0.0.0, mt = 1000 
-IP4.DNS[1]:                             8.8.8.8 
-IP4.DOMAIN[1]:                          formation.local 
-IP6.ADDRESS[1]:                         ip = fe80::a00:27ff:fef2:8c8f/64, gw = :: 
- 
-GENERAL.DEVICE:                         lo 
-GENERAL.TYPE:                           loopback 
-GENERAL.HWADDR:                         00:00:00:00:00:00 
-GENERAL.MTU:                            65536 
-GENERAL.STATE:                          10 (unmanaged) 
-GENERAL.CONNECTION:                     -- 
-GENERAL.CON-PATH:                       -- 
-IP4.ADDRESS[1]:                         ip = 127.0.0.1/8, gw = 0.0.0.0 
-IP6.ADDRESS[1]:                         ip = ::1/128, gw = :: 
-</code> 
- 
-Pour activer le profil ip_fixe, utilisez la commande suivante : 
- 
-<code> 
-root@debian8:~# nmcli connection up ip_fixe 
-Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3) 
-</code> 
- 
-Le profil ip_fixe est maintenant activé tandis que le profil Wired connection 1 a été désactivé : 
- 
-<code> 
-root@debian8:~# nmcli c show 
-NAME                UUID                                  TYPE            DEVICE  
-ip_fixe             ec7e2b5f-0d19-4a40-8639-24af88a59d79  802-3-ethernet  eth0    
-Wired connection 1  0caa0d4f-0222-415a-8a4f-753ca284911e  802-3-ethernet  --  
-     
-root@debian8:~# nmcli d show 
-GENERAL.DEVICE:                         eth0 
-GENERAL.TYPE:                           ethernet 
-GENERAL.HWADDR:                         08:00:27:F2:8C:8F 
-GENERAL.MTU:                            1500 
-GENERAL.STATE:                          100 (connected) 
-GENERAL.CONNECTION:                     ip_fixe 
-GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/3 
-WIRED-PROPERTIES.CARRIER:               on 
-IP4.ADDRESS[1]:                         ip = 10.0.2.16/24, gw = 10.0.2.2 
-IP4.ROUTE[1]:                           dst = 169.254.0.0/16, nh = 0.0.0.0, mt = 1000 
-IP6.ADDRESS[1]:                         ip = fe80::a00:27ff:fef2:8c8f/64, gw = :: 
- 
-GENERAL.DEVICE:                         lo 
-GENERAL.TYPE:                           loopback 
-GENERAL.HWADDR:                         00:00:00:00:00:00 
-GENERAL.MTU:                            65536 
-GENERAL.STATE:                          10 (unmanaged) 
-GENERAL.CONNECTION:                     -- 
-GENERAL.CON-PATH:                       -- 
-IP4.ADDRESS[1]:                         ip = 127.0.0.1/8, gw = 0.0.0.0 
-IP6.ADDRESS[1]:                         ip = ::1/128, gw = :: 
-</code> 
- 
-Pour consulter les paramètres d'un profil, utilisez la commande suivante : 
- 
-<code> 
-root@debian8:~# nmcli -p connection show "Wired connection 1" 
-=============================================================================== 
-                Connection profile details (Wired connection 1) 
-=============================================================================== 
-connection.id:                          Wired connection 1 
-connection.uuid:                        0caa0d4f-0222-415a-8a4f-753ca284911e 
-connection.interface-name:              -- 
-connection.type:                        802-3-ethernet 
-connection.autoconnect:                 yes 
-connection.timestamp:                   1446544245 
-connection.read-only:                   no 
-connection.permissions:                  
-connection.zone:                        -- 
-connection.master:                      -- 
-connection.slave-type:                  -- 
-connection.secondaries:                  
-connection.gateway-ping-timeout:        0 
-------------------------------------------------------------------------------- 
-802-3-ethernet.port:                    -- 
-802-3-ethernet.speed:                   0 
-802-3-ethernet.duplex:                  -- 
-802-3-ethernet.auto-negotiate:          yes 
-802-3-ethernet.mac-address:             -- 
-802-3-ethernet.cloned-mac-address:      -- 
-802-3-ethernet.mac-address-blacklist:    
-802-3-ethernet.mtu:                     auto 
-802-3-ethernet.s390-subchannels:         
-802-3-ethernet.s390-nettype:            -- 
-802-3-ethernet.s390-options:             
-------------------------------------------------------------------------------- 
-ipv4.method:                            auto 
-ipv4.dns:                                
-ipv4.dns-search:                         
-ipv4.addresses:                          
-ipv4.routes:                             
-ipv4.ignore-auto-routes:                no 
-ipv4.ignore-auto-dns:                   no 
-ipv4.dhcp-client-id:                    -- 
-ipv4.dhcp-send-hostname:                yes 
-ipv4.dhcp-hostname:                     -- 
-ipv4.never-default:                     no 
-ipv4.may-fail:                          yes 
-------------------------------------------------------------------------------- 
-ipv6.method:                            auto 
-ipv6.dns:                                
-ipv6.dns-search:                         
-ipv6.addresses:                          
-ipv6.routes:                             
-ipv6.ignore-auto-routes:                no 
-ipv6.ignore-auto-dns:                   no 
-ipv6.never-default:                     no 
-ipv6.may-fail:                          yes 
-ipv6.ip6-privacy:                       2 (enabled, prefer temporary IP) 
-ipv6.dhcp-hostname:                     -- 
-------------------------------------------------------------------------------- 
-</code> 
- 
-Pour consulter la liste profils associés à un périphérique, utilisez la commande suivante : 
- 
-<code> 
-root@debian8:~# nmcli -f CONNECTIONS device show eth0 
-CONNECTIONS.AVAILABLE-CONNECTION-PATHS: /org/freedesktop/NetworkManager/Settings/{1,0} 
-CONNECTIONS.AVAILABLE-CONNECTIONS[1]:   ec7e2b5f-0d19-4a40-8639-24af88a59d79 | ip_fixe 
-CONNECTIONS.AVAILABLE-CONNECTIONS[2]:   0caa0d4f-0222-415a-8a4f-753ca284911e | Wired connection 1 
-</code> 
- 
-Sous Debian 8, les fichiers de configuration pour le periphérique **eth0** se trouvent dans le répertoire **/etc/NetworkManager/system-connections** : 
- 
-<code> 
-root@debian8:~# ls -l /etc/NetworkManager/system-connections 
-total 8 
--rw------- 1 root root 207 Nov  3 12:00 ip_fixe 
--rw------- 1 root root 170 Oct 23 16:44 Wired connection 1 
-</code> 
- 
-L'étude du fichier **/etc/NetworkManager/system-connections/ip_fixe** démontre l'abscence de directives concernant les DNS : 
- 
-<code> 
-root@debian8:~# cat /etc/NetworkManager/system-connections/ip_fixe 
-[connection] 
-id=ip_fixe 
-uuid=ec7e2b5f-0d19-4a40-8639-24af88a59d79 
-interface-name=eth0 
-type=ethernet 
-timestamp=1446548328 
- 
-[ipv6] 
-method=auto 
- 
-[ipv4] 
-method=manual 
-address1=10.0.2.16/24,10.0.2.2 
-</code> 
- 
-La résolution des noms est donc inactive : 
- 
-<code> 
-root@debian8:~# ping www.free.fr 
-ping: unknown host www.free.fr 
-</code> 
- 
-Modifiez donc la configuration du profil **ip_fixe** : 
- 
-<code> 
-root@debian8:~# nmcli connection mod ip_fixe ipv4.dns 8.8.8.8 
-</code> 
- 
-Sous Debian 8 l'étude du fichier **/etc/NetworkManager/system-connections/ip_fixe** démontre que la directive concernant le serveur DNS a été ajoutée : 
- 
-<code> 
-root@debian8:~# cat /etc/NetworkManager/system-connections/ip_fixe 
-[connection] 
-id=ip_fixe 
-uuid=ec7e2b5f-0d19-4a40-8639-24af88a59d79 
-interface-name=eth0 
-type=ethernet 
-timestamp=1446548328 
- 
-[ipv6] 
-method=auto 
- 
-[ipv4] 
-method=manual 
-dns=8.8.8.8; 
-address1=10.0.2.16/24,10.0.2.2 
-</code> 
- 
-Afin que la modification du serveur DNS soit prise en compte, re-démarrez le service NetworkManager : 
- 
-<code> 
-root@debian8:~# systemctl restart NetworkManager.service 
-  
-root@debian8:~# systemctl status NetworkManager.service 
-● NetworkManager.service - Network Manager 
-   Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled) 
-   Active: active (running) since Tue 2015-11-03 12:08:26 CET; 34s ago 
- Main PID: 2991 (NetworkManager) 
-   CGroup: /system.slice/NetworkManager.service 
-           └─2991 /usr/sbin/NetworkManager --no-daemon 
- 
-Nov 03 12:08:26 debian8 NetworkManager[2991]: <info> Activation (eth0) Stage 5 of 5 (IPv4 Commit) complete. 
-Nov 03 12:08:26 debian8 NetworkManager[2991]: <info> Activation (eth0) Stage 5 of 5 (IPv6 Commit) started... 
-Nov 03 12:08:26 debian8 NetworkManager[2991]: <info> Activation (eth0) Stage 5 of 5 (IPv6 Commit) complete. 
-Nov 03 12:08:26 debian8 NetworkManager[2991]: <info> (eth0): device state change: ip-check -> secondaries (reason 'none') [80 90 0] 
-Nov 03 12:08:26 debian8 NetworkManager[2991]: <info> (eth0): device state change: secondaries -> activated (reason 'none') [90 100 0] 
-Nov 03 12:08:26 debian8 NetworkManager[2991]: <info> NetworkManager state is now CONNECTED_LOCAL 
-Nov 03 12:08:26 debian8 NetworkManager[2991]: <info> NetworkManager state is now CONNECTED_GLOBAL 
-Nov 03 12:08:26 debian8 NetworkManager[2991]: <info> Policy set 'eth0' (eth0) as default for IPv4 routing and DNS. 
-Nov 03 12:08:26 debian8 NetworkManager[2991]: <info> Activation (eth0) successful, device activated. 
-Nov 03 12:08:31 debian8 NetworkManager[2991]: <info> startup complete 
-</code> 
- 
-Vérifiez que le fichier **/etc/resolv.conf** ait été modifié par NetworkManager : 
- 
-<code> 
-root@debian8:~# cat /etc/resolv.conf 
-# Generated by NetworkManager 
-nameserver 8.8.8.8 
-</code> 
- 
-Dernièrement vérifiez la resolution des noms : 
- 
-<code> 
-root@debian8:~# ping www.free.fr 
-PING www.free.fr (212.27.48.10) 56(84) bytes of data. 
-64 bytes from www.free.fr (212.27.48.10): icmp_seq=1 ttl=63 time=44.9 ms 
-^C 
---- www.free.fr ping statistics --- 
-2 packets transmitted, 1 received, 50% packet loss, time 1001ms 
-rtt min/avg/max/mdev = 44.994/44.994/44.994/0.000 ms 
-</code> 
- 
-<WRAP center round important> 
-**Important** : Notez qu'il existe un front-end graphique en mode texte, **nmtui**, pour configurer NetworkManager. 
-</WRAP> 
- 
-====Ajouter une Deuxième Adresse IP à un Profil==== 
- 
-Pour ajouter une deuxième adresse IP à un profil sous Debian 8, il convient d'utiliser la commande suivante : 
- 
-<code> 
-root@debian8:~# nmcli connection mod ip_fixe +ipv4.addresses 192.168.1.2/24 
-</code> 
- 
-Redémarrez la machine virtuelle puis en tant que root saisissez la commande suivante : 
- 
-<code> 
-root@debian8:~# nmcli connection show ip_fixe 
-connection.id:                          ip_fixe 
-connection.uuid:                        ec7e2b5f-0d19-4a40-8639-24af88a59d79 
-connection.interface-name:              eth0 
-connection.type:                        802-3-ethernet 
-connection.autoconnect:                 yes 
-connection.timestamp:                   1446560745 
-connection.read-only:                   no 
-connection.permissions:                  
-connection.zone:                        -- 
-connection.master:                      -- 
-connection.slave-type:                  -- 
-connection.secondaries:                  
-connection.gateway-ping-timeout:        0 
-802-3-ethernet.port:                    -- 
-802-3-ethernet.speed:                   0 
-802-3-ethernet.duplex:                  -- 
-802-3-ethernet.auto-negotiate:          yes 
-802-3-ethernet.mac-address:             -- 
-802-3-ethernet.cloned-mac-address:      -- 
-802-3-ethernet.mac-address-blacklist:    
-802-3-ethernet.mtu:                     auto 
-802-3-ethernet.s390-subchannels:         
-802-3-ethernet.s390-nettype:            -- 
-802-3-ethernet.s390-options:             
-ipv4.method:                            manual 
-ipv4.dns:                               8.8.8.8 
-ipv4.dns-search:                         
-ipv4.addresses:                         { ip = 10.0.2.16/24, gw = 10.0.2.2 }; { ip = 192.168.1.2/24, gw = 0.0.0.0 } 
-ipv4.routes:                             
-ipv4.ignore-auto-routes:                no 
-ipv4.ignore-auto-dns:                   no 
-ipv4.dhcp-client-id:                    -- 
-ipv4.dhcp-send-hostname:                yes 
-ipv4.dhcp-hostname:                     -- 
-ipv4.never-default:                     no 
-ipv4.may-fail:                          yes 
-ipv6.method:                            auto 
-ipv6.dns:                                
-ipv6.dns-search:                         
-ipv6.addresses:                          
-ipv6.routes:                             
-ipv6.ignore-auto-routes:                no 
-ipv6.ignore-auto-dns:                   no 
-ipv6.never-default:                     no 
-ipv6.may-fail:                          yes 
-ipv6.ip6-privacy:                       -1 (unknown) 
-ipv6.dhcp-hostname:                     -- 
-GENERAL.NAME:                           ip_fixe 
-GENERAL.UUID:                           ec7e2b5f-0d19-4a40-8639-24af88a59d79 
-GENERAL.DEVICES:                        eth0 
-GENERAL.STATE:                          activated 
-GENERAL.DEFAULT:                        yes 
-GENERAL.DEFAULT6:                       no 
-GENERAL.VPN:                            no 
-GENERAL.ZONE:                           -- 
-GENERAL.DBUS-PATH:                      /org/freedesktop/NetworkManager/ActiveConnection/1 
-GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/Settings/1 
-GENERAL.SPEC-OBJECT:                    -- 
-GENERAL.MASTER-PATH:                    -- 
-IP4.ADDRESS[1]:                         ip = 10.0.2.16/24, gw = 10.0.2.2 
-IP4.ADDRESS[2]:                         ip = 192.168.1.2/24, gw = 10.0.2.2 
-IP4.ROUTE[1]:                           dst = 169.254.0.0/16, nh = 0.0.0.0, mt = 1000 
-IP4.DNS[1]:                             8.8.8.8 
-IP6.ADDRESS[1]:                         ip = fe80::a00:27ff:fef2:8c8f/64, gw = :: 
-</code> 
- 
-<WRAP center round important> 
-**Important** : Notez l'ajout de la ligne **IP4.ADDRESS[2]:**. 
-</WRAP> 
- 
-Sous Debian 8, consultez maintenant le contenu du fichier **/etc/NetworkManager/system-connections/ip_fixe** : 
- 
-<code> 
-[root@debian8:~# cat /etc/NetworkManager/system-connections/ip_fixe 
-[connection] 
-id=ip_fixe 
-uuid=ec7e2b5f-0d19-4a40-8639-24af88a59d79 
-interface-name=eth0 
-type=ethernet 
-timestamp=1446551688 
- 
-[ipv6] 
-method=auto 
- 
-[ipv4] 
-method=manual 
-dns=8.8.8.8; 
-address1=10.0.2.16/24,10.0.2.2 
-address2=192.168.1.2/24 
-</code> 
- 
-<WRAP center round important> 
-**Important** : Notez l'ajout de la ligne **address2=192.168.1.2/24**. 
-</WRAP> 
- 
-====La Commande hostname==== 
- 
-La procédure de la modification du hostname est simplifiée et sa prise en compte est immédiate : 
- 
-<code> 
-root@debian8:~# nmcli general hostname debian.fenestros.loc 
- 
-root@debian8:~# hostname 
-debian.fenestros.loc 
- 
-root@debian8:~# cat /etc/hostname 
-debian.fenestros.loc 
- 
-root@debian8:~# nmcli general hostname debian8.fenestros.loc 
- 
-root@debian8:~# hostname 
-debian8.fenestros.loc 
- 
-root@debian8:~# cat /etc/hostname 
-debian8.fenestros.loc 
-</code> 
- 
-====La Commande ip==== 
- 
-Sous Debian 8 la commande **ip** est préférée par rapport à la commande ifconfig : 
- 
-<code> 
-root@debian8:~# ip address 
-1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default  
-    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 
-    inet 127.0.0.1/8 scope host lo 
-       valid_lft forever preferred_lft forever 
-    inet6 ::1/128 scope host  
-       valid_lft forever preferred_lft forever 
-2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 
-    link/ether 08:00:27:f2:8c:8f brd ff:ff:ff:ff:ff:ff 
-    inet 10.0.2.16/24 brd 10.0.2.255 scope global eth0 
-       valid_lft forever preferred_lft forever 
-    inet 192.168.1.2/24 brd 192.168.1.255 scope global eth0 
-       valid_lft forever preferred_lft forever 
-    inet6 fe80::a00:27ff:fef2:8c8f/64 scope link  
-       valid_lft forever preferred_lft forever 
-</code> 
- 
-===Options de la Commande ip=== 
- 
-Les options de cette commande sont : 
- 
-<code> 
-root@debian8:~# ip --help 
-Usage: ip [ OPTIONS ] OBJECT { COMMAND | help } 
-       ip [ -force ] -batch filename 
-where  OBJECT := { link | addr | addrlabel | route | rule | neigh | ntable | 
-                   tunnel | tuntap | maddr | mroute | mrule | monitor | xfrm | 
-                   netns | l2tp | tcp_metrics | token | netconf } 
-       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] | 
-                    -f[amily] { inet | inet6 | ipx | dnet | bridge | link } | 
-                    -4 | -6 | -I | -D | -B | -0 | 
-                    -l[oops] { maximum-addr-flush-attempts } | 
-                    -o[neline] | -t[imestamp] | -b[atch] [filename] | 
-                    -rc[vbuf] [size]} 
-</code> 
- 
-====Activer/Désactiver une Interface Manuellement==== 
- 
-Deux commandes existent pour désactiver et activer manuellement une interface réseau : 
- 
-<code> 
-root@debian8:~# nmcli device disconnect eth0 
-root@debian8:~# nmcli device connect eth0 
-</code> 
- 
-====Routage Statique==== 
- 
-===La commande ip=== 
- 
-Sous Debian 8, pour supprimer la route vers le réseau 192.168.1.0 il convient d'utiliser la commande ip et non pas la commande route : 
- 
-<code> 
-root@debian8:~# ip route 
-default via 10.0.2.2 dev enp0s3  proto static  metric 100  
-10.0.2.0/24 dev enp0s3  proto kernel  scope link  src 10.0.2.16  metric 100  
-192.168.1.0/24 dev enp0s3  proto kernel  scope link  src 192.168.1.2  metric 100  
- 
-root@debian8:~# ip route del 192.168.1.0/24 via 0.0.0.0 
- 
-root@debian8:~# ip route 
-default via 10.0.2.2 dev enp0s3  proto static  metric 100  
-10.0.2.0/24 dev enp0s3  proto kernel  scope link  src 10.0.2.16  metric 100  
-</code> 
- 
-Pour ajouter la route vers le réseau 192.168.1.0 : 
- 
-<code> 
-root@debian8:~# ip route add 192.168.1.0/24 via 10.0.2.2 
- 
-root@debian8:~# ip route 
-default via 10.0.2.2 dev enp0s3  proto static  metric 100  
-10.0.2.0/24 dev enp0s3  proto kernel  scope link  src 10.0.2.16  metric 100  
-192.168.1.0/24 via 10.0.2.2 dev enp0s3 
-</code> 
- 
-<WRAP center round important> 
-La commande utilisée pour ajouter une passerelle par défaut prend la forme suivante **ip route add default via //adresse ip//**. 
-</WRAP> 
- 
-===Activer/désactiver le routage sur le serveur=== 
- 
-Pour activer le routage sur le serveur, il convient d'activer la retransmission des paquets: 
- 
-<code> 
-root@debian8:~# echo 1 > /proc/sys/net/ipv4/ip_forward 
-root@debian8:~# cat /proc/sys/net/ipv4/ip_forward 
-1 
-</code> 
- 
-Pour désactiver le routage sur le serveur, il convient de désactiver la retransmission des paquets: 
- 
-<code> 
-root@debian8:~# echo 0 > /proc/sys/net/ipv4/ip_forward 
-root@debian8:~# cat /proc/sys/net/ipv4/ip_forward 
-0 
 </code> </code>
  
Ligne 2963: Ligne 3768:
 </code> </code>
  
-=====Diagnostique du Réseau=====+=====LAB #4 - Utilisation de nmap et de netcat=====
  
-====ping====+==== 4.1 - nmap ====
  
-Pour tester l'accessibilité d'une machine, vous devez utiliser la commande **ping** :+===Installation===
  
-<code> +Sous RHEL/CentOS 7**nmap** n'est pas installé par défaut :
-root@debian8:~# ping 10.0.2.2 +
-PING 10.0.2.2 (10.0.2.2) 56(84) bytes of data. +
-64 bytes from 10.0.2.2: icmp_seq=1 ttl=64 time=0.095 ms +
-64 bytes from 10.0.2.2: icmp_seq=2 ttl=64 time=0.153 ms +
-64 bytes from 10.0.2.2: icmp_seq=3 ttl=64 time=0.137 ms +
-^C +
---- 10.0.2.2 ping statistics --- +
-3 packets transmitted3 received, 0% packet loss, time 2000ms +
-rtt min/avg/max/mdev = 0.095/0.128/0.153/0.026 ms +
-</code> +
- +
-===Options de la commande ping=== +
- +
-Les options de cette commande sont :+
  
 <code> <code>
-root@debian8:~# ping --help +[root@centos7 ~]which nmap 
-pinginvalid option -- '-' +/usr/bin/whichno nmap in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
-Usageping [-aAbBdDfhLnOqrRUvV] [-c count] [-i interval] [-I interface] +
-            [-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos] +
-            [-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option] +
-            [-w deadline] [-W timeout] [hop1 ...] destination+
 </code> </code>
  
-====netstat -i==== +Installez donc nmap en utilisant yum :
- +
-Pour visualiser les statistiques réseaux, vous disposez de la commande **netstat** :+
  
 <code> <code>
-root@debian8:~# netstat -i +[root@centos7 ~]yum install nmap 
-Kernel Interface table +Loaded plugins: fastestmirror, langpacks 
-Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg +Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast 
-eth0       1500 0       489      0      0 0           596      0      0      0 BMRU +adobe-linux-x86_64                                       | 2.9 kB     00:00      
-lo        65536 0     28623      0      0 0         28623      0      0      0 LRU +base                                                     | 3.6 kB     00:00      
-</code>+extras                                                   | 3.4 kB     00:00      
 +updates                                                  | 3.4 kB     00:00      
 +(1/3): adobe-linux-x86_64/primary_db                       | 2.7 kB   00:00      
 +(2/3): extras/7/x86_64/primary_db                          | 191 kB   00:00      
 +(3/3): updates/7/x86_64/primary_db                         | 7.8 MB   00:04      
 +Determining fastest mirrors 
 + * base: ftp.rezopole.net 
 + * extras: ftp.rezopole.net 
 + * updates: ftp.rezopole.net 
 +Resolving Dependencies 
 +--> Running transaction check 
 +---> Package nmap.x86_64 2:6.40-7.el7 will be installed 
 +--> Processing Dependency: nmap-ncat = 2:6.40-7.el7 for package: 2:nmap-6.40-7.el7.x86_64 
 +--> Running transaction check 
 +---> Package nmap-ncat.x86_64 2:6.40-7.el7 will be installed 
 +--Finished Dependency Resolution
  
-===Options de la commande netstat===+Dependencies Resolved
  
-Les options de cette commande sont :+================================================================================ 
 + Package            Arch            Version                 Repository     Size 
 +================================================================================ 
 +Installing: 
 + nmap               x86_64          2:6.40-7.el7            base          4.0 M 
 +Installing for dependencies: 
 + nmap-ncat          x86_64          2:6.40-7.el7            base          201 k
  
-<code> +Transaction Summary 
-root@debian8:~# netstat --help +================================================================================ 
-usage: netstat [-vWeenNcCF] [<Af>] -r         netstat {-V|--version|-h|--help} +Install  1 Package (+1 Dependent package)
-       netstat [-vWnNcaeol] [<Socket> ...] +
-       netstat { [-vWeenNac] -i | [-cWnNe] -M | -s }+
  
-        -r, --route              display routing table +Total download size: 4.2 M 
-        -i, --interfaces         display interface table +Installed size: 17 
-        -g, --groups             display multicast group memberships +Is this ok [y/d/N]y
-        -s, --statistics         display networking statistics (like SNMP) +
-        -M, --masquerade         display masqueraded connections +
- +
-        -v, --verbose            be verbose +
-        -W, --wide               don't truncate IP addresses +
-        -n, --numeric            don't resolve names +
-        --numeric-hosts          don't resolve host names +
-        --numeric-ports          don't resolve port names +
-        --numeric-users          don't resolve user names +
-        -N, --symbolic           resolve hardware names +
-        -e, --extend             display other/more information +
-        -p, --programs           display PID/Program name for sockets +
-        -c, --continuous         continuous listing +
- +
-        -l, --listening          display listening server sockets +
-        -a, --all, --listening   display all sockets (defaultconnected) +
-        -o, --timers             display timers +
-        -F, --fib                display Forwarding Information Base (default) +
-        -C, --cache              display routing cache instead of FIB +
- +
-  <Socket>={-t|--tcp} {-u|--udp} {-w|--raw} {-x|--unix} --ax25 --ipx --netrom +
-  <AF>=Use '-6|-4' or '-A <af>' or '--<af>'; default: inet +
-  List of possible address families (which support routing): +
-    inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25)  +
-    netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP)  +
-    x25 (CCITT X.25)+
 </code> </code>
- 
-====La commande traceroute==== 
- 
-La commande ping est à la base de la commande **traceroute**. Cette commande sert à découvrir la route empruntée pour accéder à un site donné : 
- 
-<code> 
-root@debian8:~# traceroute www.i2tch.eu 
-traceroute to www.i2tch.eu (217.160.122.33), 30 hops max, 60 byte packets 
-  10.0.2.2 (10.0.2.2)  0.091 ms  0.056 ms  0.070 ms 
-  192.168.0.1 (192.168.0.1)  0.260 ms  0.190 ms  0.205 ms 
-  * * * 
-  195-132-10-137.rev.numericable.fr (195.132.10.137)  15.769 ms  15.711 ms  15.646 ms 
-  ip-190.net-80-236-8.asnieres.rev.numericable.fr (80.236.8.190)  15.581 ms  27.137 ms  27.053 ms 
-  ip-185.net-80-236-8.asnieres.rev.numericable.fr (80.236.8.185)  27.070 ms  10.356 ms  10.184 ms 
-  172.19.132.146 (172.19.132.146)  16.374 ms  16.357 ms  16.265 ms 
-  oneandone.franceix.net (37.49.236.42)  25.843 ms  25.539 ms  25.280 ms 
-  ae-8-0.bb-a.bap.rhr.de.oneandone.net (212.227.120.42)  21.347 ms  21.291 ms  25.058 ms 
-10  * * * 
-11  * * * 
-12  * * * 
-13  * * * 
-14  *^C 
-</code> 
- 
-===Options de la commande traceroute=== 
  
 Les options de cette commande sont : Les options de cette commande sont :
  
 <code> <code>
-root@debian8:~# traceroute --help +[root@centos7 ~]nmap --help 
-Usage+Nmap 6.40 ( http://nmap.org ) 
-  traceroute -46dFITnreAUDV ] [ -f first_ttl [ -g gate,... ] [ -i device ] [ -m max_ttl ] [ -N squeries ] [ -p port ] [ -t tos ] [ -l flow_label ] -w waittime ] [ -q nqueries -s src_addr ] [ -z sendwait ] [ --fwmark=num ] host [ packetlen ] +Usage: nmap [Scan Type(s)] [Options{target specification} 
-Options+TARGET SPECIFICATION: 
-  -4                          Use IPv4 +  Can pass hostnamesIP addresses, networks, etc. 
-  -6                          Use IPv6 +  Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254 
-  -d  --debug                 Enable socket level debugging +  -iL <inputfilename>: Input from list of hosts/networks 
-  - --dont-fragment         Do not fragment packets +  -iR <num hosts>: Choose random targets 
-  -f first_ttl  --first=first_ttl +  --exclude <host1[,host2][,host3],...>: Exclude hosts/networks 
-                              Start from the first_ttl hop (instead from 1) +  --excludefile <exclude_file>: Exclude list from file 
-  -g gate,...  --gateway=gate,... +HOST DISCOVERY
-                              Route packets through the specified gateway +  -sL: List Scan - simply list targets to scan 
-                              (maximum 8 for IPv4 and 127 for IPv6) +  -sn: Ping Scan - disable port scan 
-  -I  --icmp                  Use ICMP ECHO for tracerouting +  -Pn: Treat all hosts as online -- skip host discovery 
-  - --tcp                   Use TCP SYN for tracerouting (default port is 80+  -PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports 
-  -i device  --interface=device +  -PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes 
-                              Specify a network interface to operate with +  -PO[protocol list]: IP Protocol Ping 
-  -m max_ttl  --max-hops=max_ttl +  -n/-R: Never do DNS resolution/Always resolve [default: sometimes] 
-                              Set the max number of hops (max TTL to be +  --dns-servers <serv1[,serv2],...>: Specify custom DNS servers 
-                              reached). Default is 30 +  --system-dns: Use OS's DNS resolver 
-  -N squeries  --sim-queries=squeries +  --traceroute: Trace hop path to each host 
-                              Set the number of probes to be tried +SCAN TECHNIQUES: 
-                              simultaneously (default is 16) +  -sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans 
-  -n                          Do not resolve IP addresses to their domain names +  -sU: UDP Scan 
-  -p port  --port=port        Set the destination port to use. It is either +  -sN/sF/sX: TCP Null, FIN, and Xmas scans 
-                              initial udp port value for "default" method +  --scanflags <flags>: Customize TCP scan flags 
-                              (incremented by each probe, default is 33434), or +  -sI <zombie host[:probeport]>: Idle scan 
-                              initial seq for "icmp" (incremented as well, +  -sY/sZ: SCTP INIT/COOKIE-ECHO scans 
-                              default from 1), or some constant destination +  -sO: IP protocol scan 
-                              port for other methods (with default of 80 for +  -b <FTP relay host>: FTP bounce scan 
-                              "tcp", 53 for "udp", etc.+PORT SPECIFICATION AND SCAN ORDER: 
-  -t tos  --tos=tos           Set the TOS (IPv4 type of serviceor TC (IPv6 +  -p <port ranges>: Only scan specified ports 
-                              traffic class) value for outgoing packets +    Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9 
-  -l flow_label  --flowlabel=flow_label +  -F: Fast mode - Scan fewer ports than the default scan 
-                              Use specified flow_label for IPv6 packets +  -r: Scan ports consecutively - don't randomize 
-  -w waittime  --wait=waittime +  --top-ports <number>: Scan <number> most common ports 
-                              Set the number of seconds to wait for response to +  --port-ratio <ratio>: Scan ports more common than <ratio> 
-                              probe (default is 5.0). Non-integer (float +SERVICE/VERSION DETECTION: 
-                              point) values allowed too +  -sV: Probe open ports to determine service/version info 
-  -q nqueries  --queries=nqueries +  --version-intensity <level>: Set from 0 (lightto 9 (try all probes
-                              Set the number of probes per each hopDefault is +  --version-light: Limit to most likely probes (intensity 2
-                              3 +  --version-all: Try every single probe (intensity 9
-  -r                          Bypass the normal routing and send directly to a +  --version-trace: Show detailed version scan activity (for debugging) 
-                              host on an attached network +SCRIPT SCAN: 
-  -s src_addr  --source=src_addr +  -sC: equivalent to --script=default 
-                              Use source src_addr for outgoing packets +  --script=<Lua scripts>: <Lua scripts> is a comma separated list of  
-  -z sendwait  --sendwait=sendwait +           directories, script-files or script-categories 
-                              Minimal time interval between probes (default 0)+  --script-args=<n1=v1,[n2=v2,...]>: provide arguments to scripts 
-                              If the value is more than 10then it specifies a +  --script-args-file=filename: provide NSE script args in file 
-                              number in milliseconds, else it is a number of +  --script-trace: Show all data sent and received 
-                              seconds (float point values allowed too+  --script-updatedb: Update the script database. 
-  -e  --extensions            Show ICMP extensions (if present), including MPLS +  --script-help=<Lua scripts>: Show help about scripts. 
-  - --as-path-lookups       Perform AS path lookups in routing registries and +           <Lua scripts> is a comma separted list of script-files or 
-                              print results directly after the corresponding +           script-categories
-                              addresses +OS DETECTION: 
-  -M name  --module=name      Use specified module (either builtin or external) +  -O: Enable OS detection 
-                              for traceroute operations. Most methods have +  --osscan-limit: Limit OS detection to promising targets 
-                              their shortcuts (`-I' means `-M icmp' etc.+  --osscan-guess: Guess OS more aggressively 
-  -O OPTS,...  --options=OPTS,... +TIMING AND PERFORMANCE: 
-                              Use module-specific option OPTS for the +  Options which take <time> are in seconds, or append 'ms' (milliseconds), 
-                              traceroute module. Several OPTS allowed, +  's' (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30m). 
-                              separated by comma. If OPTS is "help", print info +  -T<0-5>: Set timing template (higher is faster
-                              about available options +  --min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes 
-  --sport=num                 Use source port num for outgoing packets. Implies +  --min-parallelism/max-parallelism <numprobes>: Probe parallelization 
-                              `-N 1' +  --min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies 
-  --fwmark=num                Set firewall mark for outgoing packets +      probe round trip time. 
-  - --udp                   Use UDP to particular port for tracerouting +  --max-retries <tries>: Caps number of port scan probe retransmissions. 
-                              (instead of increasing the port per each probe), +  --host-timeout <time>: Give up on target after this long 
-                              default port is 53 +  --scan-delay/--max-scan-delay <time>: Adjust delay between probes 
-  -UL                         Use UDPLITE for tracerouting (default dest port +  --min-rate <number>: Send packets no slower than <number> per second 
-                              is 53+  --max-rate <number>: Send packets no faster than <number> per second 
-  - --dccp                  Use DCCP Request for tracerouting (default port +FIREWALL/IDS EVASION AND SPOOFING: 
-                              is 33434+  -f; --mtu <val>: fragment packets (optionally w/given MTU
-  -P prot  --protocol=prot    Use raw packet of protocol prot for tracerouting +  -D <decoy1,decoy2[,ME],...>: Cloak a scan with decoys 
-  --mtu                       Discover MTU along the path being traced. Implies +  -S <IP_Address>: Spoof source address 
-                              `--N 1' +  -e <iface>: Use specified interface 
-  --back                      Guess the number of hops in the backward path and +  -g/--source-port <portnum>: Use given port number 
-                              print if it differs +  --data-length <num>: Append random data to sent packets 
-  - --version               Print version info and exit +  --ip-options <options>: Send packets with specified ip options 
-  --help                      Read this help and exit +  --ttl <val>: Set IP time-to-live field 
- +  --spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address 
-Arguments+  --badsum: Send packets with a bogus TCP/UDP/SCTP checksum 
-+     host          The host to traceroute to +OUTPUT: 
-      packetlen     The full packet length (default is the length of an IP +  -oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3, 
-                    header plus 40)Can be ignored or increased to a minimal +     and Grepable format, respectively, to the given filename. 
-                    allowed value+  -oA <basename>: Output in the three major formats at once 
 +  -v: Increase verbosity level (use -vv or more for greater effect) 
 +  -d: Increase debugging level (use -dd or more for greater effect
 +  --reason: Display the reason a port is in a particular state 
 +  --open: Only show open (or possibly openports 
 +  --packet-trace: Show all packets sent and received 
 +  --iflist: Print host interfaces and routes (for debugging
 +  --log-errors: Log errors/warnings to the normal-format output file 
 +  --append-output: Append to rather than clobber specified output files 
 +  --resume <filename>: Resume an aborted scan 
 +  --stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML 
 +  --webxml: Reference stylesheet from Nmap.Org for more portable XML 
 +  --no-stylesheet: Prevent associating of XSL stylesheet w/XML output 
 +MISC: 
 +  -6: Enable IPv6 scanning 
 +  -A: Enable OS detection, version detection, script scanning, and traceroute 
 +  --datadir <dirname>: Specify custom Nmap data file location 
 +  --send-eth/--send-ip: Send using raw ethernet frames or IP packets 
 +  --privileged: Assume that the user is fully privileged 
 +  --unprivileged: Assume the user lacks raw socket privileges 
 +  -V: Print version number 
 +  -h: Print this help summary page. 
 +EXAMPLES
 +  nmap -v -A scanme.nmap.org 
 +  nmap -v -sn 192.168.0.0/16 10.0.0.0/8 
 +  nmap -v -iR 10000 -Pn -p 80 
 +SEE THE MAN PAGE (http://nmap.org/book/man.html) FOR MORE OPTIONS AND EXAMPLES
 </code> </code>
  
-=====Connexions à Distance=====+===Utilisation===
  
-==== Telnet ==== +Pour connaître la liste des ports ouverts sur votre machine virtuellesaisissez la commande suivante :
- +
-La commande **telnet** est utilisée pour établir une connexion à distance avec un serveur telnet : +
- +
-<file> +
-  # telnet numero_ip +
-</file> +
- +
-<WRAP center round important> +
-Le service telnet revient à une redirection des canaux standards d'entrée et de sortie. Notez que la connexion n'est **pas** sécurisée. Pour fermer la connexionil faut saisir la commande **exit**. La commande telnet n'offre pas de services de transfert de fichiers. Pour cela, il convient d'utiliser la command **ftp**. +
-</WRAP> +
- +
-===Options de la commande telnet=== +
- +
-Les options de cette commande sont :+
  
 <code> <code>
-root@debian8:~# telnet --help +[root@centos7 ~]# nmap 127.0.0.1
-telnet: invalid option -- '-' +
-Usage: telnet [-4[-6] [-8] [-E] [-L] [-a] [-d] [-e char] [-l user] +
- [-n tracefile] [ -b addr ] [-r] [host-name [port]] +
-</code> +
- +
-==== wget ==== +
- +
-La commande **wget** est utilisée pour récupérer un fichier via http ou ftp :  +
- +
-<code> +
-root@debian8:~wget https://www.dropbox.com/s/li5tyou8msofuwb/fichier_test?dl=0 +
---2017-06-22 15:58:28--  https://www.dropbox.com/s/li5tyou8msofuwb/fichier_test?dl=0 +
-Resolving www.dropbox.com (www.dropbox.com)... 162.125.65.1 +
-Connecting to www.dropbox.com (www.dropbox.com)|162.125.65.1|:443... connected. +
-HTTP request sent, awaiting response... 302 Found +
-Location: https://dl.dropboxusercontent.com/content_link/DWSZfzGE6aRiRjGhALuA1VZTLwR9OLGZmTFKef0Cq1PdVJUuIXxfApaV4D13DopI/file [following] +
---2017-06-22 15:58:30--  https://dl.dropboxusercontent.com/content_link/DWSZfzGE6aRiRjGhALuA1VZTLwR9OLGZmTFKef0Cq1PdVJUuIXxfApaV4D13DopI/file +
-Resolving dl.dropboxusercontent.com (dl.dropboxusercontent.com)... 162.125.65.6 +
-Connecting to dl.dropboxusercontent.com (dl.dropboxusercontent.com)|162.125.65.6|:443... connected. +
-HTTP request sent, awaiting response... 200 OK +
-Length: 17 [text/plain] +
-Saving to: ‘fichier_test?dl=0’+
  
-fichier_test?dl=0   100%[=====================>     17  --.-KB/s   in 0s     +Starting Nmap 6.40 ( http://nmap.org ) at 2017-08-05 14:17 CEST 
 +Nmap scan report for localhost.localdomain (127.0.0.1) 
 +Host is up (-2100s latency). 
 +Not shown: 996 closed ports 
 +PORT    STATE SERVICE 
 +22/tcp  open  ssh 
 +25/tcp  open  smtp 
 +111/tcp open  rpcbind 
 +631/tcp open  ipp
  
-2017-06-22 15:58:31 (3.53 MB/s- ‘fichier_test?dl=0’ saved [17/17]+Nmap done1 IP address (1 host upscanned in 0.06 seconds
 </code> </code>
  
-===Options de la commande wget===+<WRAP center round important 50%> 
 +**Important** - Pour connaître les ports ouverts sur une machine distante, la procédure est identique sauf que vous devez utiliser l'adresse IP de votre cible. 
 +</WRAP>
  
-Les options de cette commande sont :+===Fichiers de Configuration===
  
-<code> +**nmap** utilise un fichier spécifique pour identifier les portsCe fichier est **/usr/share/nmap/nmap-services**:
-root@debian8:~# wget --help +
-GNU Wget 1.16, a non-interactive network retriever. +
-Usage: wget [OPTION]... [URL]... +
- +
-Mandatory arguments to long options are mandatory for short options too. +
- +
-Startup: +
-  -V,  --version                   display the version of Wget and exit. +
-  -h,  --help                      print this help. +
-  -b,  --background                go to background after startup. +
-  -e,  --execute=COMMAND           execute a `.wgetrc'-style command. +
- +
-Logging and input file: +
-  -o,  --output-file=FILE          log messages to FILE. +
-  -a,  --append-output=FILE        append messages to FILE. +
-  -d,  --debug                     print lots of debugging information. +
-  -q,  --quiet                     quiet (no output). +
-  -v,  --verbose                   be verbose (this is the default). +
-  -nv, --no-verbose                turn off verboseness, without being quiet. +
-       --report-speed=TYPE         Output bandwidth as TYPE.  TYPE can be bits. +
-  -i,  --input-file=FILE           download URLs found in local or external FILE. +
-  -F,  --force-html                treat input file as HTML. +
-  -B,  --base=URL                  resolves HTML input-file links (-i -F) +
-                                   relative to URL. +
-       --config=FILE               Specify config file to use. +
-       --no-config                 Do not read any config file. +
- +
-Download: +
-  -t,  --tries=NUMBER              set number of retries to NUMBER (0 unlimits). +
-       --retry-connrefused         retry even if connection is refused. +
-  -O,  --output-document=FILE      write documents to FILE. +
-  -nc, --no-clobber                skip downloads that would download to +
-                                   existing files (overwriting them). +
-  -c,  --continue                  resume getting a partially-downloaded file. +
-       --start-pos=OFFSET          start downloading from zero-based position OFFSET. +
-       --progress=TYPE             select progress gauge type. +
-       --show-progress             display the progress bar in any verbosity mode. +
-  -N,  --timestamping              don't re-retrieve files unless newer than +
-                                   local. +
-  --no-use-server-timestamps       don't set the local file's timestamp by +
-                                   the one on the server. +
-  -S,  --server-response           print server response. +
-       --spider                    don't download anything. +
-  -T,  --timeout=SECONDS           set all timeout values to SECONDS. +
-       --dns-timeout=SECS          set the DNS lookup timeout to SECS. +
-       --connect-timeout=SECS      set the connect timeout to SECS. +
-       --read-timeout=SECS         set the read timeout to SECS. +
-  -w,  --wait=SECONDS              wait SECONDS between retrievals. +
-       --waitretry=SECONDS         wait 1..SECONDS between retries of a retrieval. +
-       --random-wait               wait from 0.5*WAIT...1.5*WAIT secs between retrievals. +
-       --no-proxy                  explicitly turn off proxy. +
-  -Q,  --quota=NUMBER              set retrieval quota to NUMBER. +
-       --bind-address=ADDRESS      bind to ADDRESS (hostname or IP) on local host. +
-       --limit-rate=RATE           limit download rate to RATE. +
-       --no-dns-cache              disable caching DNS lookups. +
-       --restrict-file-names=OS    restrict chars in file names to ones OS allows. +
-       --ignore-case               ignore case when matching files/directories. +
-  -4,  --inet4-only                connect only to IPv4 addresses. +
-  -6,  --inet6-only                connect only to IPv6 addresses. +
-       --prefer-family=FAMILY      connect first to addresses of specified family, +
-                                   one of IPv6, IPv4, or none. +
-       --user=USER                 set both ftp and http user to USER. +
-       --password=PASS             set both ftp and http password to PASS. +
-       --ask-password              prompt for passwords. +
-       --no-iri                    turn off IRI support. +
-       --local-encoding=ENC        use ENC as the local encoding for IRIs. +
-       --remote-encoding=ENC       use ENC as the default remote encoding. +
-       --unlink                    remove file before clobber. +
- +
-Directories: +
-  -nd, --no-directories            don't create directories. +
-  -x,  --force-directories         force creation of directories. +
-  -nH, --no-host-directories       don't create host directories. +
-       --protocol-directories      use protocol name in directories. +
-  -P,  --directory-prefix=PREFIX   save files to PREFIX/... +
-       --cut-dirs=NUMBER           ignore NUMBER remote directory components. +
- +
-HTTP options: +
-       --http-user=USER            set http user to USER. +
-       --http-password=PASS        set http password to PASS. +
-       --no-cache                  disallow server-cached data. +
-       --default-page=NAME         Change the default page name (normally +
-                                   this is `index.html'.). +
-  -E,  --adjust-extension          save HTML/CSS documents with proper extensions. +
-       --ignore-length             ignore `Content-Length' header field. +
-       --header=STRING             insert STRING among the headers. +
-       --max-redirect              maximum redirections allowed per page. +
-       --proxy-user=USER           set USER as proxy username. +
-       --proxy-password=PASS       set PASS as proxy password. +
-       --referer=URL               include `Referer: URL' header in HTTP request. +
-       --save-headers              save the HTTP headers to file. +
-  -U,  --user-agent=AGENT          identify as AGENT instead of Wget/VERSION. +
-       --no-http-keep-alive        disable HTTP keep-alive (persistent connections). +
-       --no-cookies                don't use cookies. +
-       --load-cookies=FILE         load cookies from FILE before session. +
-       --save-cookies=FILE         save cookies to FILE after session. +
-       --keep-session-cookies      load and save session (non-permanent) cookies. +
-       --post-data=STRING          use the POST method; send STRING as the data. +
-       --post-file=FILE            use the POST method; send contents of FILE. +
-       --method=HTTPMethod         use method "HTTPMethod" in the request. +
-       --body-data=STRING          Send STRING as data. --method MUST be set. +
-       --body-file=FILE            Send contents of FILE. --method MUST be set. +
-       --content-disposition       honor the Content-Disposition header when +
-                                   choosing local file names (EXPERIMENTAL). +
-       --content-on-error          output the received content on server errors. +
-       --auth-no-challenge         send Basic HTTP authentication information +
-                                   without first waiting for the server'+
-                                   challenge. +
- +
-HTTPS (SSL/TLS) options: +
-       --secure-protocol=PR        choose secure protocol, one of auto, SSLv2, +
-                                   SSLv3, TLSv1 and PFS. +
-       --https-only                only follow secure HTTPS links +
-       --no-check-certificate      don't validate the server's certificate. +
-       --certificate=FILE          client certificate file. +
-       --certificate-type=TYPE     client certificate type, PEM or DER. +
-       --private-key=FILE          private key file. +
-       --private-key-type=TYPE     private key type, PEM or DER. +
-       --ca-certificate=FILE       file with the bundle of CA's. +
-       --ca-directory=DIR          directory where hash list of CA's is stored. +
-       --random-file=FILE          file with random data for seeding the SSL PRNG. +
-       --egd-file=FILE             file naming the EGD socket with random data. +
- +
-FTP options: +
-       --ftp-user=USER             set ftp user to USER. +
-       --ftp-password=PASS         set ftp password to PASS. +
-       --no-remove-listing         don't remove `.listing' files. +
-       --no-glob                   turn off FTP file name globbing. +
-       --no-passive-ftp            disable the "passive" transfer mode. +
-       --preserve-permissions      preserve remote file permissions. +
-       --retr-symlinks             when recursing, get linked-to files (not dir). +
- +
-WARC options: +
-       --warc-file=FILENAME        save request/response data to a .warc.gz file. +
-       --warc-header=STRING        insert STRING into the warcinfo record. +
-       --warc-max-size=NUMBER      set maximum size of WARC files to NUMBER. +
-       --warc-cdx                  write CDX index files. +
-       --warc-dedup=FILENAME       do not store records listed in this CDX file. +
-       --no-warc-compression       do not compress WARC files with GZIP. +
-       --no-warc-digests           do not calculate SHA1 digests. +
-       --no-warc-keep-log          do not store the log file in a WARC record. +
-       --warc-tempdir=DIRECTORY    location for temporary files created by the +
-                                   WARC writer. +
- +
-Recursive download: +
-  -r,  --recursive                 specify recursive download. +
-  -l,  --level=NUMBER              maximum recursion depth (inf or 0 for infinite). +
-       --delete-after              delete files locally after downloading them. +
-  -k,  --convert-links             make links in downloaded HTML or CSS point to +
-                                   local files. +
-       --backups=N                 before writing file X, rotate up to N backup files. +
-  -K,  --backup-converted          before converting file X, back up as X.orig. +
-  -m,  --mirror                    shortcut for -N -r -l inf --no-remove-listing. +
-  -p,  --page-requisites           get all images, etc. needed to display HTML page. +
-       --strict-comments           turn on strict (SGML) handling of HTML comments. +
- +
-Recursive accept/reject: +
-  -A,  --accept=LIST               comma-separated list of accepted extensions. +
-  -R,  --reject=LIST               comma-separated list of rejected extensions. +
-       --accept-regex=REGEX        regex matching accepted URLs. +
-       --reject-regex=REGEX        regex matching rejected URLs. +
-       --regex-type=TYPE           regex type (posix). +
-  -D,  --domains=LIST              comma-separated list of accepted domains. +
-       --exclude-domains=LIST      comma-separated list of rejected domains. +
-       --follow-ftp                follow FTP links from HTML documents. +
-       --follow-tags=LIST          comma-separated list of followed HTML tags. +
-       --ignore-tags=LIST          comma-separated list of ignored HTML tags. +
-  -H,  --span-hosts                go to foreign hosts when recursive. +
-  -L,  --relative                  follow relative links only. +
-  -I,  --include-directories=LIST  list of allowed directories. +
-       --trust-server-names        use the name specified by the redirection +
-                                   url last component. +
-  -X,  --exclude-directories=LIST  list of excluded directories. +
-  -np, --no-parent                 don't ascend to the parent directory. +
- +
-Mail bug reports and suggestions to <bug-wget@gnu.org>+
-</code> +
- +
-==== ftp ==== +
- +
-La commande **ftp** est utilisée pour le transfert de fichiers:+
  
 <code> <code>
-root@debian8:~# ftp ftp2.fenestros.com +[root@centos7 ~]more /usr/share/nmap/nmap-services 
-Connected to anonymous.ftp.ovh.net+# THIS FILE IS GENERATED AUTOMATICALLY FROM A MASTER - DO NOT EDIT. 
-220 anonymous.ftp.ovh.net NcFTPd Server (licensed copy) ready+# EDIT /nmap-private-dev/nmap-services-all IN SVN INSTEAD
-Name (ftp2.fenestros.com:trainee): anonymous +# Well known service port numbers -*- mode: fundamental; -*- 
-331 Guest login ok, send your complete e-mail address as password+# From the Nmap Security Scanner ( http://nmap.org ) 
-Password+
-230 Logged in anonymously+# $Id: nmap-services 31220 2013-07-03 04:30:43Z david $ 
-Remote system type is UNIX+
-Using binary mode to transfer files+# Derived from IANA data and our own research 
-ftp> +#  
 +# This collection of service data is (C) 1996-2011 by Insecure.Com 
 +# LLC It is distributed under the Nmap Open Source license as 
 +# provided in the COPYING file of the source distribution or at 
 +# http://nmap.org/data/COPYING  Note that this license 
 +# requires you to license your own work under a compatable open source 
 +# license If you wish to embed Nmap technology into proprietary 
 +# software, we sell alternative licenses (contact sales@insecure.com). 
 +# Dozens of software vendors already license Nmap technology such as 
 +# host discovery, port scanning, OS detection, and version detection
 +# For more details, see http://nmap.org/book/man-legal.html 
 +
 +# Fields in this file are: Service name, portnum/protocol, open-frequency, optional comments 
 +
 +tcpmux 1/tcp 0.001995 # TCP Port Service Multiplexer [rfc-1078] 
 +tcpmux 1/udp 0.001236 # TCP Port Service Multiplexer 
 +compressnet 2/tcp 0.000013 # Management Utility 
 +compressnet 2/udp 0.001845 # Management Utility 
 +compressnet 3/tcp 0.001242 # Compression Process 
 +compressnet 3/udp 0.001532 # Compression Process 
 +unknown 4/tcp 0.000477 
 +rje 5/udp 0.000593 # Remote Job Entry 
 +unknown 6/tcp 0.000502 
 +echo 7/sctp 0.000000 
 +echo 7/tcp 0.004855 
 +echo 7/udp 0.024679 
 +unknown 8/tcp 0.000013 
 +--More--(0%)
 </code> </code>
  
-Une fois connecté, il convient d'utiliser la commande **help** pour afficher la liste des commandes disponibles :+Le répertoire **/usr/share/nmap** contient d'autres fichiers importants :
  
 <code> <code>
-ftp> help +[root@centos7 ~]# ls -l /usr/share/nmap 
-Commands may be abbreviated.  Commands are: +total 6548 
- +-rw-r--r--1 root root   10546 Nov 20  2015 nmap.dtd 
-! dir mdelete qc site +-rw-r--r--. 1 root root  455371 Nov 20  2015 nmap-mac-prefixes 
-$ disconnect mdir sendport size +-rw-r--r--. 1 root root 3694559 Nov 20  2015 nmap-os-db 
-account exit mget put status +-rw-r--r--. 1 root root   11749 Nov 20  2015 nmap-payloads 
-append form mkdir pwd struct +-rw-r--r--. 1 root root    6631 Nov 20  2015 nmap-protocols 
-ascii get mls quit system +-rw-r--r--. 1 root root   49243 Nov 20  2015 nmap-rpc 
-bell glob mode quote sunique +-rw-r--r--. 1 root root 1727204 Nov 20  2015 nmap-service-probes 
-binary hash modtime recv tenex +-rw-r--r--. 1 root root  622039 Nov 20  2015 nmap-services 
-bye help mput reget tick +-rw-r--r--. 1 root root   31935 Nov 20  2015 nmap.xsl 
-case idle newer rstatus trace +drwxr-xr-x. 3 root root    4096 Aug  5 14:16 nselib 
-cd image nmap rhelp type +-rw-r--r--. 1 root root   47190 Nov 20  2015 nse_main.lua 
-cdup ipany nlist rename user +drwxr-xr-x. 2 root root   20480 Aug  5 14:16 scripts
-chmod ipv4 ntrans reset umask +
-close ipv6 open restart verbose +
-cr lcd prompt rmdir ? +
-delete ls passive runique +
-debug macdef proxy send+
 </code> </code>
  
-Le caractère **!** permet d'exécuter une commande sur la machine cliente+Voici la liste des fichiers les plus importants :
  
-<code> +^ Fichier ^ Description ^ 
-ftp> !pwd +| /usr/share/nmap/nmap-protocols | Contient la liste des protocols reconnus par **nmap**. | 
-/root +/usr/share/nmap/nmap-service-probes | Contient les règles de balayage utilisées par **nmap** pour identifier le service actif sur un port donné. | 
-</code>+| /usr/share/nmap/nmap-mac-prefixes | Contient une liste de préfix d'adresses MAC par fabricant reconnu par **nmap**. | 
 +| /usr/share/nmap/nmap-rpc | Contient une liste des services RPC reconnus par **nmap**. |
  
-Pour transférer un fichier vers le serveur, il convient d'utiliser la commande **put** :+===Scripts===
  
-<file> +**nmap** utilise des scripts pour accomplir certaines tâches allant de la découverte simple de ports ouverts jusqu'à l'intrusion :
-ftp> put nom_fichier_local nom_fichier_distant +
-</file> +
- +
-Vous pouvez également transférer plusieurs fichiers à la fois grâce à la commande **mput**. Dans ce cas précis, il convient de saisir la commande suivante: +
- +
-<file> +
-ftp> mput nom*.* +
-</file> +
- +
-Pour transférer un fichier du serveur, il convient d'utiliser la commande **get** : +
- +
-<file> +
-ftp> get nom_fichier +
-</file> +
- +
-Vous pouvez également transférer plusieurs fichiers à la fois grâce à la commande **mget** ( voir la commande **mput** ci-dessus ). +
- +
-Pour supprimer un fichier sur le serveur, il convient d'utiliser la commande **del** : +
- +
-<file> +
-ftp> del nom_fichier +
-</file> +
- +
-Pour fermer la session, il convient d'utiliser la commande **quit** :+
  
 <code> <code>
-ftp> quit +[root@centos7 ~]ls /usr/share/nmap/scripts/ 
-221 Goodbye. +acarsd-info.nse                       http-domino-enum-passwords.nse          ndmp-version.nse 
-root@debian8:~#+address-info.nse                      http-drupal-enum-users.nse              nessus-brute.nse 
 +afp-brute.nse                         http-drupal-modules.nse                 nessus-xmlrpc-brute.nse 
 +afp-ls.nse                            http-email-harvest.nse                  netbus-auth-bypass.nse 
 +afp-path-vuln.nse                     http-enum.nse                           netbus-brute.nse 
 +afp-serverinfo.nse                    http-exif-spider.nse                    netbus-info.nse 
 +afp-showmount.nse                     http-favicon.nse                        netbus-version.nse 
 +ajp-auth.nse                          http-fileupload-exploiter.nse           nexpose-brute.nse 
 +ajp-brute.nse                         http-form-brute.nse                     nfs-ls.nse 
 +ajp-headers.nse                       http-form-fuzzer.nse                    nfs-showmount.nse 
 +ajp-methods.nse                       http-frontpage-login.nse                nfs-statfs.nse 
 +ajp-request.nse                       http-generator.nse                      nping-brute.nse 
 +amqp-info.nse                         http-git.nse                            nrpe-enum.nse 
 +asn-query.nse                         http-gitweb-projects-enum.nse           ntp-info.nse 
 +auth-owners.nse                       http-google-malware.nse                 ntp-monlist.nse 
 +auth-spoof.nse                        http-grep.nse                           omp2-brute.nse 
 +backorifice-brute.nse                 http-headers.nse                        omp2-enum-targets.nse 
 +backorifice-info.nse                  http-huawei-hg5xx-vuln.nse              openlookup-info.nse 
 +banner.nse                            http-icloud-findmyiphone.nse            openvas-otp-brute.nse 
 +bitcoin-getaddr.nse                   http-icloud-sendmsg.nse                 oracle-brute.nse 
 +bitcoin-info.nse                      http-iis-webdav-vuln.nse                oracle-brute-stealth.nse 
 +bitcoinrpc-info.nse                   http-joomla-brute.nse                   oracle-enum-users.nse 
 +bittorrent-discovery.nse              http-litespeed-sourcecode-download.nse  oracle-sid-brute.nse 
 +bjnp-discover.nse                     http-majordomo2-dir-traversal.nse       ovs-agent-version.nse 
 +broadcast-ataoe-discover.nse          http-malware-host.nse                   p2p-conficker.nse 
 +broadcast-avahi-dos.nse               http-methods.nse                        path-mtu.nse 
 +broadcast-bjnp-discover.nse           http-method-tamper.nse                  pcanywhere-brute.nse 
 +broadcast-db2-discover.nse            http-open-proxy.nse                     pgsql-brute.nse 
 +broadcast-dhcp6-discover.nse          http-open-redirect.nse                  pjl-ready-message.nse 
 +broadcast-dhcp-discover.nse           http-passwd.nse                         pop3-brute.nse 
 +broadcast-dns-service-discovery.nse   http-phpmyadmin-dir-traversal.nse       pop3-capabilities.nse 
 +broadcast-dropbox-listener.nse        http-phpself-xss.nse                    pptp-version.nse 
 +broadcast-eigrp-discovery.nse         http-php-version.nse                    qscan.nse 
 +broadcast-igmp-discovery.nse          http-proxy-brute.nse                    quake3-info.nse 
 +broadcast-listener.nse                http-put.nse                            quake3-master-getservers.nse 
 +broadcast-ms-sql-discover.nse         http-qnap-nas-info.nse                  rdp-enum-encryption.nse 
 +broadcast-netbios-master-browser.nse  http-rfi-spider.nse                     rdp-vuln-ms12-020.nse 
 +broadcast-networker-discover.nse      http-robots.txt.nse                     realvnc-auth-bypass.nse 
 +broadcast-novell-locate.nse           http-robtex-reverse-ip.nse              redis-brute.nse 
 +broadcast-pc-anywhere.nse             http-robtex-shared-ns.nse               redis-info.nse 
 +broadcast-pc-duo.nse                  http-sitemap-generator.nse              resolveall.nse 
 +broadcast-pim-discovery.nse           http-slowloris-check.nse                reverse-index.nse 
 +broadcast-ping.nse                    http-slowloris.nse                      rexec-brute.nse 
 +broadcast-pppoe-discover.nse          http-sql-injection.nse                  riak-http-info.nse 
 +broadcast-rip-discover.nse            http-stored-xss.nse                     rlogin-brute.nse 
 +broadcast-ripng-discover.nse          http-title.nse                          rmi-dumpregistry.nse 
 +broadcast-sybase-asa-discover.nse     http-tplink-dir-traversal.nse           rmi-vuln-classloader.nse 
 +broadcast-tellstick-discover.nse      http-trace.nse                          rpcap-brute.nse 
 +broadcast-upnp-info.nse               http-traceroute.nse                     rpcap-info.nse 
 +broadcast-versant-locate.nse          http-unsafe-output-escaping.nse         rpc-grind.nse 
 +broadcast-wake-on-lan.nse             http-userdir-enum.nse                   rpcinfo.nse 
 +broadcast-wpad-discover.nse           http-vhosts.nse                         rsync-brute.nse 
 +broadcast-wsdd-discover.nse           http-virustotal.nse                     rsync-list-modules.nse 
 +broadcast-xdmcp-discover.nse          http-vlcstreamer-ls.nse                 rtsp-methods.nse 
 +cassandra-brute.nse                   http-vmware-path-vuln.nse               rtsp-url-brute.nse 
 +cassandra-info.nse                    http-vuln-cve2009-3960.nse              samba-vuln-cve-2012-1182.nse 
 +cccam-version.nse                     http-vuln-cve2010-0738.nse              script.db 
 +citrix-brute-xml.nse                  http-vuln-cve2010-2861.nse              servicetags.nse 
 +citrix-enum-apps.nse                  http-vuln-cve2011-3192.nse              sip-brute.nse 
 +citrix-enum-apps-xml.nse              http-vuln-cve2011-3368.nse              sip-call-spoof.nse 
 +citrix-enum-servers.nse               http-vuln-cve2012-1823.nse              sip-enum-users.nse 
 +citrix-enum-servers-xml.nse           http-vuln-cve2013-0156.nse              sip-methods.nse 
 +couchdb-databases.nse                 http-waf-detect.nse                     skypev2-version.nse 
 +couchdb-stats.nse                     http-waf-fingerprint.nse                smb-brute.nse 
 +creds-summary.nse                     http-wordpress-brute.nse                smb-check-vulns.nse 
 +cups-info.nse                         http-wordpress-enum.nse                 smb-enum-domains.nse 
 +cups-queue-info.nse                   http-wordpress-plugins.nse              smb-enum-groups.nse 
 +cvs-brute.nse                         iax2-brute.nse                          smb-enum-processes.nse 
 +cvs-brute-repository.nse              iax2-version.nse                        smb-enum-sessions.nse 
 +daap-get-library.nse                  icap-info.nse                           smb-enum-shares.nse 
 +daytime.nse                           ike-version.nse                         smb-enum-users.nse 
 +db2-das-info.nse                      imap-brute.nse                          smb-flood.nse 
 +db2-discover.nse                      imap-capabilities.nse                   smb-ls.nse 
 +dhcp-discover.nse                     informix-brute.nse                      smb-mbenum.nse 
 +dict-info.nse                         informix-query.nse                      smb-os-discovery.nse 
 +distcc-cve2004-2687.nse               informix-tables.nse                     smb-print-text.nse 
 +dns-blacklist.nse                     ip-forwarding.nse                       smb-psexec.nse 
 +dns-brute.nse                         ip-geolocation-geobytes.nse             smb-security-mode.nse 
 +dns-cache-snoop.nse                   ip-geolocation-geoplugin.nse            smb-server-stats.nse 
 +dns-check-zone.nse                    ip-geolocation-ipinfodb.nse             smb-system-info.nse 
 +dns-client-subnet-scan.nse            ip-geolocation-maxmind.nse              smbv2-enabled.nse 
 +dns-fuzz.nse                          ipidseq.nse                             smb-vuln-ms10-054.nse 
 +dns-ip6-arpa-scan.nse                 ipv6-node-info.nse                      smb-vuln-ms10-061.nse 
 +dns-nsec3-enum.nse                    ipv6-ra-flood.nse                       smtp-brute.nse 
 +dns-nsec-enum.nse                     irc-botnet-channels.nse                 smtp-commands.nse 
 +dns-nsid.nse                          irc-brute.nse                           smtp-enum-users.nse 
 +dns-random-srcport.nse                irc-info.nse                            smtp-open-relay.nse 
 +dns-random-txid.nse                   irc-sasl-brute.nse                      smtp-strangeport.nse 
 +dns-recursion.nse                     irc-unrealircd-backdoor.nse             smtp-vuln-cve2010-4344.nse 
 +dns-service-discovery.nse             iscsi-brute.nse                         smtp-vuln-cve2011-1720.nse 
 +dns-srv-enum.nse                      iscsi-info.nse                          smtp-vuln-cve2011-1764.nse 
 +dns-update.nse                        isns-info.nse                           sniffer-detect.nse 
 +dns-zeustracker.nse                   jdwp-exec.nse                           snmp-brute.nse 
 +dns-zone-transfer.nse                 jdwp-info.nse                           snmp-hh3c-logins.nse 
 +domcon-brute.nse                      jdwp-inject.nse                         snmp-interfaces.nse 
 +domcon-cmd.nse                        jdwp-version.nse                        snmp-ios-config.nse 
 +domino-enum-users.nse                 krb5-enum-users.nse                     snmp-netstat.nse 
 +dpap-brute.nse                        ldap-brute.nse                          snmp-processes.nse 
 +drda-brute.nse                        ldap-novell-getpass.nse                 snmp-sysdescr.nse 
 +drda-info.nse                         ldap-rootdse.nse                        snmp-win32-services.nse 
 +duplicates.nse                        ldap-search.nse                         snmp-win32-shares.nse 
 +eap-info.nse                          lexmark-config.nse                      snmp-win32-software.nse 
 +epmd-info.nse                         llmnr-resolve.nse                       snmp-win32-users.nse 
 +eppc-enum-processes.nse               lltd-discovery.nse                      socks-auth-info.nse 
 +finger.nse                            maxdb-info.nse                          socks-brute.nse 
 +firewalk.nse                          mcafee-epo-agent.nse                    socks-open-proxy.nse 
 +firewall-bypass.nse                   membase-brute.nse                       ssh2-enum-algos.nse 
 +flume-master-info.nse                 membase-http-info.nse                   ssh-hostkey.nse 
 +ftp-anon.nse                          memcached-info.nse                      sshv1.nse 
 +ftp-bounce.nse                        metasploit-info.nse                     ssl-cert.nse 
 +ftp-brute.nse                         metasploit-msgrpc-brute.nse             ssl-date.nse 
 +ftp-libopie.nse                       metasploit-xmlrpc-brute.nse             ssl-enum-ciphers.nse 
 +ftp-proftpd-backdoor.nse              mmouse-brute.nse                        ssl-google-cert-catalog.nse 
 +ftp-vsftpd-backdoor.nse               mmouse-exec.nse                         ssl-known-key.nse 
 +ftp-vuln-cve2010-4221.nse             modbus-discover.nse                     sslv2.nse 
 +ganglia-info.nse                      mongodb-brute.nse                       stun-info.nse 
 +giop-info.nse                         mongodb-databases.nse                   stun-version.nse 
 +gkrellm-info.nse                      mongodb-info.nse                        stuxnet-detect.nse 
 +gopher-ls.nse                         mrinfo.nse                              svn-brute.nse 
 +gpsd-info.nse                         msrpc-enum.nse                          targets-asn.nse 
 +hadoop-datanode-info.nse              ms-sql-brute.nse                        targets-ipv6-multicast-echo.nse 
 +hadoop-jobtracker-info.nse            ms-sql-config.nse                       targets-ipv6-multicast-invalid-dst.nse 
 +hadoop-namenode-info.nse              ms-sql-dac.nse                          targets-ipv6-multicast-mld.nse 
 +hadoop-secondary-namenode-info.nse    ms-sql-dump-hashes.nse                  targets-ipv6-multicast-slaac.nse 
 +hadoop-tasktracker-info.nse           ms-sql-empty-password.nse               targets-sniffer.nse 
 +hbase-master-info.nse                 ms-sql-hasdbaccess.nse                  targets-traceroute.nse 
 +hbase-region-info.nse                 ms-sql-info.nse                         teamspeak2-version.nse 
 +hddtemp-info.nse                      ms-sql-query.nse                        telnet-brute.nse 
 +hostmap-bfk.nse                       ms-sql-tables.nse                       telnet-encryption.nse 
 +hostmap-ip2hosts.nse                  ms-sql-xp-cmdshell.nse                  tftp-enum.nse 
 +hostmap-robtex.nse                    mtrace.nse                              tls-nextprotoneg.nse 
 +http-adobe-coldfusion-apsa1301.nse    murmur-version.nse                      traceroute-geolocation.nse 
 +http-affiliate-id.nse                 mysql-audit.nse                         unusual-port.nse 
 +http-apache-negotiation.nse           mysql-brute.nse                         upnp-info.nse 
 +http-auth-finder.nse                  mysql-databases.nse                     url-snarf.nse 
 +http-auth.nse                         mysql-dump-hashes.nse                   ventrilo-info.nse 
 +http-awstatstotals-exec.nse           mysql-empty-password.nse                versant-info.nse 
 +http-axis2-dir-traversal.nse          mysql-enum.nse                          vmauthd-brute.nse 
 +http-backup-finder.nse                mysql-info.nse                          vnc-brute.nse 
 +http-barracuda-dir-traversal.nse      mysql-query.nse                         vnc-info.nse 
 +http-brute.nse                        mysql-users.nse                         voldemort-info.nse 
 +http-cakephp-version.nse              mysql-variables.nse                     vuze-dht-info.nse 
 +http-chrono.nse                       mysql-vuln-cve2012-2122.nse             wdb-version.nse 
 +http-coldfusion-subzero.nse           nat-pmp-info.nse                        whois.nse 
 +http-comments-displayer.nse           nat-pmp-mapport.nse                     wsdd-discover.nse 
 +http-config-backup.nse                nbstat.nse                              x11-access.nse 
 +http-cors.nse                         ncp-enum-users.nse                      xdmcp-discover.nse 
 +http-date.nse                         ncp-serverinfo.nse                      xmpp-brute.nse 
 +http-default-accounts.nse             ndmp-fs-info.nse                        xmpp-info.nse
 </code> </code>
  
-====SSH====+Les scripts sont regroupés dans des catégories : **auth**, **broadcast**, **brute**, **default**, **discovery**, **dos**, **exploit**, **external**, **fuzzer**, **intrusive**, **malware**, **safe**, **version** and **vuln**.
  
-===Introduction===+<WRAP center round important 50%> 
 +**Important** - Pour plus d'informations concernant ces catégories, consultez cette [[http://nmap.org/man/fr/man-nse.html|page]]. 
 +</WRAP>
  
-La commande **[[wpfr>Ssh|ssh]]** est le successeur et la remplaçante de la commande **[[wpfr>Rlogin|rlogin]]**. Il permet d'établir des connexions sécurisées avec une machine distante. SSH comporte cinq acteurs : +La catégorie la plus utilisée est **default** qui est appelée par l'utilisation de l'option **-sC**. Cette catégorie contient une liste de scripts par défaut.
- +
-  * Le **serveur SSH** +
-    * le démon sshd, qui s'occupe des authentifications et autorisations des clients,  +
-  * Le **client SSH** +
-    * ssh ou scp, qui assure la connexion et le dialogue avec le serveur, +
-  * La **session** qui représente la connexion courante et qui commence juste après l'authentification réussie, +
-  * Les **clefs** +
-    * **Couple de clef utilisateur asymétriques** et persistantes qui assurent l'identité d'un utilisateur et qui sont stockés sur disque dur, +
-    * **Clef hôte asymétrique et persistante** garantissant l'identité du serveur er qui est conservé sur disque dur +
-    * **Clef serveur asymétrique et temporaire** utilisée par le protocole SSH1 qui sert au chiffrement de la clé de session, +
-    * **Clef de session symétrique qui est générée aléatoirement** et qui permet le chiiffrement de la communication entre le client et le serveur. Elle est détruite en fin de session. SSH-1 utilise une seule clef tandis que SSH-2 utilise une clef par direction de la communication, +
-  * La **base de données des hôtes connus** qui stocke les clés des connexions précédentes. +
- +
-SSH fonctionne de la manière suivante pour la la mise en place d'un canal sécurisé: +
- +
-  * Le client contacte le serveur sur son port 22, +
-  * Les client et le serveur échangent leur version de SSH. En cas de non-compatibilité de versions, l'un des deux met fin au processus, +
-  Le serveur SSH s'identifie auprès du client en lui fournissant : +
-    Sa clé hôte, +
-    Sa clé serveur, +
-    Une séquence aléatoire de huit octets à inclure dans les futures réponses du client, +
-    * Une liste de méthodes de chiffrage, compression et authentification, +
-  * Le client et le serveur produisent un identifiant identique, un haché MD5 long de 128 bits contenant la clé hôte, la clé serveur et la séquence aléatoire, +
-  * Le client génère sa clé de session symétrique et la chiffre deux fois de suite, une fois avec la clé hôte du serveur et la deuxième fois avec la clé serveurLe client envoie cette clé au serveur accompagnée de la séquence aléatoire et un choix d'algorithmes supportés, +
-  * Le serveur déchiffre la clé de session, +
-  * Le client et le serveur mettent en place le canal sécurisé. +
- +
-===SSH-1=== +
- +
-SSH-1 utilise une paire de clefs de type RSA1. Il assure l'intégrité des données par une **[[wpfr>Contrôle_de_redondance_cyclique|Contrôle de Redondance Cyclique]]** (CRC) et est un bloc dit **monolithique**. +
- +
-Afin de s'identifier, le client essaie chacune des six méthodes suivantes : +
- +
-  * **Kerberos**, +
-  * **Rhosts**, +
-  * **%%RhostsRSA%%**, +
-  * Par **clef asymétrique**, +
-  * **TIS**, +
-  * Par **mot de passe**. +
- +
-===SSH-2=== +
- +
-SSH-2 utilise **DSA** ou **RSA**. Il assure l'intégrité des données par l'algorithme **HMAC**. SSH-2 est organisé en trois **couches** : +
- +
-  * **SSH-TRANS** – Transport Layer Protocol, +
-  * **SSH-AUTH** – Authentification Protocol, +
-  * **SSH-CONN** – Connection Protocol. +
- +
-SSH-2 diffère de SSH-1 essentiellement dans la phase authentification.  +
- +
-Trois méthodes d'authentification : +
- +
-  * Par **clef asymétrique**, +
-    * Identique à SSH-1 sauf avec l'algorithme DSA, +
-  * **%%RhostsRSA%%**, +
-  * Par **mot de passe**. +
- +
-===Options de la commande=== +
- +
-Les options de cette commande sont :+
  
 <code> <code>
-root@debian8:~# ssh --help +[root@centos7 ~]nmap --sC localhost
-unknown option -- - +
-usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec] +
-           [-D [bind_address:]port] [-E log_file] [-e escape_char] +
-           [-F configfile] [-I pkcs11] [-i identity_file] +
-           [-L [bind_address:]port:host:hostport] [-l login_name] [-m mac_spec] +
-           [-O ctl_cmd] [-o option] [-p port] +
-           [-Q cipher | cipher-auth | mac | kex | key] +
-           [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port] +
-           [-w local_tun[:remote_tun]] [user@]hostname [command] +
-</code>+
  
-====L'authentification par mot de passe====+Starting Nmap 6.40 ( http://nmap.org ) at 2017-08-05 14:20 CEST 
 +NSE: Loaded 95 scripts for scanning. 
 +NSE: Script Pre-scanning. 
 +Initiating SYN Stealth Scan at 14:20 
 +Scanning localhost (127.0.0.1) [1000 ports] 
 +Discovered open port 22/tcp on 127.0.0.1 
 +adjust_timeouts2: packet supposedly had rtt of -1500757317045342 microseconds.  Ignoring time. 
 +adjust_timeouts2: packet supposedly had rtt of -1500757317045342 microseconds.  Ignoring time. 
 +Discovered open port 25/tcp on 127.0.0.1 
 +adjust_timeouts2: packet supposedly had rtt of -1500757317045486 microseconds.  Ignoring time. 
 +adjust_timeouts2: packet supposedly had rtt of -1500757317045486 microseconds.  Ignoring time. 
 +Discovered open port 111/tcp on 127.0.0.1 
 +adjust_timeouts2: packet supposedly had rtt of -1500757317045504 microseconds.  Ignoring time. 
 +adjust_timeouts2: packet supposedly had rtt of -1500757317045504 microseconds.  Ignoring time. 
 +Discovered open port 631/tcp on 127.0.0.1 
 +adjust_timeouts2: packet supposedly had rtt of -1500757274107480 microseconds.  Ignoring time. 
 +adjust_timeouts2: packet supposedly had rtt of -1500757274107480 microseconds.  Ignoring time. 
 +Completed SYN Stealth Scan at 14:20, 0.01s elapsed (1000 total ports) 
 +NSE: Script scanning 127.0.0.1. 
 +Initiating NSE at 14:20 
 +Completed NSE at 14:20, 0.28s elapsed 
 +Nmap scan report for localhost (127.0.0.1) 
 +Host is up (0.0000060s latency). 
 +rDNS record for 127.0.0.1: localhost.localdomain 
 +Not shown: 996 closed ports 
 +PORT    STATE SERVICE 
 +22/tcp  open  ssh 
 +| ssh-hostkey: 2048 17:21:e0:43:b1:66:22:22:b6:f8:2b:cc:08:68:38:59 (RSA) 
 +|_256 19:cd:05:58:af:2c:10:82:52:ba:e3:31:df:bd:72:54 (ECDSA) 
 +25/tcp  open  smtp 
 +|_smtp-commands: centos7.fenestros.loc, PIPELINING, SIZE 10240000, VRFY, ETRN, ENHANCEDSTATUSCODES, 8BITMIME, DSN,  
 +111/tcp open  rpcbind 
 +| rpcinfo:  
 +|   program version   port/proto  service 
 +|   100000  2,3,4        111/tcp  rpcbind 
 +|_  100000  2,3,4        111/udp  rpcbind 
 +631/tcp open  ipp 
 +| http-methods: GET HEAD OPTIONS POST PUT 
 +| Potentially risky methods: PUT 
 +|_See http://nmap.org/nsedoc/scripts/http-methods.html 
 +| http-robots.txt: 1 disallowed entry  
 +|_/ 
 +|_http-title: Home - CUPS 1.6.3
  
-L'utilisateur fournit un mot de passe au client ssh. Le client ssh le transmet de façon sécurisée au serveur ssh puis  le serveur vérifie le mot de passe et l'accepte ou non+NSE: Script Post-scanning
- +Initiating NSE at 14:20 
-Avantage+Completed NSE at 14:200.00s elapsed 
-  * Aucune configuration de clef asymétrique n'est nécessaire. +Read data files from: /usr/bin/../share/nmap 
- +Nmap done1 IP address (1 host up) scanned in 0.43 seconds 
-Inconvénients: +           Raw packets sent1000 (44.000KB) | Rcvd2004 (84.176KB)
-  * L'utilisateur doit fournir à chaque connexion un identifiant et un mot de passe, +
-  * Moins sécurisé qu'un système par clef asymétrique+
- +
-====L'authentification par clef asymétrique==== +
- +
-  * Le **client** envoie au serveur une requête d'authentification par clé asymétrique qui contient le module de la clé à utiliser, +
-  * Le **serveur** recherche une correspondance pour ce module dans le fichier des clés autorisés **~/.ssh/authorized_keys**, +
-    * Dans le cas où une correspondance n'est pas trouvée, le serveur met fin à la communication, +
-    * Dans le cas contraire le serveur génère une chaîne aléatoire de 256 bits appelée un **challenge** et la chiffre avec la **clé publique du client**, +
-  * Le **client** reçoit le challenge et le décrypte avec la partie privée de sa clé. Il combine le challenge avec l'identifiant de session et chiffre le résultat. Ensuite il envoie le résultat chiffré au serveur. +
-  * Le **serveur** génère le même haché et le compare avec celui reçu du client. Si les deux hachés sont identiques, l'authentification est réussie. +
- +
-====Installation==== +
- +
-Pour installer/mettre à jour le serveur **sshd**, utilisez **apt-get** : +
- +
-<code> +
-root@debian8:~# which sshd +
-/usr/sbin/sshd +
-root@debian8:~# which ssh +
-/usr/bin/ssh +
-root@debian8:~# dpkg -S /usr/sbin/sshd  +
-openssh-server/usr/sbin/sshd +
-root@debian8:~# dpkg -S /usr/bin/ssh +
-openssh-client/usr/bin/ssh +
-root@debian8:~# apt-get install openssh-server +
-Reading package lists... Done +
-Building dependency tree        +
-Reading state information... Done +
-openssh-server is already the newest version. +
-0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.+
 </code> </code>
  
-<WRAP center round important+<WRAP center round warning 50%
-**Important** - Pour les stations de travail, installez le client : **openssh-client**.+**Attention** - La catégorie par défaut **default** contient certains scripts de la catégorie **intrusive**. Vous ne devez donc jamais utiliser cette option sur un réseau sans avoir obtenu un accord au préalable.
 </WRAP> </WRAP>
  
-===Options de la commande===+====4.2 - netcat ====
  
-Les options de la commande sont :+**netcat** est un couteau suisse. Il permet non seulement de scanner des ports mais aussi de lancer la connexion lors de la découverte d'un port ouvert.
  
-<file> +Les options de cette commande sont :
-SYNOPSIS +
-     sshd [-46DdeiqTt] [-b bits] [-C connection_spec] [-f config_file] [-g login_grace_time] [-h host_key_file] [-k key_gen_time] [-o option] [-p port]  [-u len] +
-</file> +
- +
-====Configuration==== +
- +
-<WRAP center round important> +
-**Important** - La configuration doit s'effectuer dans la fenêtre de la VM sous VirtualBox. Les connexions en ssh doivent de faire à partir d'un terminal ou de l'application putty. +
-</WRAP> +
- +
-===Serveur=== +
- +
-La configuration du serveur s'effectue dans le fichier **/etc/ssh/sshd_config** :+
  
 <code> <code>
-root@debian8:~# cat /etc/ssh/sshd_config +[root@centos7 ~]nc --help 
-# Package generated configuration file +Ncat 6.40 ( http://nmap.org/ncat ) 
-# See the sshd_config(5) manpage for details+Usage: ncat [options] [hostname] [port]
  
-# What portsIPs and protocols we listen for +Options taking a time assume seconds. Append 'ms' for milliseconds, 
-Port 22 +'s' for seconds, 'm' for minutes, or 'h' for hours (e.g. 500ms). 
-Use these options to restrict which interfaces/protocols sshd will bind to +  -4                         Use IPv4 only 
-#ListenAddress :: +  -6                         Use IPv6 only 
-#ListenAddress 0.0.0.0 +  -U, --unixsock             Use Unix domain sockets only 
-Protocol 2 +  -C, --crlf                 Use CRLF for EOL sequence 
-# HostKeys for protocol version 2 +  -c, --sh-exec <command>    Executes the given command via /bin/sh 
-HostKey /etc/ssh/ssh_host_rsa_key +  -e, --exec <command>       Executes the given command 
-HostKey /etc/ssh/ssh_host_dsa_key +      --lua-exec <filename>  Executes the given Lua script 
-HostKey /etc/ssh/ssh_host_ecdsa_key +  -g hop1[,hop2,...]         Loose source routing hop points (8 max) 
-HostKey /etc/ssh/ssh_host_ed25519_key +  -G <n>                     Loose source routing hop pointer (4, 8, 12, ...) 
-#Privilege Separation is turned on for security +  -m, --max-conns <n>        Maximum <n> simultaneous connections 
-UsePrivilegeSeparation yes+  -h, --help                 Display this help screen 
 +  -d, --delay <time>         Wait between read/writes 
 +  -o, --output <filename>    Dump session data to a file 
 +  -x, --hex-dump <filename>  Dump session data as hex to a file 
 +  -i, --idle-timeout <time>  Idle read/write timeout 
 +  -p, --source-port port     Specify source port to use 
 +  -s, --source addr          Specify source address to use (doesn't affect -l) 
 +  -l, --listen               Bind and listen for incoming connections 
 +  -k, --keep-open            Accept multiple connections in listen mode 
 +  -n, --nodns                Do not resolve hostnames via DNS 
 +  -t, --telnet               Answer Telnet negotiations 
 +  -u, --udp                  Use UDP instead of default TCP 
 +      --sctp                 Use SCTP instead of default TCP 
 +  -v, --verbose              Set verbosity level (can be used several times) 
 +  -w, --wait <time>          Connect timeout 
 +      --append-output        Append rather than clobber specified output files 
 +      --send-only            Only send data, ignoring received; quit on EOF 
 +      --recv-only            Only receive data, never send anything 
 +      --allow                Allow only given hosts to connect to Ncat 
 +      --allowfile            A file of hosts allowed to connect to Ncat 
 +      --deny                 Deny given hosts from connecting to Ncat 
 +      --denyfile             A file of hosts denied from connecting to Ncat 
 +      --broker               Enable Ncat's connection brokering mode 
 +      --chat                 Start a simple Ncat chat server 
 +      --proxy <addr[:port]>  Specify address of host to proxy through 
 +      --proxy-type <type>    Specify proxy type ("http" or "socks4"
 +      --proxy-auth <auth>    Authenticate with HTTP or SOCKS proxy server 
 +      --ssl                  Connect or listen with SSL 
 +      --ssl-cert             Specify SSL certificate file (PEM) for listening 
 +      --ssl-key              Specify SSL private key (PEM) for listening 
 +      --ssl-verify           Verify trust and domain name of certificates 
 +      --ssl-trustfile        PEM file containing trusted SSL certificates 
 +      --version              Display Ncat's version information and exit
  
-# Lifetime and size of ephemeral version 1 server key +See the ncat(1manpage for full options, descriptions and usage examples
-KeyRegenerationInterval 3600 +
-ServerKeyBits 1024 +
- +
-# Logging +
-SyslogFacility AUTH +
-LogLevel INFO +
- +
-# Authentication: +
-LoginGraceTime 120 +
-PermitRootLogin without-password +
-StrictModes yes +
- +
-RSAAuthentication yes +
-PubkeyAuthentication yes +
-#AuthorizedKeysFile %h/.ssh/authorized_keys +
- +
-# Don't read the user's ~/.rhosts and ~/.shosts files +
-IgnoreRhosts yes +
-# For this to work you will also need host keys in /etc/ssh_known_hosts +
-RhostsRSAAuthentication no +
-# similar for protocol version 2 +
-HostbasedAuthentication no +
-# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication +
-#IgnoreUserKnownHosts yes +
- +
-# To enable empty passwords, change to yes (NOT RECOMMENDED) +
-PermitEmptyPasswords no +
- +
-# Change to yes to enable challenge-response passwords (beware issues with +
-# some PAM modules and threads) +
-ChallengeResponseAuthentication no +
- +
-# Change to no to disable tunnelled clear text passwords +
-#PasswordAuthentication yes +
- +
-# Kerberos options +
-#KerberosAuthentication no +
-#KerberosGetAFSToken no +
-#KerberosOrLocalPasswd yes +
-#KerberosTicketCleanup yes +
- +
-# GSSAPI options +
-#GSSAPIAuthentication no +
-#GSSAPICleanupCredentials yes +
- +
-X11Forwarding yes +
-X11DisplayOffset 10 +
-PrintMotd no +
-PrintLastLog yes +
-TCPKeepAlive yes +
-#UseLogin no +
- +
-#MaxStartups 10:30:60 +
-#Banner /etc/issue.net +
- +
-# Allow client to pass locale environment variables +
-AcceptEnv LANG LC_* +
- +
-Subsystem sftp /usr/lib/openssh/sftp-server +
- +
-# Set this to 'yes' to enable PAM authentication, account processing, +
-# and session processing. If this is enabled, PAM authentication will +
-# be allowed through the ChallengeResponseAuthentication and +
-# PasswordAuthentication.  Depending on your PAM configuration, +
-# PAM authentication via ChallengeResponseAuthentication may bypass +
-# the setting of "PermitRootLogin without-password"+
-# If you just want the PAM account and session checks to run without +
-# PAM authenticationthen enable this but set PasswordAuthentication +
-and ChallengeResponseAuthentication to 'no'+
-UsePAM yes+
 </code> </code>
- 
-Pour ôter les lignes de commentaires dans ce fichier, utilisez la commande suivante : 
- 
-<code> 
-root@debian8:~# cd /tmp ; grep -E -v '^(#|$)'  /etc/ssh/sshd_config > sshd_config 
-root@debian8:/tmp# cat sshd_config 
-Port 22 
-Protocol 2 
-HostKey /etc/ssh/ssh_host_rsa_key 
-HostKey /etc/ssh/ssh_host_dsa_key 
-HostKey /etc/ssh/ssh_host_ecdsa_key 
-HostKey /etc/ssh/ssh_host_ed25519_key 
-UsePrivilegeSeparation yes 
-KeyRegenerationInterval 3600 
-ServerKeyBits 1024 
-SyslogFacility AUTH 
-LogLevel INFO 
-LoginGraceTime 120 
-PermitRootLogin without-password 
-StrictModes yes 
-RSAAuthentication yes 
-PubkeyAuthentication yes 
-IgnoreRhosts yes 
-RhostsRSAAuthentication no 
-HostbasedAuthentication no 
-PermitEmptyPasswords no 
-ChallengeResponseAuthentication no 
-X11Forwarding yes 
-X11DisplayOffset 10 
-PrintMotd no 
-PrintLastLog yes 
-TCPKeepAlive yes 
-AcceptEnv LANG LC_* 
-Subsystem sftp /usr/lib/openssh/sftp-server 
-UsePAM yes 
-</code> 
- 
-Pour sécuriser le serveur ssh, ajoutez ou modifiez les directives suivantes : 
- 
-<file> 
-AllowGroups adm 
-Banner /etc/issue.net 
-PermitRootLogin no 
-X11Forwarding no 
-</file> 
- 
-Votre fichier ressemblera à celui-ci : 
- 
-<file> 
-AllowGroups adm 
-Banner /etc/issue.net 
-PermitRootLogin no 
-X11Forwarding no 
-Port 22 
-Protocol 2 
-HostKey /etc/ssh/ssh_host_rsa_key 
-HostKey /etc/ssh/ssh_host_dsa_key 
-HostKey /etc/ssh/ssh_host_ecdsa_key 
-HostKey /etc/ssh/ssh_host_ed25519_key 
-UsePrivilegeSeparation yes 
-KeyRegenerationInterval 3600 
-ServerKeyBits 1024 
-SyslogFacility AUTH 
-LogLevel INFO 
-LoginGraceTime 120 
-StrictModes yes 
-RSAAuthentication yes 
-PubkeyAuthentication yes 
-IgnoreRhosts yes 
-RhostsRSAAuthentication no 
-HostbasedAuthentication no 
-PermitEmptyPasswords no 
-ChallengeResponseAuthentication no 
-X11DisplayOffset 10 
-PrintMotd no 
-PrintLastLog yes 
-TCPKeepAlive yes 
-AcceptEnv LANG LC_* 
-Subsystem sftp /usr/lib/openssh/sftp-server 
-UsePAM yes 
-</file> 
- 
-<WRAP center round todo> 
-**A Faire** - Renommez le fichier **/etc/ssh/sshd_config** en **/etc/ssh/sshd_config.old** puis copiez le fichier **/tmp/sshd_config** vers **/etc/sshd/**. Redémarrez ensuite le service sshd. N'oubliez pas de mettre l'utilisateur **trainee** dans le groupe **adm** ! 
-</WRAP> 
- 
-Saisissez maintenant les commandes suivantes en tant que **trainee** : 
- 
-<WRAP center round important> 
-Lors de la génération des clefs, la passphrase doit être **vide**. 
-</WRAP> 
- 
-<code> 
-trainee@debian8:~$ ssh-keygen -t dsa 
-Generating public/private dsa key pair. 
-Enter file in which to save the key (/home/trainee/.ssh/id_dsa):  
-Created directory '/home/trainee/.ssh'. 
-Enter passphrase (empty for no passphrase):  
-Enter same passphrase again:  
-Your identification has been saved in /home/trainee/.ssh/id_dsa. 
-Your public key has been saved in /home/trainee/.ssh/id_dsa.pub. 
-The key fingerprint is: 
-07:c9:8f:e3:b9:c9:26:8d:49:a9:22:08:d2:6e:22:4d trainee@debian8 
-The key's randomart image is: 
-+---[DSA 1024]----+ 
-|                 | 
-|       . .       | 
-|        +        | 
-|               | 
-| .     .S o      | 
-|o E   o. +       | 
-|++   o +o        | 
-|= = . +.oo       | 
-|.+ .   o+        | 
-+-----------------+ 
-trainee@debian8:~$ ssh-keygen -t rsa 
-Generating public/private rsa key pair. 
-Enter file in which to save the key (/home/trainee/.ssh/id_rsa):  
-Enter passphrase (empty for no passphrase):  
-Enter same passphrase again:  
-Your identification has been saved in /home/trainee/.ssh/id_rsa. 
-Your public key has been saved in /home/trainee/.ssh/id_rsa.pub. 
-The key fingerprint is: 
-75:ed:8b:ed:32:be:78:72:19:88:12:d1:4d:56:7a:d2 trainee@debian8 
-The key's randomart image is: 
-+---[RSA 2048]----+ 
-|       . oo..    | 
-|      . ...o .   | 
-|        + E .  | 
-|      .  . + .   | 
-|       .S. .  .  | 
-|      . . . .o . | 
-|          .oo  | 
-|          ..*.   | 
-|          .=o+.  | 
-+-----------------+ 
-trainee@debian8:~$ ssh-keygen -t ecdsa 
-Generating public/private ecdsa key pair. 
-Enter file in which to save the key (/home/trainee/.ssh/id_ecdsa):  
-Enter passphrase (empty for no passphrase):  
-Enter same passphrase again:  
-Your identification has been saved in /home/trainee/.ssh/id_ecdsa. 
-Your public key has been saved in /home/trainee/.ssh/id_ecdsa.pub. 
-The key fingerprint is: 
-66:70:a4:c5:99:3e:4f:97:b3:8d:3a:87:4c:de:c7:8c trainee@debian8 
-The key's randomart image is: 
-+---[ECDSA 256]---+ 
-|       .oo       | 
-|       ++        | 
-|      o..    .   | 
-|       oo . +    | 
-|        S+ . =   | 
-|        o o .  | 
-|         + + +   | 
-|          * E +  | 
-|           o .   | 
-+-----------------+ 
-trainee@debian8:~$ ssh-keygen -t ed25519 
-Generating public/private ed25519 key pair. 
-Enter file in which to save the key (/home/trainee/.ssh/id_ed25519):  
-Enter passphrase (empty for no passphrase):  
-Enter same passphrase again:  
-Your identification has been saved in /home/trainee/.ssh/id_ed25519. 
-Your public key has been saved in /home/trainee/.ssh/id_ed25519.pub. 
-The key fingerprint is: 
-92:e7:04:c6:77:9f:c3:46:f2:21:7d:c9:35:7d:c4:26 trainee@debian8 
-The key's randomart image is: 
-+--[ED25519 256]--+ 
-|               ++| 
-|         . .Eo*| 
-|      + . + + +o.| 
-|     . + . B +   | 
-|      o S      | 
-|         . .   | 
-|        .        | 
-|                 | 
-|                 | 
-+-----------------+ 
-</code> 
- 
-<WRAP center round important> 
-Les clés générées seront placées dans le répertoire **~/.ssh/**. 
-</WRAP> 
  
 ===Utilisation=== ===Utilisation===
  
-La commande ssh prend la forme suivante: +Dans l'exemple qui suit, un scan est lancé sur le port 80 puis sur le port 25 :
- +
-  ssh -nom_de_compte numero_ip (nom_de_machine) +
- +
-En saisissant cette commande sur votre propre machinevous obtiendrez un résultat similaire à celle-ci :+
  
 <code> <code>
-trainee@debian8:~$ su +[root@centos7 ~]# nc 127.0.0.1 80 -w 1 -vv 
-Passwordfenestros+Ncat: Version 6.40 ( http://nmap.org/ncat ) 
 +libnsock nsi_new2(): nsi_new (IOD #1) 
 +libnsock nsock_connect_tcp(): TCP connection requested to 127.0.0.1:80 (IOD #1) EID 8 
 +libnsock nsock_trace_handler_callback(): Callback: CONNECT ERROR [Connection refused (111)] for EID 8 [127.0.0.1:80] 
 +NcatConnection refused.
  
-root@debian8:~# ssh -l trainee localhost +[root@centos7 ~]nc 127.0.0.1 25 -w 1 -vv 
-The authenticity of host 'localhost (::1)' can't be established. +Ncat: Version 6.40 http://nmap.org/ncat ) 
-ECDSA key fingerprint is 79:00:60:0e:2b:71:5e:cb:1a:08:45:e8:ab:45:b8:dd+libnsock nsi_new2()nsi_new (IOD #1) 
-Are you sure you want to continue connecting (yes/no)? yes +libnsock nsock_connect_tcp()TCP connection requested to 127.0.0.1:25 (IOD #1) EID 8 
-WarningPermanently added 'localhost' (ECDSAto the list of known hosts. +libnsock nsock_trace_handler_callback()CallbackCONNECT SUCCESS for EID 8 [127.0.0.1:25] 
-trainee@localhost's passwordtrainee +NcatConnected to 127.0.0.1:25
- +libnsock nsi_new2(): nsi_new (IOD #2
-The programs included with the Debian GNU/Linux system are free software; +libnsock nsock_read()Read request from IOD #1 [127.0.0.1:25] (timeout-1ms) EID 18 
-the exact distribution terms for each program are described in the +libnsock nsock_readbytes()Read request for 0 bytes from IOD #2 [peer unspecified] EID 26 
-individual files in /usr/share/doc/*/copyright. +libnsock nsock_trace_handler_callback(): Callback: READ SUCCESS for EID 18 [127.0.0.1:25] (41 bytes)220 centos7.fenestros.loc ESMTP Postfix.. 
- +220 centos7.fenestros.loc ESMTP Postfix 
-Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent +libnsock nsock_readbytes()Read request for 0 bytes from IOD #1 [127.0.0.1:25] EID 34 
-permitted by applicable law. +^C
-Last loginSun Aug  7 08:17:07 2016 from 10.0.2.+
- +
-trainee@debian8:~$ pwd +
-/home/trainee +
- +
-trainee@debian8:~$ whoami +
-trainee +
- +
-trainee@debian8:~$ exit +
-logout +
-Connection to localhost closed.+
 </code> </code>
  
-====Tunnels SSH====+<WRAP center round important 50%> 
 +**Important** - Notez que **netcat** se connecte au port 25 qui est ouvert. 
 +</WRAP>
  
-Le protocole SSH peut être utilisé pour sécuriser les protocoles tels telnet, pop3 etc.. En effet, on peut créer un //tunnel// SSH dans lequel passe les communications du protocole non-sécurisé.+=====LAB #5 Utilisation de tcpdump=====
  
-La commande pour créer un tunnel ssh prend la forme suivante :+Le logiciel **tcpdump** sert à écouter le réseau en interceptant les paquets.
  
-  ssh -N -f compte@hôte -Lport-local:localhost:port_distant +Les options de cette commande sont :
- +
-Dans votre cas, vous allez créer un tunnel dans votre propre vm entre le port 15023 et le port 23 :+
  
 <code> <code>
-root@debian8:~# ssh --f trainee@localhost -L15023:localhost:23 +[root@centos7 ~]tcpdump --help 
-trainee@localhost'password: trainee +tcpdump version 4.9.2 
 +libpcap version 1.5.3 
 +OpenSSL 1.0.2k-fips  26 Jan 2017 
 +Usagetcpdump [-aAbdDefhHIJKlLnNOpqStuUvxX#] [ -B size ] [ -c count ] 
 + [ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ] 
 + [ -i interface ] [ -j tstamptype ] [ -M secret ] [ --number ] 
 + [ -Q|-P in|out|inout ] 
 + [ -r file ] [ -snaplen ] [ --time-stamp-precision precision ] 
 + [ --immediate-mode ] [ -T type ] [ --version ] [ -V file ] 
 + [ -w file ] [ -W filecount ] [ -y datalinktype ] [ -z postrotate-command ] 
 + [ -Z user ] [ expression ]
 </code> </code>
  
-Installez maintenant le serveur telnet :+====5.1 - Utilisation====
  
-<code> +===L'option -i===
-root@debian8:~# apt-get install telnetd +
-Reading package lists... Done +
-Building dependency tree        +
-Reading state information... Done +
-The following extra packages will be installed: +
-  openbsd-inetd +
-The following NEW packages will be installed: +
-  openbsd-inetd telnetd +
-0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. +
-Need to get 80.0 kB of archives. +
-After this operation, 289 kB of additional disk space will be used. +
-Do you want to continue? [Y/n] y +
-Get:1 http://ftp.fr.debian.org/debian/ jessie/main openbsd-inetd amd64 0.20140418-2 [35.4 kB] +
-Get:2 http://ftp.fr.debian.org/debian/ jessie/main telnetd amd64 0.17-36 [44.6 kB] +
-Fetched 80.0 kB in 0s (585 kB/s) +
-Selecting previously unselected package openbsd-inetd. +
-(Reading database ... 82450 files and directories currently installed.) +
-Preparing to unpack .../openbsd-inetd_0.20140418-2_amd64.deb ... +
-Unpacking openbsd-inetd (0.20140418-2) ... +
-Selecting previously unselected package telnetd. +
-Preparing to unpack .../telnetd_0.17-36_amd64.deb ... +
-Unpacking telnetd (0.17-36) ... +
-Processing triggers for systemd (215-17+deb8u4) ... +
-Processing triggers for man-db (2.7.0.2-5) ... +
-Setting up openbsd-inetd (0.20140418-2) ... +
-Setting up telnetd (0.17-36) ... +
-Adding user telnetd to group utmp +
-Processing triggers for systemd (215-17+deb8u4) ... +
-</code>+
  
-Connectez-vous ensuite via telnet sur le port 15023vous constaterez que votre connexion n'aboutit pas :+Pour écouter sur une **interface spécifique**utilisez l'option **-i** :
  
 <code> <code>
-root@debian8:~# telnet localhost 15023 +[root@centos7 ~]tcpdump -i enp0s3 
-Trying ::1... +tcpdumpverbose output suppressed, use -v or -vv for full protocol decode 
-Connected to localhost. +listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes 
-Escape character is '^]'+01:32:57.800710 IP centos7.fenestros.loc.ssh > gateway.36360: Flags [P.], seq 2207704927:2207705115, ack 23445380, win 40096, length 188 
-Debian GNU/Linux 8 +01:32:57.801785 IP gateway.36360 > centos7.fenestros.loc.ssh: Flags [.], ack 188, win 65535, length 0 
-debian8 logintrainee +01:32:57.805318 IP centos7.fenestros.loc.45319 > google-public-dns-a.google.com.domain: 62187+ PTR? 2.2.0.10.in-addr.arpa. (39) 
-Password:  +01:32:57.862866 IP google-public-dns-a.google.com.domain > centos7.fenestros.loc.4531962187 NXDomain 0/0/0 (39) 
-Last loginSun Aug  7 09:30:13 BST 2016 from localhost on pts/1 +01:32:57.873506 IP centos7.fenestros.loc.54658 > google-public-dns-a.google.com.domain: 6854+ PTR? 15.2.0.10.in-addr.arpa. (40) 
-Linux debian8 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-(2016-04-08x86_64 +01:32:57.934593 IP google-public-dns-a.google.com.domain > centos7.fenestros.loc.54658: 6854 NXDomain 0/0/0 (40) 
- +01:32:57.947943 IP centos7.fenestros.loc.53477 > google-public-dns-a.google.com.domain: 63054+ PTR? 8.8.8.8.in-addr.arpa. (38
-The programs included with the Debian GNU/Linux system are free software; +01:32:57.948649 IP centos7.fenestros.loc.ssh > gateway.36360: Flags [P.], seq 188:464, ack 1, win 40096, length 276 
-the exact distribution terms for each program are described in the +01:32:57.958724 IP gateway.36360 > centos7.fenestros.loc.ssh: Flags [.], ack 464, win 65535, length 0 
-individual files in /usr/share/doc/*/copyright+01:32:58.025768 IP google-public-dns-a.google.com.domain > centos7.fenestros.loc.53477: 63054 1/0/0 PTR google-public-dns-a.google.com. (82) 
- +01:32:58.026959 IP centos7.fenestros.loc.ssh > gateway.36360: Flags [P.], seq 464:1476, ack 1, win 40096, length 1012 
-Debian GNU/Linux comes with ABSOLUTELY NO WARRANTYto the extent +01:32:58.027640 IP centos7.fenestros.loc.ssh > gateway.36360: Flags [P.]seq 1476:1632, ack 1, win 40096, length 156 
-permitted by applicable law+01:32:58.028108 IP gateway.36360 > centos7.fenestros.loc.ssh: Flags [.], ack 1476, win 65535, length 0 
- +01:32:58.028146 IP gateway.36360 > centos7.fenestros.loc.ssh: Flags [.], ack 1632, win 65535, length 0 
-trainee@debian8:~$ pwd +01:32:58.028313 IP centos7.fenestros.loc.ssh > gateway.36360: Flags [P.], seq 1632:1788, ack 1, win 40096, length 156 
-/home/trainee +01:32:58.028822 IP centos7.fenestros.loc.ssh > gateway.36360: Flags [P.], seq 1788:2152, ack 1, win 40096, length 364 
- +01:32:58.029240 IP gateway.36360 > centos7.fenestros.loc.ssh: Flags [.], ack 1788, win 65535, length 0 
-trainee@debian8:~$ whoami +01:32:58.029273 IP gateway.36360 > centos7.fenestros.loc.ssh: Flags [.], ack 2152, win 65535, length 0 
-trainee +01:32:58.029710 IP centos7.fenestros.loc.ssh > gateway.36360: Flags [P.], seq 2152:2516, ack 1, win 40096, length 364 
- +01:32:58.030217 IP gateway.36360 > centos7.fenestros.loc.ssh: Flags [.], ack 2516, win 65535, length 0 
-trainee@debian8:~$ exit +01:32:58.030773 IP centos7.fenestros.loc.ssh > gateway.36360: Flags [P.], seq 2516:2776, ack 1, win 40096, length 260 
-logout +01:32:58.034485 IP gateway.36360 > centos7.fenestros.loc.ssh: Flags [.], ack 2776, win 65535, length 0 
-Connection closed by foreign host.+...
 </code> </code>
  
-<WRAP center round important> +Notez qu'à la fin, un résumé vous est présenté, par exemple :
-Notez bien que votre communication telnet passe par le tunnel SSH. +
-</WRAP> +
- +
-====SCP==== +
- +
-===Introduction=== +
- +
-La commande **scp** est le successeur et la remplaçante de la commande **rcp** de la famille des commandes **remote**. Il permet de faire des transferts sécurisés à partir d'une machine distante : +
- +
-  $ scp compte@numero_ip(nom_de_machine):/chemin_distant/fichier_distant /chemin_local/fichier_local +
- +
-ou vers une machine distante : +
- +
-  $ scp /chemin_local/fichier_local compte@numero_ip(nom_de_machine):/chemin_distant/fichier_distant +
- +
-===Utilisation=== +
- +
-Nous allons maintenant utiliser **scp** pour chercher un fichier sur le <<serveur>>+
- +
-Créez le fichier **/home/trainee/scp_test** :+
  
 <code> <code>
-root@debian8:~# exit +... 
-logout +^C 
- +767 packets captured 
-trainee@debian8:~$ pwd +767 packets received by filter 
-/home/trainee +0 packets dropped by kernel
- +
-trainee@debian8:~$ touch scp_test+
 </code> </code>
  
-Récupérez le fichier **scp_test** en utilisant scp :+===L'option -x===
  
-<code> +Pour écouter sur une interface spécifique et voir le contenu en Hexadécimalutilisez les options -i et **-x** :
-trainee@debian8:~$ scp trainee@127.0.0.1:/home/trainee/scp_test /tmp/scp_test +
-The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established. +
-ECDSA key fingerprint is 79:00:60:0e:2b:71:5e:cb:1a:08:45:e8:ab:45:b8:dd. +
-Are you sure you want to continue connecting (yes/no)? yes +
-Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts. +
-trainee@127.0.0.1's password:  +
-scp_test                                                                                                                              100%    0     0.0KB/  00:00  +
-     +
-trainee@debian8:~$ ls /tmp/scp_test  +
-/tmp/scp_test +
- +
-</code> +
- +
-==Mise en place des clefs== +
- +
-Il convient maintenant de se connecter sur le <<serveur>> en utilisant ssh et vérifiez la présence du répertoire ~/.ssh : +
- +
-En saisissant cette commandevous obtiendrez une fenêtre similaire à celle-ci :+
  
 <code> <code>
-trainee@debian8:~$ ssh -l trainee 127.0.0.1 +[root@centos7 ~]# tcpdump -i enp0s3 -x 
-trainee@127.0.0.1's passwordtrainee+tcpdump: verbose output suppressed, use -v or -vv for full protocol decode 
 +listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes 
 +01:34:55.540011 IP centos7.fenestros.loc.ssh > gateway.36360: Flags [P.], seq 2208166651:2208166839, ack 23445916, win 40096, length 188 
 + 0x0000:  4510 00e4 851c 4000 4006 9cd7 0a00 020f 
 + 0x0010:  0a00 0202 0016 8e08 839d f2fb 0165 c19c 
 + 0x0020:  5018 9ca0 18e7 0000 96d1 7d89 0022 fb31 
 + 0x0030:  dec8 d6f4 1227 ceb3 4df9 1ed8 691b b0e4 
 + 0x0040:  4561 6454 7f80 8928 1704 99a9 d4fe e565 
 + 0x0050:  7d2e e55f eadc 7e0e 352c 2f65 dd2a ff02 
 + 0x0060:  3a66 d1fa 3a15 9a4e 0054 91fe 7fe5 ce35 
 + 0x0070:  7df4 371a 6363 1302 4037 2a7f dde1 3d76 
 + 0x0080:  6ce5 069a 5855 cff6 18f5 dcf3 afff e525 
 + 0x0090:  ec03 c13d c23c 9d4b e0b9 0661 4f59 cd11 
 + 0x00a0:  cffb 1447 d6e6 7ab7 d7a8 d357 8fa6 ac7a 
 + 0x00b0:  bcf5 257f 41dd 5064 ba0b 189b 1563 06fa 
 + 0x00c0:  5364 9d6a 4f7c e99c 7a27 c3fc 3a2e 2618 
 + 0x00d0:  1357 7e4c b62a 9e44 8350 71fa e9b8 a17f 
 + 0x00e0:  a2be c731 
 +01:34:55.540618 IP gateway.36360 > centos7.fenestros.loc.ssh: Flags [.], ack 188, win 65535, length 0 
 + 0x0000:  4500 0028 061f 0000 4006 5ca1 0a00 0202 
 + 0x0010:  0a00 020f 8e08 0016 0165 c19c 839d f3b7 
 + 0x0020:  5010 ffff cf4e 0000 0000 0000 0000 
 +^C01:34:55.543115 IP centos7.fenestros.loc.47568 > google-public-dns-a.google.com.domain: 37698+ PTR? 2.2.0.10.in-addr.arpa. (39) 
 + 0x0000:  4500 0043 8ca3 4000 4011 91e8 0a00 020f 
 + 0x0010:  0808 0808 b9d0 0035 002f 1c5f 9342 0100 
 + 0x0020:  0001 0000 0000 0000 0132 0132 0130 0231 
 + 0x0030:  3007 696e 2d61 6464 7204 6172 7061 0000 
 + 0x0040 0c00 01
  
-The programs included with the Debian GNU/Linux system are free software; +3 packets captured 
-the exact distribution terms for each program are described in the +21 packets received by filter 
-individual files in /usr/share/doc/*/copyright. +packets dropped by kernel
- +
-Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent +
-permitted by applicable law. +
-Last login: Sun Aug  7 09:36:15 2016 from localhost +
- +
-trainee@debian8:~$ ls -la | grep .ssh +
-drwx------  2 trainee trainee 4096 Aug  7 09:38 .ssh +
-trainee@debian8:~$ exit +
-logout +
-Connection to 127.0.0.1 closed.+
 </code> </code>
  
-<WRAP center round important> +===L'option -X===
-Si le dossier distant .ssh n'existe pas dans le répertoire personnel de l'utilisateur connecté, il faut le créer avec des permissions de 700. Dans votre cas, puisque votre machine joue le rôle de serveur **et** du client, le dossier /home/trainee/.ssh existe **déjà**. +
-</WRAP>+
  
-Ensuite, il convient de transférer le fichier local **.ssh/id_ecdsa.pub** du <<client>> vers le <<serveur>> en le renommant en **authorized_keys** :+Pour écouter sur une interface spécifique et voir le contenu en Hexadécimal et en ASCII, utilisez les options -i et **-X** :
  
 <code> <code>
-trainee@debian8:~$ scp .ssh/id_ecdsa.pub trainee@127.0.0.1:/home/trainee/.ssh/authorized_keys +[root@centos7 ~]# tcpdump -i enp0s3 -X 
-trainee@127.0.0.1's password:  +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode 
-id_ecdsa.pub                                                                                                                          100%  177     0.2KB/s   00:00    +listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes 
-</code>+01:35:56.671522 IP centos7.fenestros.loc.ssh > gateway.36360: Flags [P.], seq 2208168643:2208168831, ack 23446048, win 40096, length 188 
 + 0x0000:  4510 00e4 8522 4000 4006 9cd1 0a00 020f  E...."@.@....... 
 + 0x0010:  0a00 0202 0016 8e08 839d fac3 0165 c220  .............e.. 
 + 0x0020:  5018 9ca0 18e7 0000 d8cc 9fe4 3055 351c  P...........0U5. 
 + 0x0030:  96a0 b2c0 650e 44e7 0016 b72e c990 4929  ....e.D.......I) 
 + 0x0040:  0d05 e79b ef5b ccef aafc 607b b9a2 a714  .....[....`{.... 
 + 0x0050:  e1a0 36a1 b5f3 4a0a 5cdd 90bd 96cf b75d  ..6...J.\......] 
 + 0x0060:  efa5 cc0b d195 d69a e933 48f2 74a5 ca6b  .........3H.t..k 
 + 0x0070:  c803 fe4e 5832 2253 d6d9 178b c63a df8e  ...NX2"S.....:.. 
 + 0x0080:  62a3 6e67 91f8 cc50 f330 51da a285 1c3a  b.ng...P.0Q....: 
 + 0x0090:  b074 a98f 95d6 f528 03e2 308a 31e8 5aa2  .t.....(..0.1.Z. 
 + 0x00a0 988b e3b1 444e ab24 e1b0 3eb8 ffa7 ae3f  ....DN.$..>....? 
 + 0x00b0:  332f 221d 3bec d17a 1c8f 741a eaaf 5444  3/".;..z..t...TD 
 + 0x00c0:  ea38 320e ea7f e9d2 035a 2531 e8f1 0757  .82......Z%1...W 
 + 0x00d0:  0259 70b1 464b 51ea 9e6b 1b93 48ea 6f25  .Yp.FKQ..k..H.o% 
 + 0x00e0:  d918 9027                                ...' 
 +01:35:56.672680 IP gateway.36360 > centos7.fenestros.loc.ssh: Flags [.], ack 188, win 65535, length 0 
 + 0x0000:  4500 0028 06cc 0000 4006 5bf4 0a00 0202  E..(....@.[..... 
 + 0x0010:  0a00 020f 8e08 0016 0165 c220 839d fb7f  .........e...... 
 + 0x0020:  5010 ffff c702 0000 0000 0000 0000       P............. 
 +^C01:35:56.674310 IP centos7.fenestros.loc.57986 > google-public-dns-a.google.com.domain: 33529+ PTR? 2.2.0.10.in-addr.arpa. (39) 
 + 0x0000 4500 0043 188e 4000 4011 05fe 0a00 020f  E..C..@.@....... 
 + 0x0010:  0808 0808 e282 0035 002f 1c5f 82f9 0100  .......5./._.... 
 + 0x0020:  0001 0000 0000 0000 0132 0132 0130 0231  .........2.2.0.1 
 + 0x0030:  3007 696e 2d61 6464 7204 6172 7061 0000  0.in-addr.arpa.. 
 + 0x0040:  0c00 01                                  ...
  
-<WRAP center round important> +3 packets captured 
-**Important** : Le fichier **authorized_keys** doit avoir les permissions de 600. +13 packets received by filter 
-</WRAP> +0 packets dropped by kernel
- +
- +
-Connectez-vous via telnet et insérer les clefs publiques restantes dans le fichier .ssh/authorized_keys : +
- +
-<code> +
-trainee@debian8:~$ ssh -l trainee localhost +
-The authenticity of host 'localhost (::1)' can't be established. +
-ECDSA key fingerprint is 79:00:60:0e:2b:71:5e:cb:1a:08:45:e8:ab:45:b8:dd. +
-Are you sure you want to continue connecting (yes/no)? yes +
-Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts. +
- +
-The programs included with the Debian GNU/Linux system are free software; +
-the exact distribution terms for each program are described in the +
-individual files in /usr/share/doc/*/copyright. +
- +
-Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent +
-permitted by applicable law. +
-Last login: Sun Aug  7 09:39:27 2016 from localhost +
-trainee@debian8:~$ cat .ssh/id_rsa.pub >> .ssh/authorized_keys +
-trainee@debian8:~$ cat .ssh/id_dsa.pub >> .ssh/authorized_keys +
-trainee@debian8:~$ cat .ssh/id_ed25519.pub >> .ssh/authorized_keys +
-trainee@debian8:~$ cat .ssh/authorized_keys +
-ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBGdOSQvO1nuPdg5FqzsdwD2l6JuylCDjguGV89prpCYndSaNDyLzE8qV2lHNy8Nk+026oDSyceTOJMJ56rzCVpM= trainee@debian8 +
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDdVGlmhx8NjbSOk4DHFcUU/pLkxmaLH2VaAyOiFzfgqCYPMaurc8S/GboecKsl39FV4QMGrOO1s+36/c6rLf28kicwDiS1UcbjHJt4eo0YniMRUhx9rz0polS+AARt/vfvGdfLVkjFcMg51WVXOQ6YmLc9nGKnKcQpQ8xbqO3cPxTWOMN9V0GozvqVMa9QbTEgTJg9gANt32WdA70IZdMB4l4H0XgV6cI+b01z5xjER6MgNF/52qbRiaPJe0+n/ujrjcXQqQ1NpOKJwK6XHtyKElM9t+xESPGwQJ3q9h4xxZH3zlMxcntWiJwBm8U+Z8NLco+o+RhEDhUcLWanR3PX trainee@debian8 +
-ssh-dss AAAAB3NzaC1kc3MAAACBAP0CgPkPk5tkJeZC3bmB+7yuSjWzdeNF3WeKKxd6YRfHwYVtTWbpw5VMBEGQVVTLtozGmSaZXI2rcL2ZjLRKu2PrWMXMHNptu+5xD1B7obRutzNa0wzxRuwyI7Ducq8PK53nbm56M4GormuZmc/0MBWrVi+QazPChbPrHB1oYSNZAAAAFQD2qjLJr89nWmGT0FrM3CtZmdTTmwAAAIEA4AtkO2+xQmqKyIKka2WJy6d2VR6KZEFdCjWXakXp0OsqotFgghsokEnGpeyUTA53ItZoL+ozV2Vb+4yskFS1RL2c/jHyc/C9j5tV9xgsSjb3Iz77YK+7plamZQFiOWyZwpuPirlsPGHZ//p3z5+qsL7sYy1UR9UxzxSm+2eDc0MAAACBAK697cNU0Z3PbkqjPiypfAIEpTMVHmYutlnpLjU0H6EuVz4Ku3SpD9iZwX9lrSMRDrTs4gd0WjMR7Ahc4zYdILC94tZDl6Uz9Obq5Y2seqCSA00fCxCi6t4rEDDT5Rpuo1JX6pNklQsGiUJyg1Z1hJvWPRZzzsM+ZXszz9Ar5b96 trainee@debian8 +
-ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOmyQOP1WnEAbS/qkqQxvJWHvCin8CiGBm2bzOhfPU1Z trainee@debian8+
 </code> </code>
  
-<WRAP center round important> +===L'option -w===
-**Important** : Notez que l'authentification a utilisé le couple de clefs asymétrique et aucun mot de passe n'a été requis. +
-</WRAP>+
  
-=====Le Parefeu Netfilter===== +Pour écouter sur une interface spécifique et envoyer la sortie dans un fichierutilisez les options -i et **-w** :
- +
-====Configuration du Pare-feu Netfilter/iptables==== +
- +
-===Introduction=== +
- +
-**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 le chargement de plusieurs modules supplémentaires en fonction de la situation: +
- +
-  * iptable_filter +
-  * iptable_mangle +
-  * iptable_net +
-  * etc +
- +
-Netfilter est organisé en **tables**. La commande **iptables** de netfilter permet d'insérer des **policies** dans les **chaines**: +
- +
-  * 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'applique par défaut. +
- +
-  * La table **NAT** +
-    * La chaîne PREROUTING +
-      * Permet de faire la translation d'adresse de destination +
-        * Cibles: SNAT, DNAT, MASQUERADE +
-    * La chaîne POSTROUTING +
-      * Permet de faire la translation d'adresse de la source +
-        * 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'accepter le paquet concerné +
-  * DROP +
-    * Permet de rejeter le paquet concerné sans générer un message d'erreur +
-  * REJECT +
-    * Permet de rejeter le paquet concerné en générant une message d'erreur +
- +
-Les **cibles** sont: +
- +
-  * SNAT +
-    * Permet de modifier l'adresse source du paquet concerné +
-  * DNAT +
-    * Permet de modifier l'adresse de destination du paquet concerné +
-  * MASQUERADE +
-    * Permet de remplacer l'adresse IP privée de l'expéditeur par un socket public de la passerelle. +
- +
-IPTABLES peut être configuré soit par des outils tels shorewall, soit en utilisant des lignes de commandes ou un script. Dans ce dernier casla ligne prend la forme: +
- +
-  # IPTABLES --action CHAINE --option1 --option2 +
- +
-Les actions sont: +
- +
-^  Action  ^  Abréviation  ^  Déscription +
-| - -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'insérer une règle à l'endroit spécifié |  +
-| - -list |  -L  | Permet d'afficher des règles | +
-| - -flush |  -F  | Permet de vider toutes les règles d'une chaîne |   +
- +
-Les options sont: +
- +
-^  Option  ^  Abréviation  ^  Déscription +
-| - -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'entrée |  +
-| - -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  | Permet de spécifier un port source ou une plage de ports source |  +
-| - -destination-port |  -dport  | Permet de spécifier un port de destination ou une plage de ports de destination |  +
-| - -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'adresse de destination d'une translation |  +
-| - -to-source |  s/o  | Permet spécifier l'adresse source d'une translation |  +
- +
-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'option spécifique au STATEFUL est: +
- +
-| - -state |  s/o  | Permet de spécifier l'état du paquet à vérifier |  +
- +
-Ce dernier cas fait référence au STATEFUL. Le STATEFUL est la capacité du par-feu à enregistrer dans une table spécifique, l'état des différentes connexions. Cette table s'appelle une **table d'état**. Le principe du fonctionnement de STATEFUL est simple, à savoir, si le paquet entrant appartient à une communication déjà établie, celui-ci n'est pas vérifié. +
- +
-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. +
- +
-===Configuration par Scripts sous Debian 6 et 7=== +
- +
-Dans l'exemple suivant, expliquez le fonctionnement du script en détaillant les règles écrites : +
- +
-<file> +
-#!/bin/bash +
-##################################### +
-# proxy server IP +
-PROXY_SERVER="192.168.1.2" +
-# Interface connected to Internet +
-INTERNET="eth1" +
-# Interface connected to LAN +
-LAN_IN="eth0" +
-# Local Interface +
-LOCAL="lo" +
-# Squid port +
-PROXY_PORT="8080" +
-# DO NOT MODIFY BELOW +
-# Clean old firewall +
-iptables -F +
-iptables -X +
-iptables -t nat -F +
-iptables -t nat -X +
-iptables -t mangle -F +
-iptables -t mangle -X +
-# Load IPTABLES modules for NAT and IP conntrack support +
-modprobe ip_conntrack +
-modprobe ip_conntrack_ftp +
-# For win xp ftp client +
-modprobe ip_nat_ftp +
-echo 1 > /proc/sys/net/ipv4/ip_forward +
-# Setting default filter policy +
-iptables -P INPUT DROP +
-iptables -P OUTPUT ACCEPT +
-# Unlimited access to loop back +
-iptables -A INPUT -i lo -j ACCEPT +
-iptables -A OUTPUT -o lo -j ACCEPT +
-# Allow UDP, DNS and Passive FTP +
-iptables -A INPUT -i $INTERNET -m state --state ESTABLISHED,RELATED -j ACCEPT +
-# set this system as a router for Rest of LAN +
-iptables --table nat --append POSTROUTING --out-interface $INTERNET -j MASQUERADE +
-iptables --append FORWARD --in-interface $LAN_IN -j ACCEPT +
-# unlimited access to LAN +
-iptables -A INPUT -i $LAN_IN -j ACCEPT +
-iptables -A OUTPUT -o $LAN_IN -j ACCEPT +
-# DNAT port 80 request comming from LAN systems to squid 3128 ($SQUID_PORT) aka transparent proxy +
-iptables -t nat -A PREROUTING -i $LAN_IN -p tcp --dport 80 -j DNAT --to $PROXY_SERVER:$PROXY_PORT +
-# iptables -t nat -A PREROUTING -i br0 -p tcp --dport 80 -j REDIRECT --to-port 3128 +
-# if it is same system +
-iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j REDIRECT --to-port $PROXY_PORT +
-# DROP everything and Log it +
-iptables -A INPUT -j LOG +
-iptables -A INPUT -j DROP +
-</file> +
- +
-Dans l'exemple suivant, expliquez le fonctionnement du script en détaillant les règles écrites :+
  
 <code> <code>
-#!/bin/sh +[root@centos7 ~]# tcpdump -i enp0s3 -log.dump 
-+tcpdumplistening on enp0s3link-type EN10MB (Ethernet), capture size 262144 bytes 
-# Generated iptables firewall script for the Linux 2.4 kernel +^C45 packets captured 
-# Script generated by Easy Firewall Generator for IPTables 1.15 +45 packets received by filter 
-# copyright 2002 Timothy Scott Morizot +0 packets dropped by kernel
-#  +
-# Redhat chkconfig comments - firewall applied early, +
-#                             removed late +
-# chkconfig: 2345 08 92 +
-# description: This script applies or removes iptables firewall rules +
-#  +
-# This generator is primarily designed for RedHat installations, +
-# although it should be adaptable for others. +
-+
-# It can be executed with the typical start and stop arguments. +
-# If used with stop, it will stop after flushing the firewall. +
-# The save and restore arguments will save or restore the rules +
-# from the /etc/sysconfig/iptables file.  The save and restore +
-# arguments are included to preserve compatibility with +
-# Redhat's or Fedora's init.d script if you prefer to use it. +
- +
-# Redhat/Fedora installation instructions +
-+
-# 1. Have the system link the iptables init.d startup script into run states +
-#    2, 3, and 5. +
-#    chkconfig --level 235 iptables on +
-+
-# 2. Save this script and execute it to load the ruleset from this file. +
-#    You may need to run the dos2unix command on it to remove carraige returns. +
-+
-# 3. To have it applied at startup, copy this script to +
-#    /etc/init.d/iptables.  It accepts stop, start, save, and restore +
-#    arguments.  (You may wish to save the existing one first.) +
-#    Alternatively, if you issue the 'service iptables save' command +
-#    the init.d script should save the rules and reload them at runtime. +
-+
-# 4. For non-Redhat systems (or Redhat systems if you have a problem), you +
-#    may want to append the command to execute this script to rc.local. +
-#    rc.local is typically located in /etc and /etc/rc.d and is usually +
-#    the last thing executed on startup.  Simply add /path/to/script/script_name +
-#    on its own line in the rc.local file. +
- +
-############################################################################### +
-#  +
-# Local Settings +
-+
- +
-# sysctl location.  If set, it will use sysctl to adjust the kernel parameters. +
-# If this is set to the empty string (or is unset), the use of sysctl +
-# is disabled. +
- +
-SYSCTL="/sbin/sysctl -w"  +
- +
-# To echo the value directly to the /proc file instead +
-# SYSCTL="" +
- +
-# IPTables Location - adjust if needed +
- +
-IPT="/sbin/iptables" +
-IPTS="/sbin/iptables-save" +
-IPTR="/sbin/iptables-restore" +
- +
-# Internet Interface +
-INET_IFACE="eth1" +
- +
-# Local Interface Information +
-LOCAL_IFACE="eth0" +
-LOCAL_IP="192.168.1.1" +
-LOCAL_NET="192.168.1.0/24" +
-LOCAL_BCAST="192.168.1.255" +
- +
-# Localhost Interface +
- +
-LO_IFACE="lo" +
-LO_IP="127.0.0.1" +
- +
-# Save and Restore arguments handled here +
-if "$1" = "save" ] +
-then +
- echo -n "Saving firewall to /etc/sysconfig/iptables ... " +
- $IPTS > /etc/sysconfig/iptables +
- echo "done" +
- exit 0 +
-elif [ "$1" = "restore"+
-then +
- echo -n "Restoring firewall from /etc/sysconfig/iptables ... " +
- $IPTR < /etc/sysconfig/iptables +
- echo "done" +
- exit 0 +
-fi +
- +
-############################################################################### +
-+
-# Load Modules +
-+
- +
-echo "Loading kernel modules ..." +
- +
-# You should uncomment the line below and run it the first time just to +
-# ensure all kernel module dependencies are OK.  There is no need to run +
-# every time, however. +
- +
-/sbin/depmod -a +
- +
-# Unless you have kernel module auto-loading disabled, you should not +
-# need to manually load each of these modules.  Other than ip_tables, +
-# ip_conntrack, and some of the optional modules, I've left these +
-# commented by default.  Uncomment if you have any problems or if +
-# you have disabled module autoload.  Note that some modules must +
-# be loaded by another kernel module. +
- +
-# core netfilter module +
-/sbin/modprobe ip_tables +
- +
-# the stateful connection tracking module +
-/sbin/modprobe ip_conntrack +
- +
-# filter table module +
-# /sbin/modprobe iptable_filter +
- +
-# mangle table module +
-# /sbin/modprobe iptable_mangle +
- +
-# nat table module +
-# /sbin/modprobe iptable_nat +
- +
-# LOG target module +
-# /sbin/modprobe ipt_LOG +
- +
-# This is used to limit the number of packets per sec/min/hr +
-# /sbin/modprobe ipt_limit +
- +
-# masquerade target module +
-# /sbin/modprobe ipt_MASQUERADE +
- +
-# filter using owner as part of the match +
-# /sbin/modprobe ipt_owner<WRAP center round important> +
-Importez une machine virtuelle vierge de CentOS 6 pour effectuer le LABS #8. +
-</WRAP> +
- +
-# REJECT target drops the packet and returns an ICMP response. +
-# The response is configurable.  By default, connection refused. +
-# /sbin/modprobe ipt_REJECT +
- +
-# This target allows packets to be marked in the mangle table +
-# /sbin/modprobe ipt_mark +
- +
-# This target affects the TCP MSS +
-# /sbin/modprobe ipt_tcpmss +
- +
-# This match allows multiple ports instead of a single port or range +
-# /sbin/modprobe multiport +
- +
-# This match checks against the TCP flags +
-# /sbin/modprobe ipt_state +
- +
-# This match catches packets with invalid flags +
-# /sbin/modprobe ipt_unclean +
- +
-# The ftp nat module is required for non-PASV ftp support +
-/sbin/modprobe ip_nat_ftp +
- +
-# the module for full ftp connection tracking +
-/sbin/modprobe ip_conntrack_ftp +
- +
-# the module for full irc connection tracking +
-/sbin/modprobe ip_conntrack_irc +
- +
- +
-############################################################################### +
-+
-# Kernel Parameter Configuration +
-+
-# See http://ipsysctl-tutorial.frozentux.net/chunkyhtml/index.html +
-# for a detailed tutorial on sysctl and the various settings +
-# available. +
- +
-# Required to enable IPv4 forwarding. +
-# Redhat users can try setting FORWARD_IPV4 in /etc/sysconfig/network to true +
-# Alternatively, it can be set in /etc/sysctl.conf +
-if [ "$SYSCTL" = ""+
-then +
-    echo "1" > /proc/sys/net/ipv4/ip_forward +
-else +
-    $SYSCTL net.ipv4.ip_forward="1" +
-fi +
- +
-# This enables dynamic address hacking. +
-# This may help if you have a dynamic IP address \(e.g. slip, ppp, dhcp\). +
-#if [ "$SYSCTL" = ""+
-#then +
-#    echo "1" > /proc/sys/net/ipv4/ip_dynaddr +
-#else +
-#    $SYSCTL net.ipv4.ip_dynaddr="1" +
-#fi +
- +
-# This enables SYN flood protection. +
-# The SYN cookies activation allows your system to accept an unlimited +
-# number of TCP connections while still trying to give reasonable +
-# service during a denial of service attack. +
-if [ "$SYSCTL" = ""+
-then +
-    echo "1" > /proc/sys/net/ipv4/tcp_syncookies +
-else +
-    $SYSCTL net.ipv4.tcp_syncookies="1" +
-fi +
- +
-# This enables source validation by reversed path according to RFC1812. +
-# In other words, did the response packet originate from the same interface +
-# through which the source packet was sent?  It's recommended for single-homed +
-# systems and routers on stub networks.  Since those are the configurations +
-# this firewall is designed to support, I turn it on by default. +
-# Turn it off if you use multiple NICs connected to the same network. +
-if [ "$SYSCTL" = ""+
-then +
-    echo "1" > /proc/sys/net/ipv4/conf/all/rp_filter +
-else +
-    $SYSCTL net.ipv4.conf.all.rp_filter="1" +
-fi +
- +
-# This option allows a subnet to be firewalled with a single IP address. +
-# It's used to build a DMZ.  Since that's not a focus of this firewall +
-# script, it's not enabled by default, but is included for reference. +
-# See: http://www.sjdjweis.com/linux/proxyarp/  +
-#if [ "$SYSCTL" = ""+
-#then +
-#    echo "1" > /proc/sys/net/ipv4/conf/all/proxy_arp +
-#else +
-#    $SYSCTL net.ipv4.conf.all.proxy_arp="1" +
-#fi +
- +
-# The following kernel settings were suggested by Alex Weeks. Thanks! +
- +
-# This kernel parameter instructs the kernel to ignore all ICMP +
-# echo requests sent to the broadcast address.  This prevents +
-# a number of smurfs and similar DoS nasty attacks. +
-if [ "$SYSCTL" = ""+
-then +
-    echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts +
-else +
-    $SYSCTL net.ipv4.icmp_echo_ignore_broadcasts="1" +
-fi +
- +
-# This option can be used to accept or refuse source routed +
-# packets.  It is usually on by default, but is generally +
-# considered a security risk.  This option turns it off. +
-if [ "$SYSCTL" = ""+
-then +
-    echo "0" > /proc/sys/net/ipv4/conf/all/accept_source_route +
-else +
-    $SYSCTL net.ipv4.conf.all.accept_source_route="0" +
-fi +
- +
-# This option can disable ICMP redirects.  ICMP redirects +
-# are generally considered a security risk and shouldn't be +
-# needed by most systems using this generator. +
-#if [ "$SYSCTL" = ""+
-#then +
-#    echo "0" > /proc/sys/net/ipv4/conf/all/accept_redirects +
-#else +
-#    $SYSCTL net.ipv4.conf.all.accept_redirects="0" +
-#fi +
- +
-# However, we'll ensure the secure_redirects option is on instead. +
-# This option accepts only from gateways in the default gateways list. +
-if [ "$SYSCTL" = ""+
-then +
-    echo "1" > /proc/sys/net/ipv4/conf/all/secure_redirects +
-else +
-    $SYSCTL net.ipv4.conf.all.secure_redirects="1" +
-fi +
- +
-# This option logs packets from impossible addresses. +
-if [ "$SYSCTL" = ""+
-then +
-    echo "1" > /proc/sys/net/ipv4/conf/all/log_martians +
-else +
-    $SYSCTL net.ipv4.conf.all.log_martians="1" +
-fi +
- +
- +
-############################################################################### +
-+
-# Flush Any Existing Rules or Chains +
-+
- +
-echo "Flushing Tables ..." +
- +
-# Reset Default Policies +
-$IPT -P INPUT ACCEPT +
-$IPT -P FORWARD ACCEPT +
-$IPT -P OUTPUT ACCEPT +
-$IPT -t nat -P PREROUTING ACCEPT +
-$IPT -t nat -P POSTROUTING ACCEPT +
-$IPT -t nat -P OUTPUT ACCEPT +
-$IPT -t mangle -P PREROUTING ACCEPT +
-$IPT -t mangle -P OUTPUT ACCEPT +
- +
-# Flush all rules +
-$IPT -F +
-$IPT -t nat -F +
-$IPT -t mangle -F +
- +
-# Erase all non-default chains +
-$IPT -X +
-$IPT -t nat -X +
-$IPT -t mangle -X +
- +
-if [ "$1" = "stop"+
-then +
- echo "Firewall completely flushed!  Now running with no firewall." +
- exit 0 +
-fi +
- +
-############################################################################### +
-+
-# Rules Configuration +
-+
- +
-############################################################################### +
-+
-# Filter Table +
-+
-############################################################################### +
- +
-# Set Policies +
- +
-$IPT -P INPUT DROP +
-$IPT -P OUTPUT DROP +
-$IPT -P FORWARD DROP +
- +
-############################################################################### +
-+
-# User-Specified Chains +
-+
-# Create user chains to reduce the number of rules each packet +
-# must traverse. +
- +
-echo "Create and populate custom rule chains ..." +
- +
-# Create a chain to filter INVALID packets +
- +
-$IPT -N bad_packets +
- +
-# Create another chain to filter bad tcp packets +
- +
-$IPT -N bad_tcp_packets +
- +
-# Create separate chains for icmp, tcp (incoming and outgoing), +
-# and incoming udp packets. +
- +
-$IPT -N icmp_packets +
- +
-# Used for UDP packets inbound from the Internet +
-$IPT -N udp_inbound +
- +
-# Used to block outbound UDP services from internal network +
-# Default to allow all +
-$IPT -N udp_outbound +
- +
-# Used to allow inbound services if desired +
-# Default fail except for established sessions +
-$IPT -N tcp_inbound +
- +
-# Used to block outbound services from internal network +
-# Default to allow all +
-$IPT -N tcp_outbound +
- +
-############################################################################### +
-+
-# Populate User Chains +
-+
- +
-# bad_packets chain +
-+
- +
-# Drop packets received on the external interface +
-# claiming a source of the local network +
-$IPT -A bad_packets -p ALL -i $INET_IFACE -s $LOCAL_NET -j LOG \ +
-    --log-prefix "fp=bad_packets:2 a=DROP " +
-$IPT -A bad_packets -p ALL -i $INET_IFACE -s $LOCAL_NET -j DROP +
- +
-# Drop INVALID packets immediately +
-$IPT -A bad_packets -p ALL -m state --state INVALID -j LOG \ +
-    --log-prefix "fp=bad_packets:1 a=DROP " +
- +
-$IPT -A bad_packets -p ALL -m state --state INVALID -j DROP +
- +
-# Then check the tcp packets for additional problems +
-$IPT -A bad_packets -p tcp -j bad_tcp_packets +
- +
-# All good, so return +
-$IPT -A bad_packets -p ALL -j RETURN +
- +
-# bad_tcp_packets chain +
-+
-# All tcp packets will traverse this chain+
-# Every new connection attempt should begin with +
-# a syn packet.  If it doesn't, it is likely a +
-# port scan.  This drops packets in state +
-# NEW that are not flagged as syn packets. +
- +
-# Return to the calling chain if the bad packets originate +
-# from the local interface. This maintains the approach +
-# throughout this firewall of a largely trusted internal +
-# network. +
-$IPT -A bad_tcp_packets -p tcp -i $LOCAL_IFACE -j RETURN +
- +
-# However, I originally did apply this filter to the forward chain +
-# for packets originating from the internal network.  While I have +
-# not conclusively determined its effect, it appears to have the +
-# interesting side effect of blocking some of the ad systems. +
-# Apparently some ad systems have the browser initiate a NEW +
-# connection that is not flagged as a syn packet to retrieve +
-# the ad image.  If you wish to experiment further comment the +
-# rule above. If you try it, you may also wish to uncomment the +
-# rule below.  It will keep those packets from being logged. +
-# There are a lot of them. +
-# $IPT -A bad_tcp_packets -p tcp -i $LOCAL_IFACE ! --syn -m state \ +
-#     --state NEW -j DROP +
- +
-$IPT -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j LOG \ +
-    --log-prefix "fp=bad_tcp_packets:1 a=DROP " +
-$IPT -A bad_tcp_packets -p tcp ! --syn -m state --state NEW -j DROP +
- +
-$IPT -A bad_tcp_packets -p tcp --tcp-flags ALL NONE -j LOG \ +
-    --log-prefix "fp=bad_tcp_packets:2 a=DROP " +
-$IPT -A bad_tcp_packets -p tcp --tcp-flags ALL NONE -j DROP +
- +
-$IPT -A bad_tcp_packets -p tcp --tcp-flags ALL ALL -j LOG \ +
-    --log-prefix "fp=bad_tcp_packets:3 a=DROP " +
-$IPT -A bad_tcp_packets -p tcp --tcp-flags ALL ALL -j DROP +
- +
-$IPT -A bad_tcp_packets -p tcp --tcp-flags ALL FIN,URG,PSH -j LOG \ +
-    --log-prefix "fp=bad_tcp_packets:4 a=DROP " +
-$IPT -A bad_tcp_packets -p tcp --tcp-flags ALL FIN,URG,PSH -j DROP +
- +
-$IPT -A bad_tcp_packets -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j LOG \ +
-    --log-prefix "fp=bad_tcp_packets:5 a=DROP " +
-$IPT -A bad_tcp_packets -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP +
- +
-$IPT -A bad_tcp_packets -p tcp --tcp-flags SYN,RST SYN,RST -j LOG \ +
-    --log-prefix "fp=bad_tcp_packets:6 a=DROP " +
-$IPT -A bad_tcp_packets -p tcp --tcp-flags SYN,RST SYN,RST -j DROP +
- +
-$IPT -A bad_tcp_packets -p tcp --tcp-flags SYN,FIN SYN,FIN -j LOG \ +
-    --log-prefix "fp=bad_tcp_packets:7 a=DROP " +
-$IPT -A bad_tcp_packets -p tcp --tcp-flags SYN,FIN SYN,FIN -j DROP +
- +
-# All good, so return +
-$IPT -A bad_tcp_packets -p tcp -j RETURN +
- +
-# icmp_packets chain +
-+
-# This chain is for inbound (from the Internet) icmp packets only. +
-# Type 8 (Echo Request) is not accepted by default +
-# Enable it if you want remote hosts to be able to reach you. +
-# 11 (Time Exceeded) is the only one accepted +
-# that would not already be covered by the established +
-# connection rule.  Applied to INPUT on the external interface. +
-#  +
-# See: http://www.ee.siue.edu/~rwalden/networking/icmp.html +
-# for more info on ICMP types. +
-+
-# Note that the stateful settings allow replies to ICMP packets. +
-# These rules allow new packets of the specified types. +
- +
-# ICMP packets should fit in a Layer 2 framethus they should +
-# never be fragmented.  Fragmented ICMP packets are a typical sign +
-# of a denial of service attack. +
-$IPT -A icmp_packets --fragment -p ICMP -j LOG \ +
-    --log-prefix "fp=icmp_packets:1 a=DROP " +
-$IPT -A icmp_packets --fragment -p ICMP -j DROP +
- +
-# Echo - uncomment to allow your system to be pinged. +
-# Uncomment the LOG command if you also want to log PING attempts +
-#  +
-# $IPT -A icmp_packets -p ICMP -s 0/0 --icmp-type 8 -j LOG \ +
-#    --log-prefix "fp=icmp_packets:2 a=ACCEPT " +
-# $IPT -A icmp_packets -p ICMP -s 0/0 --icmp-type 8 -j ACCEPT +
- +
-# By default, however, drop pings without logging. Blaster +
-# and other worms have infected systems blasting pings. +
-# Comment the line below if you want pings logged, but it +
-# will likely fill your logs. +
-$IPT -A icmp_packets -p ICMP -s 0/0 --icmp-type 8 -j DROP +
- +
-# Time Exceeded +
-$IPT -A icmp_packets -p ICMP -s 0/0 --icmp-type 11 -j ACCEPT +
- +
-# Not matched, so return so it will be logged +
-$IPT -A icmp_packets -p ICMP -j RETURN +
- +
-# TCP & UDP +
-# Identify ports at: +
-#    http://www.chebucto.ns.ca/~rakerman/port-table.html +
-#    http://www.iana.org/assignments/port-numbers +
- +
-# udp_inbound chain +
-+
-# This chain describes the inbound UDP packets it will accept. +
-# It's applied to INPUT on the external or Internet interface. +
-# Note that the stateful settings allow replies. +
-# These rules are for new requests. +
-# It drops netbios packets (windowsimmediately without logging. +
- +
-# Drop netbios calls +
-# Please note that these rules do not really change the way the firewall +
-# treats netbios connections.  Connections from the localhost and +
-# internal interface (if one exists) are accepted by default. +
-# Responses from the Internet to requests initiated by or through +
-# the firewall are also accepted by default.  To get herethe +
-packets would have to be part of a new request received by the +
-# Internet interface.  You would have to manually add rules to +
-# accept these.  I added these rules because some network connections, +
-# such as those via cable modems, tend to be filled with noise from +
-# unprotected Windows machines.  These rules drop those packets +
-# quickly and without logging them.  This prevents them from traversing +
-# the whole chain and keeps the log from getting cluttered with +
-# chatter from Windows systems. +
-$IPT -A udp_inbound -p UDP -s 0/0 --destination-port 137 -j DROP +
-$IPT -A udp_inbound -p UDP -s 0/0 --destination-port 138 -j DROP +
- +
-# Ident requests (Port 113) must have a REJECT rule rather than the +
-# default DROP rule.  This is the minimum requirement to avoid +
-# long delays while connecting.  Also see the tcp_inbound rule. +
-$IPT -A udp_inbound -p UDP -s 0/0 --destination-port 113 -j REJECT +
- +
-# A more sophisticated configuration could accept the ident requests. +
-# $IPT -A udp_inbound -p UDP -s 0/0 --destination-port 113 -j ACCEPT +
- +
-# However, if this is a gateway system that masquerades/nats for internal systems +
-# and the internal systems wish to chat, a simple changing these rules to +
-# ACCEPT won't work.  The ident daemon on the gateway will need to know how +
-# to handle the requests.  The stock daemon in most linux distributions +
-# can't do that.   oidentd is one package that can. +
-# See: http://dev.ojnk.net/ +
- +
-# Network Time Protocol (NTP) Server +
-$IPT -A udp_inbound -p UDP -s 0/0 --destination-port 123 -j ACCEPT +
- +
-# Dynamic Address +
-# If DHCP, the initial request is a broadcast. The response +
-# doesn't exactly match the outbound packet.  This explicitly +
-# allow the DHCP ports to alleviate this problem. +
-# If you receive your dynamic address by a different means, you +
-# can probably comment this line. +
-$IPT -A udp_inbound -p UDP -s 0/0 --source-port 67 --destination-port 68 \ +
-     -j ACCEPT +
- +
- +
-# Not matched, so return for logging +
-$IPT -A udp_inbound -p UDP -j RETURN +
- +
-# udp_outbound chain +
-+
-# This chain is used with a private network to prevent forwarding for +
-# UDP requests on specific protocols.  Applied to the FORWARD rule from +
-# the internal network.  Ends with an ACCEPT +
- +
- +
-# No match, so ACCEPT +
-$IPT -A udp_outbound -p UDP -s 0/0 -j ACCEPT +
- +
-# tcp_inbound chain +
-+
-# This chain is used to allow inbound connections to the +
-# system/gateway.  Use with care.  It defaults to none. +
-# It's applied on INPUT from the external or Internet interface. +
- +
-# Ident requests (Port 113) must have a REJECT rule rather than the +
-# default DROP rule.  This is the minimum requirement to avoid +
-# long delays while connecting.  Also see the tcp_inbound rule. +
-$IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 113 -j REJECT +
- +
-# A more sophisticated configuration could accept the ident requests. +
-# $IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 113 -j ACCEPT +
- +
-# However, if this is a gateway system that masquerades/nats for internal systems +
-# and the internal systems wish to chat, a simple changing these rules to +
-# ACCEPT won't work.  The ident daemon on the gateway will need to know how +
-# to handle the requests.  The stock daemon in most linux distributions +
-# can't do that.   oidentd is one package that can. +
-# See: http://dev.ojnk.net/ +
- +
-# Web Server +
- +
-# HTTP +
-$IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 80 -j ACCEPT +
- +
-# HTTPS (Secure Web Server) +
-$IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 443 -j ACCEPT +
- +
-# FTP Server (Control) +
-$IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 21 -j ACCEPT +
- +
-# FTP Client (Data Port for non-PASV transfers) +
-$IPT -A tcp_inbound -p TCP -s 0/0 --source-port 20 -j ACCEPT +
- +
-# Passive FTP +
-#  +
-# With passive FTP, the server provides a port to the client +
-# and allows the client to initiate the connection rather +
-# than initiating the connection with the client from the data port. +
-# Web browsers and clients operating behind a firewall generally +
-# use passive ftp transfers.  A general purpose FTP server +
-# will need to support them. +
-#  +
-# However, by default an FTP server will select a port from the entire +
-# range of high ports.  It is not particularly safe to open all +
-# high ports.  Fortunately, that range can be restricted.  This +
-# firewall presumes that the range has been restricted to a specific +
-# selected range.  That range must also be configured in the ftp server. +
-#  +
-# Instructions for specifying the port range for the wu-ftpd server +
-# can be found here: +
-# http://www.wu-ftpd.org/man/ftpaccess.html +
-# (See the passive ports option.) +
-#  +
-# Instructions for the ProFTPD server can be found here: +
-# http://proftpd.linux.co.uk/localsite/Userguide/linked/x861.html +
- +
-$IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 62000:64000 -j ACCEPT +
- +
-# Email Server (SMTP) +
-$IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 25 -j ACCEPT +
- +
-# Email Server (POP3) +
-$IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 110 -j ACCEPT +
- +
-# Email Server (IMAP4) +
-$IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 143 -j ACCEPT +
- +
-# SSL Email Server (POP3) +
-$IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 995 -j ACCEPT +
- +
-# SSL Email Server (IMAP4) +
-$IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 993 -j ACCEPT +
- +
-# sshd +
-$IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 22 -j ACCEPT +
- +
-# ICQ File Transfers & Other Advanced Features +
-#  +
-# ICQ supports a number of options beyond simple instant messaging. +
-# For those to function, the instant messaging system must allow +
-# new connections initiated from remote systems. This option will +
-# open a specified port range on the firewalled system.  The ICQ client +
-# on the firewalled system must also be configured to use the specified +
-# port range. +
- +
-$IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 5000:5100 -j ACCEPT +
- +
-# MSN Messenger File Transfers +
-#  +
-# Messenger supports file transfers.  For transfers initiated by +
-# remote systems to function, the system must allow +
-# new connections initiated from remote systems a specific port range. +
-# This option defaults to the port range 6891 through 6900. +
-# Unless the MSN Messenger client can be configured to specify any +
-# port range, don't change the default. +
- +
-$IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 6891:6900 -j ACCEPT +
- +
-# User specified allowed UDP protocol +
-$IPT -A tcp_inbound -p TCP -s 0/0 --destination-port 32500:36000 -j ACCEPT +
- +
- +
-# Not matched, so return so it will be logged +
-$IPT -A tcp_inbound -p TCP -j RETURN +
- +
-# tcp_outbound chain +
-+
-# This chain is used with a private network to prevent forwarding for +
-# requests on specific protocols.  Applied to the FORWARD rule from +
-# the internal network.  Ends with an ACCEPT +
- +
- +
-# No match, so ACCEPT +
-$IPT -A tcp_outbound -p TCP -s 0/0 -j ACCEPT +
- +
-############################################################################### +
-+
-# INPUT Chain +
-+
- +
-echo "Process INPUT chain ..." +
- +
-# Allow all on localhost interface +
-$IPT -A INPUT -p ALL -i $LO_IFACE -j ACCEPT +
- +
-# Drop bad packets +
-$IPT -A INPUT -p ALL -j bad_packets +
- +
-# DOCSIS compliant cable modems +
-# Some DOCSIS compliant cable modems send IGMP multicasts to find +
-# connected PCs.  The multicast packets have the destination address +
-# 224.0.0.1.  You can accept them.  If you choose to do so, +
-# Uncomment the rule to ACCEPT them and comment the rule to DROP +
-# them  The firewall will drop them here by default to avoid +
-# cluttering the log.  The firewall will drop all multicasts +
-# to the entire subnet (224.0.0.1) by default.  To only affect +
-# IGMP multicasts, change '-p ALL' to '-p 2' Of course, +
-# if they aren't accepted elsewhere, it will only ensure that +
-# multicasts on other protocols are logged. +
-# Drop them without logging. +
-$IPT -A INPUT -p ALL -d 224.0.0.1 -j DROP +
-# The rule to accept the packets. +
-# $IPT -A INPUT -p ALL -d 224.0.0.1 -j ACCEPT +
- +
-# Rules for the private network (accessing gateway system itself) +
-$IPT -A INPUT -p ALL -i $LOCAL_IFACE -s $LOCAL_NET -j ACCEPT +
-$IPT -A INPUT -p ALL -i $LOCAL_IFACE -d $LOCAL_BCAST -j ACCEPT +
- +
- +
-# Inbound Internet Packet Rules +
- +
-# Accept Established Connections +
-$IPT -A INPUT -p ALL -i $INET_IFACE -m state --state ESTABLISHED,RELATED \ +
-     -j ACCEPT +
- +
-# Route the rest to the appropriate user chain +
-$IPT -A INPUT -p TCP -i $INET_IFACE -j tcp_inbound +
-$IPT -A INPUT -p UDP -i $INET_IFACE -j udp_inbound +
-$IPT -A INPUT -p ICMP -i $INET_IFACE -j icmp_packets +
- +
-# Drop without logging broadcasts that get this far. +
-# Cuts down on log clutter. +
-# Comment this line if testing new rules that impact +
-# broadcast protocols. +
-$IPT -A INPUT -m pkttype --pkt-type broadcast -j DROP +
- +
-# Log packets that still don't match +
-$IPT -A INPUT -j LOG --log-prefix "fp=INPUT:99 a=DROP " +
- +
-############################################################################### +
-+
-# FORWARD Chain +
-+
- +
-echo "Process FORWARD chain ..." +
- +
-# Used if forwarding for a private network +
- +
-# Drop bad packets +
-$IPT -A FORWARD -p ALL -j bad_packets +
- +
-# Accept TCP packets we want to forward from internal sources +
-$IPT -A FORWARD -p tcp -i $LOCAL_IFACE -j tcp_outbound +
- +
-# Accept UDP packets we want to forward from internal sources +
-$IPT -A FORWARD -p udp -i $LOCAL_IFACE -j udp_outbound +
- +
-# If not blocked, accept any other packets from the internal interface +
-$IPT -A FORWARD -p ALL -i $LOCAL_IFACE -j ACCEPT +
- +
-# Deal with responses from the internet +
-$IPT -A FORWARD -i $INET_IFACE -m state --state ESTABLISHED,RELATED \ +
-     -j ACCEPT +
- +
-# Port Forwarding is enabled, so accept forwarded traffic +
-$IPT -A FORWARD -p tcp -i $INET_IFACE --destination-port 8080 \ +
-     --destination 192.168.1.50 -j ACCEPT  +
- +
-# Log packets that still don't match +
-$IPT -A FORWARD -j LOG --log-prefix "fp=FORWARD:99 a=DROP " +
- +
-############################################################################### +
-+
-# OUTPUT Chain +
-+
- +
-echo "Process OUTPUT chain ..." +
- +
-# Generally trust the firewall on output +
- +
-# However, invalid icmp packets need to be dropped +
-# to prevent a possible exploit. +
-$IPT -A OUTPUT -m state -p icmp --state INVALID -j DROP +
- +
-# Localhost +
-$IPT -A OUTPUT -p ALL -s $LO_IP -j ACCEPT +
-$IPT -A OUTPUT -p ALL -o $LO_IFACE -j ACCEPT +
- +
-# To internal network +
-$IPT -A OUTPUT -p ALL -s $LOCAL_IP -j ACCEPT +
-$IPT -A OUTPUT -p ALL -o $LOCAL_IFACE -j ACCEPT +
- +
-# To internet +
-$IPT -A OUTPUT -p ALL -o $INET_IFACE -j ACCEPT +
- +
-# Log packets that still don't match +
-$IPT -A OUTPUT -j LOG --log-prefix "fp=OUTPUT:99 a=DROP " +
- +
-############################################################################### +
-+
-# nat table +
-+
-############################################################################### +
- +
-# The nat table is where network address translation occurs if there +
-# is a private network.  If the gateway is connected to the Internet +
-# with a static IP, snat is used.  If the gateway has a dynamic address, +
-# masquerade must be used instead.  There is more overhead associated +
-# with masquerade, so snat is better when it can be used. +
-# The nat table has a builtin chain, PREROUTING, for dnat and redirects. +
-# Another, POSTROUTING, handles snat and masquerade. +
- +
-echo "Load rules for nat table ..." +
- +
-############################################################################### +
-+
-# PREROUTING chain +
-+
- +
-# Port Forwarding +
-#  +
-# Port forwarding forwards all traffic on a port or ports from +
-# the firewall to a computer on the internal LAN.  This can +
-# be required to support special situations.  For instance, +
-# this is the only way to support file transfers with an ICQ +
-# client on an internal computer.  It's also required if an internal +
-# system hosts a service such as a web server.  However, it's also +
-# a dangerous option.  It allows Internet computers access to +
-# your internal network.  Use it carefully and only if you're +
-# certain you know what you're doing. +
- +
-$IPT -t nat -A PREROUTING -p tcp -i $INET_IFACE --destination-port 80:80 \ +
-     -j DNAT --to-destination 192.168.1.50:8080 +
- +
-# This is a sample that will exempt a specific host from the transparent proxy +
-#$IPT -t nat -A PREROUTING -p tcp -s 192.168.1.50 --destination-port 80 \ +
-#     -j RETURN +
-#$IPT -t nat -A PREROUTING -p tcp -s 192.168.1.50 --destination-port 443 \ +
-#     -j RETURN +
- +
-# Redirect HTTP for a transparent proxy +
-$IPT -t nat -A PREROUTING -p tcp --destination-port 80 \ +
-     -j REDIRECT --to-ports 3128 +
-# Redirect HTTPS for a transparent proxy - commented by default +
-# $IPT -t nat -A PREROUTING -p tcp --destination-port 443 \ +
-#     -j REDIRECT --to-ports 3128 +
- +
-############################################################################### +
-+
-# POSTROUTING chain +
-+
- +
-$IPT -t nat -A POSTROUTING -o $INET_IFACE -j MASQUERADE +
- +
-############################################################################### +
-+
-# mangle table +
-+
-############################################################################### +
- +
-# The mangle table is used to alter packets.  It can alter or mangle them in +
-# several ways.  For the purposes of this generator, we only use its ability +
-# to alter the TTL in packets.  However, it can be used to set netfilter +
-# mark values on specific packets.  Those marks could then be used in another +
-# table like filter, to limit activities associated with a specific host, for +
-# instance.  The TOS target can be used to set the Type of Service field in +
-# the IP header.  Note that the TTL target might not be included in the +
-# distribution on your system.  If it is not and you require it, you will +
-# have to add it.  That may require that you build from source. +
- +
-echo "Load rules for mangle table ..."+
  
-Set the TTL in outbound packets to the same consistent value+[root@centos7 ~]ls -l log.dump 
-# A value around 128 is a good value.  Do not set this too high as +-rw-r--r--. 1 tcpdump tcpdump 8685 Jun  9 01:37 log.dump
-# it will adversely affect your network.  It is also considered bad +
-# form on the Internet. +
-$IPT -t mangle -A OUTPUT -o $INET_IFACE -j TTL --ttl-set 128+
 </code> </code>
  
-<WRAP center round todo+<WRAP center round important 50%
-Utilisez la commande **system-config-firewall** pour lancer l'outil graphique **Configuration du pare-feu** et constatez la configuration de netfilter.+**Important** - Pour générer le trafic, réactualisez simplement cette page web. Arrêtez la sortie de la commande à l'aide des touches **^C**.
 </WRAP> </WRAP>
  
-====La Configuration par firewalld sous Debian 8==== +Notez que le fichier log.dump est au format **libpcap** et non au format texteIl est donc inutile d'essayer de lire son contenu :
- +
-<WRAP center round important> +
-Importez une machine virtuelle vierge de Debian 8. +
-</WRAP> +
- +
-firewalld est à Netfilter ce que NetworkManager est au réseau. firewalld utilise des **zones** - des jeux de règles pré-définis dans lesquels sont placés les interfaces : +
- +
-  * **trusted** - un réseau fiable. Dans ce cas tous les ports sont autorisés, +
-  * **work**, **home**, **internal** - un réseau partiellement fiable. Dans ce cas quelques ports sont autorisés, +
-  * **dmz**, **public**, **external** - un réseau non fiableDans ce cas peu de ports sont autorisés, +
-  * **block**, **drop** - tout est interdit. La zone drop n'envoie pas de messages d'erreurs. +
- +
-<WRAP center round important> +
-Une interface ne peut être que dans une zone à la fois tandis que plusieurs interfaces peuvent être dans la même zone. +
-</WRAP> +
- +
-Sous Debian 8, firewalld n'est pas installé par défaut :+
  
 <code> <code>
-root@debian8:~# apt-get install firewalld +[root@centos7 ~]file log.dump 
-Reading package lists..Done +log.dumptcpdump capture file (little-endian) version 2.4 (Ethernetcapture length 262144)
-Building dependency tree        +
-Reading state information... Done +
-The following packages were automatically installed and are no longer required: +
-  libevent-core-2.0-5 libevent-pthreads-2.0-5 +
-Use 'apt-get autoremove' to remove them. +
-The following extra packages will be installed: +
-  ebtables python-decorator python-slip python-slip-dbus +
-The following NEW packages will be installed: +
-  ebtables firewalld python-decorator python-slip python-slip-dbus +
-0 upgraded5 newly installed, 0 to remove and 1 not upgraded. +
-Need to get 436 kB of archives. +
-After this operation, 2,950 kB of additional disk space will be used. +
-Do you want to continue? [Y/n] y+
 </code> </code>
  
-Le service firewalld est déjà lancé et activé :+===L'option -v===
  
-<code> +Tcpdump peut être utilisé avec un de trois modes verbose.
-root@debian8:~# systemctl status firewalld.service +
-● firewalld.service - firewalld - dynamic firewall daemon +
-   Loaded: loaded (/lib/systemd/system/firewalld.service; enabled) +
-   Active: active (running) since Wed 2017-07-26 09:10:38 BST; 24s ago +
- Main PID: 8093 (firewalld) +
-   CGroup: /system.slice/firewalld.service +
-           └─8093 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid+
  
-Jul 26 09:10:38 debian8 systemd[1]: Started firewalld dynamic firewall daemon. +^ Mode ^ Option ^ 
-</code> +| Light verbose | -v | 
- +| Medium verbose | -vv | 
-===La Configuration de Base de firewalld=== +| Full verbose | -vvv |
- +
-La configuration par défaut de firewalld se trouve dans **/usr/lib/firewalld** :+
  
 <code> <code>
-root@debian8:~# ls -lR /usr/lib/firewalld/ +[root@centos7 ~]tcpdump -i enp0s3 -v 
-/usr/lib/firewalld/: +tcpdumplistening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes 
-total 12 +01:39:13.094781 IP (tos 0x10, ttl 64, id 39762, offset 0, flags [DF], proto TCP (6), length 164) 
-drwxr-xr-x 2 root root 4096 Jul 26 09:10 icmptypes +^C    centos7.fenestros.loc.ssh > gateway.36360: Flags [P.], cksum 0x18a7 (incorrect -> 0xd270), seq 2210981047:2210981171, ack 23448932, win 40096, length 124
-drwxr-xr-x 2 root root 4096 Jul 26 09:10 services +
-drwxr-xr-x 2 root root 4096 Jul 26 09:10 zones +
- +
-/usr/lib/firewalld/icmptypes: +
-total 36 +
--rw-r--r-- 1 root root 222 Oct 16  2014 destination-unreachable.xml +
--rw-r--r-- 1 root root 173 Oct 16  2014 echo-reply.xml +
--rw-r--r-- 1 root root 210 Oct 16  2014 echo-request.xml +
--rw-r--r-- 1 root root 225 Oct 16  2014 parameter-problem.xml +
--rw-r--r-- 1 root root 185 Oct 16  2014 redirect.xml +
--rw-r--r-- 1 root root 227 Oct 16  2014 router-advertisement.xml +
--rw-r--r-- 1 root root 223 Oct 16  2014 router-solicitation.xml +
--rw-r--r-- 1 root root 248 Oct 16  2014 source-quench.xml +
--rw-r--r-- 1 root root 253 Oct 16  2014 time-exceeded.xml +
- +
-/usr/lib/firewalld/services: +
-total 248 +
--rw-r--r-- 1 root root 412 Oct 16  2014 amanda-client.xml +
--rw-r--r-- 1 root root 447 Oct 16  2014 amanda-k5-client.xml +
--rw-r--r-- 1 root root 320 Oct 16  2014 bacula-client.xml +
--rw-r--r-- 1 root root 346 Oct 16  2014 bacula.xml +
--rw-r--r-- 1 root root 305 Oct 16  2014 dhcpv6-client.xml +
--rw-r--r-- 1 root root 234 Oct 16  2014 dhcpv6.xml +
--rw-r--r-- 1 root root 227 Oct 16  2014 dhcp.xml +
--rw-r--r-- 1 root root 346 Oct 16  2014 dns.xml +
--rw-r--r-- 1 root root 836 Oct 16  2014 freeipa-ldaps.xml +
--rw-r--r-- 1 root root 836 Oct 16  2014 freeipa-ldap.xml +
--rw-r--r-- 1 root root 315 Oct 16  2014 freeipa-replication.xml +
--rw-r--r-- 1 root root 374 Oct 16  2014 ftp.xml +
--rw-r--r-- 1 root root 476 Oct 16  2014 high-availability.xml +
--rw-r--r-- 1 root root 448 Oct 16  2014 https.xml +
--rw-r--r-- 1 root root 353 Oct 16  2014 http.xml +
--rw-r--r-- 1 root root 372 Oct 16  2014 imaps.xml +
--rw-r--r-- 1 root root 454 Oct 16  2014 ipp-client.xml +
--rw-r--r-- 1 root root 427 Oct 16  2014 ipp.xml +
--rw-r--r-- 1 root root 517 Oct 16  2014 ipsec.xml +
--rw-r--r-- 1 root root 182 Oct 16  2014 kadmin.xml +
--rw-r--r-- 1 root root 233 Oct 16  2014 kerberos.xml +
--rw-r--r-- 1 root root 221 Oct 16  2014 kpasswd.xml +
--rw-r--r-- 1 root root 232 Oct 16  2014 ldaps.xml +
--rw-r--r-- 1 root root 199 Oct 16  2014 ldap.xml +
--rw-r--r-- 1 root root 385 Oct 16  2014 libvirt-tls.xml +
--rw-r--r-- 1 root root 389 Oct 16  2014 libvirt.xml +
--rw-r--r-- 1 root root 424 Oct 16  2014 mdns.xml +
--rw-r--r-- 1 root root 211 Oct 16  2014 mountd.xml +
--rw-r--r-- 1 root root 190 Oct 16  2014 ms-wbt.xml +
--rw-r--r-- 1 root root 171 Oct 16  2014 mysql.xml +
--rw-r--r-- 1 root root 324 Oct 16  2014 nfs.xml +
--rw-r--r-- 1 root root 389 Oct 16  2014 ntp.xml +
--rw-r--r-- 1 root root 335 Oct 16  2014 openvpn.xml +
--rw-r--r-- 1 root root 433 Oct 16  2014 pmcd.xml +
--rw-r--r-- 1 root root 474 Oct 16  2014 pmproxy.xml +
--rw-r--r-- 1 root root 544 Oct 16  2014 pmwebapis.xml +
--rw-r--r-- 1 root root 460 Oct 16  2014 pmwebapi.xml +
--rw-r--r-- 1 root root 357 Oct 16  2014 pop3s.xml +
--rw-r--r-- 1 root root 181 Oct 16  2014 postgresql.xml +
--rw-r--r-- 1 root root 509 Oct 16  2014 privoxy.xml +
--rw-r--r-- 1 root root 261 Oct 16  2014 proxy-dhcp.xml +
--rw-r--r-- 1 root root 297 Oct 16  2014 puppetmaster.xml +
--rw-r--r-- 1 root root 446 Oct 16  2014 radius.xml +
--rw-r--r-- 1 root root 214 Oct 16  2014 rpc-bind.xml +
--rw-r--r-- 1 root root 384 Oct 16  2014 samba-client.xml +
--rw-r--r-- 1 root root 461 Oct 16  2014 samba.xml +
--rw-r--r-- 1 root root 337 Oct 16  2014 sane.xml +
--rw-r--r-- 1 root root 550 Oct 16  2014 smtp.xml +
--rw-r--r-- 1 root root 173 Oct 16  2014 squid.xml +
--rw-r--r-- 1 root root 463 Oct 16  2014 ssh.xml +
--rw-r--r-- 1 root root 496 Oct 16  2014 synergy.xml +
--rw-r--r-- 1 root root 393 Oct 16  2014 telnet.xml +
--rw-r--r-- 1 root root 301 Oct 16  2014 tftp-client.xml +
--rw-r--r-- 1 root root 437 Oct 16  2014 tftp.xml +
--rw-r--r-- 1 root root 771 Oct 16  2014 tor-socks.xml +
--rw-r--r-- 1 root root 211 Oct 16  2014 transmission-client.xml +
--rw-r--r-- 1 root root 475 Oct 16  2014 vnc-server.xml +
--rw-r--r-- 1 root root 310 Oct 16  2014 wbem-https.xml +
--rw-r--r-- 1 root root 509 Oct 16  2014 xmpp-bosh.xml +
--rw-r--r-- 1 root root 488 Oct 16  2014 xmpp-client.xml +
--rw-r--r-- 1 root root 264 Oct 16  2014 xmpp-local.xml +
--rw-r--r-- 1 root root 545 Oct 16  2014 xmpp-server.xml+
  
-/usr/lib/firewalld/zones: +packet captured 
-total 36 +11 packets received by filter 
--rw-r--r-- root root 299 Oct 16  2014 block.xml +0 packets dropped by kernel
--rw-r--r-- 1 root root 293 Oct 16  2014 dmz.xml +
--rw-r--r-- 1 root root 291 Oct 16  2014 drop.xml +
--rw-r--r-- 1 root root 304 Oct 16  2014 external.xml +
--rw-r--r-- 1 root root 369 Oct 16  2014 home.xml +
--rw-r--r-- 1 root root 384 Oct 16  2014 internal.xml +
--rw-r--r-- 1 root root 315 Oct 16  2014 public.xml +
--rw-r--r-- 1 root root 162 Oct 16  2014 trusted.xml +
--rw-r--r-- 1 root root 311 Oct 16  2014 work.xml+
 </code> </code>
  
-Ces fichiers sont au format **xml**, par exemple :+====5.2 - Filtrage à l'écoute====
  
-<code> +Tcpdump peut effectuer du filtrage lors de l'écoute.
-root@debian8:~# cat /usr/lib/firewalld/zones/home.xml +
-<?xml version="1.0" encoding="utf-8"?> +
-<zone> +
-  <short>Home</short> +
-  <description>For use in home areas. You mostly trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description> +
-  <service name="ssh"/> +
-  <service name="mdns"/> +
-  <service name="samba-client"/> +
-  <service name="dhcpv6-client"/> +
-</zone> +
-</code>+
  
-La configuration de firewalld ainsi que les définitions et règles personnalisées se trouvent dans **/etc/firewalld** :+Pour uniquement écouter les paquets en provenance de l'adresse IP 192.168.1.11, utilisez la condition **src host** :
  
-<code> +  tcpdump src host 192.168.1.11 [Entrée]
-root@debian8:~ls -lR /etc/firewalld/ +
-/etc/firewalld/: +
-total 20 +
--rw-r--r-- 1 root root 1026 Oct 16  2014 firewalld.conf +
-drwxr-xr-x 2 root root 4096 Oct 16  2014 icmptypes +
--rw-r--r-- root root  271 Oct 16  2014 lockdown-whitelist.xml +
-drwxr-xr-x 2 root root 4096 Oct 16  2014 services +
-drwxr-xr-x 2 root root 4096 Oct 16  2014 zones+
  
-/etc/firewalld/icmptypes: +Pour uniquement écouter les paquets en provenance de l'adresse IP 192.168.1.11 et vers l'adresse 192.168.1.2, utilisez les conditions src host et **dst host** :
-total 0+
  
-/etc/firewalld/services: +  # tcpdump src host 192.168.1.11 and dst host 192.168.1.2 [Entrée]
-total 0+
  
-/etc/firewalld/zones: +Pour uniquement écouter les paquets d'un port précis, utilisez la condition **port** :
-total 0 +
-</code>+
  
-Le fichier de configuration de firewalld est **/etc/firewalld/firewalld.conf** :+  # tcpdump -i eth0 port 80 [Entrée]
  
-<code> +Pour uniquement écouter les paquets d'un protocole précis, utilisez une condition telle **ip**, **icmp**, **arp**, **rarp**, **udp** ou **tcp**:
-root@debian8:~# cat /etc/firewalld/firewalld.conf +
-# firewalld config file+
  
-default zone +  tcpdump -i eth0 udp [Entrée]
-# The default zone used if an empty zone string is used. +
-# Default: public +
-DefaultZone=public+
  
-# Minimal mark +Pour uniquement écouter les paquets d'une taille inférieure à 100 octetsutilisez la condition **less** :
-# Marks up to this minimum are free for use for example in the direct  +
-# interface. If more free marks are neededincrease the minimum +
-# Default100 +
-MinimalMark=100+
  
-Clean up on exit +  tcpdump -i eth0 less 100 [Entrée]
-# If set to no or false the firewall configuration will not get cleaned up +
-# on exit or stop of firewalld +
-# Default: yes +
-CleanupOnExit=yes+
  
-# Lockdown +Pour uniquement écouter les paquets d'une taille supérieure à 100 octetsutilisez la condition **great** :
-# If set to enabledfirewall 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 +
-# Defaultno +
-Lockdown=no+
  
-IPv6_rpfilter +  tcpdump -i eth0 greater 100 [Entrée]
-# Performs a reverse path filter test on a packet for IPv6. If a reply to the +
-# packet would be sent via the same interface that the packet arrived on, the  +
-# packet will match and be accepted, otherwise dropped. +
-# The rp_filter for IPv4 is controlled using sysctl. +
-# Default: yes +
-IPv6_rpfilter=yes +
-</code>+
  
-===La Commande firewall-cmd===+L'utilisation des ses options et conditions peut être combinée pour donner des commandes telles :
  
-firewalld s'appuie sur netfilter. Pour cette raison, l'utilisation de firewall-cmd est incompatible avec l'utilisation des commandes iptables et system-config-firewall.+  # tcpdump -i eth0 -X src host 192.168.1.11 and dst host 192.168.1.2 and port 21 and ftp [Entrée]
  
-<WRAP center round important> +=====LAB #6 Mise en place d'un VPN avec OpenVPN=====
-firewall-cmd est le front-end de firewalld en ligne de commande. Il existe aussi la commande **firewall-config** qui lance un outil de configuration graphique. +
-</WRAP>+
  
-Pour obtenir la liste de toutes les zones prédéfinies, utilisez la commande suivante :+====6.1 - Présentation====
  
-<code> +**%%OpenVPN%%** permet à des pairs de s'authentifier entre eux à l'aide :
-root@debian8:~# firewall-cmd --get-zones +
-block dmz drop external home internal public trusted work +
-</code>+
  
-Pour obtenir la liste de toutes les services prédéfinisutilisez la commande suivante :+  * d'une **clé privée partagée** à l'avance,  
 +  * de **certificats** ou 
 +  * à partir de la version 2.0 et à condition que le serveur possède un certificat, de **couples de noms d'utilisateur/mot de passe** sans besoin d'un certificat client 
  
-<code> +**%%OpenVPN%%** :
-root@debian8:~# firewall-cmd --get-services +
-amanda-client amanda-k5-client bacula bacula-client dhcp dhcpv6 dhcpv6-client dns freeipa-ldap freeipa-ldaps freeipa-replication ftp high-availability http https imaps ipp ipp-client ipsec kadmin kerberos kpasswd ldap ldaps libvirt libvirt-tls mdns mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s postgresql privoxy proxy-dhcp puppetmaster radius rpc-bind samba samba-client sane smtp squid ssh synergy telnet tftp tftp-client tor-socks transmission-client vnc-server wbem-https xmpp-bosh xmpp-client xmpp-local xmpp-server +
-</code>+
  
-Pour obtenir la liste de toutes les types ICMP prédéfinisutilisez la commande suivante :+  * utilise de manière intensive la bibliothèque d'authentification **%%OpenSSL%%** ainsi que le protocole **SSLv3/TLSv1** 
 +  * n'est pas compatible avec IPsec ou d'autres logiciels VPN. 
  
-<code> +====6.2 Configuration commune au client et au serveur====
-root@debian8:~# firewall-cmd --get-icmptypes +
-destination-unreachable echo-reply echo-request parameter-problem redirect router-advertisement router-solicitation source-quench time-exceeded +
-</code>+
  
-Pour obtenir la liste des zones de la configuration courante, utilisez la commande suivante :+Commencez par vérifiez si le paquet **openssl** est bien installé :
  
 <code> <code>
-root@debian8:~# firewall-cmd --get-active-zones +[root@centos7 ~]rpm -q openssl 
-public +openssl-1.0.2k-8.el7.x86_64
-  interfaces: eth0+
 </code> </code>
  
-Pour obtenir la liste des zones de la configuration courante pour une interface spécifique, utilisez la commande suivante :+Installez ensuite le paquet openvpn :
  
 <code> <code>
-root@debian8:~# firewall-cmd --get-zone-of-interface=eth0 +[root@centos7 ~]yum install openvpn
-public+
 </code> </code>
  
-Pour obtenir la liste des services autorisés pour la zone public, utilisez la commande suivante :+Naviguez au répertoire **/etc/openvpn** et créez la clef partagée :
  
 <code> <code>
-root@debian8:~# firewall-cmd --zone=public --list-services +[root@centos7 ~]cd /etc/openvpn/ 
-dhcpv6-client ssh+[root@centos7 openvpn]# openvpn --genkey --secret static.key 
 +[root@centos7 openvpn]# cat static.key  
 +
 +# 2048 bit OpenVPN static key 
 +
 +-----BEGIN OpenVPN Static key V1----- 
 +54f96ea50dbef7d5341efeda459b05ad 
 +5af134bf915bbd867fdd6310f4f0b72b 
 +331a82cdc6080622a7861e8c30cd0ffb 
 +6b35c143e5c715077247270bdb610fc8 
 +4c536f34742ba23f2bfe9ab148b3fa04 
 +20d1f6e5a20d58db30cce56ce1ca5744 
 +3028353a7e5e47b3f630738b71b04a1e 
 +e388b5e986826ce481ff457157b3492e 
 +61c147cd3d4373e283ad91c8ac44c0e8 
 +3b593d342cd0a2600db7b3e7cd0efa89 
 +d38dd861c1e4fc566e5e50004b102c7f 
 +b444795e2691cd59dfbb51e79996339d 
 +7e54d002aa4d5c63b3c155fbcc20f696 
 +fe148128f2e94e509c39c72c117a684b 
 +9fa8c7e159c451a7c52f42b2260d62c9 
 +586d66a454319ba538559c143643e434 
 +-----END OpenVPN Static key V1-----
 </code> </code>
  
-Pour obtenir toute la configuration pour la zone public, utilisez la commande suivante :+L'architecture réseau sera donc la suivante :
  
-<code+<file
-root@debian8:~# firewall-cmd --zone=public --list-all +                                   serveur <------------Votre réseau-------------> client 
-public (default, active) +                                                                                    | 
-  interfaces: eth0 +                                                                                    | 
-  sources:  +                                  eth0@ifxxx                                      eth0@ifxxx 
-  services: dhcpv6-client ssh +                                  172.yy.0.3                                      172.yy.0.4  
-  ports:  +</file>
-  masquerade: no +
-  forward-ports:  +
-  icmp-blocks:  +
-  rich rules:  +
-  +
-</code>+
  
-Pour obtenir la liste complète de toutes les zones et leurs configurations, utilisez la commande suivante : +====6.3 Configuration du client====
- +
-<code> +
-root@debian8:~# firewall-cmd --list-all-zones +
-block +
-  interfaces:  +
-  sources:  +
-  services:  +
-  ports:  +
-  masquerade: no +
-  forward-ports:  +
-  icmp-blocks:  +
-  rich rules:  +
-  +
-dmz +
-  interfaces:  +
-  sources:  +
-  services: ssh +
-  ports:  +
-  masquerade: no +
-  forward-ports:  +
-  icmp-blocks:  +
-  rich rules:  +
-  +
-drop +
-  interfaces:  +
-  sources:  +
-  services:  +
-  ports:  +
-  masquerade: no +
-  forward-ports:  +
-  icmp-blocks:  +
-  rich rules:  +
-  +
-external +
-  interfaces:  +
-  sources:  +
-  services: ssh +
-  ports:  +
-  masquerade: yes +
-  forward-ports:  +
-  icmp-blocks:  +
-  rich rules:  +
-  +
-home +
-  interfaces:  +
-  sources:  +
-  services: dhcpv6-client mdns samba-client ssh +
-  ports:  +
-  masquerade: no +
-  forward-ports:  +
-  icmp-blocks:  +
-  rich rules:  +
-  +
-internal +
-  interfaces:  +
-  sources:  +
-  services: dhcpv6-client mdns samba-client ssh +
-  ports:  +
-  masquerade: no +
-  forward-ports:  +
-  icmp-blocks:  +
-  rich rules:  +
-  +
-public (default, active) +
-  interfaces: eth0 +
-  sources:  +
-  services: dhcpv6-client ssh +
-  ports:  +
-  masquerade: no +
-  forward-ports:  +
-  icmp-blocks:  +
-  rich rules:  +
-  +
-trusted +
-  interfaces:  +
-  sources:  +
-  services:  +
-  ports:  +
-  masquerade: no +
-  forward-ports:  +
-  icmp-blocks:  +
-  rich rules:  +
-  +
-work +
-  interfaces:  +
-  sources:  +
-  services: dhcpv6-client ssh +
-  ports:  +
-  masquerade: no +
-  forward-ports:  +
-  icmp-blocks:  +
-  rich rules:  +
- +
-</code>+
  
-Pour changer la zone par défaut de public à work, utilisez la commande suivante :+Créez le fichier **/etc/openvpn/client.conf** :
  
 <code> <code>
-root@debian8:~# firewall-cmd --set-default-zone=work +[root@centos7 ~]vi /etc/openvpn/client.conf 
-success +[root@centos7 ~]cat /etc/openvpn/client.conf 
-root@debian8:~# firewall-cmd --get-active-zones +remote 10.0.2.15 
-work +dev tun 
-  interfaces: eth0+port 1194 
 +proto udp 
 +comp-lzo 
 +ifconfig 10.0.0.2 10.0.0.1 
 +secret /etc/openvpn/static.key 
 </code> </code>
  
-HERE+<WRAP center round important 50%> 
 +**Important** - Trouvez la signification de chacune des directives dans ce fichier. 
 +</WRAP>
  
-Pour ajouter l'interface ip_fixe à la zone work, utilisez la commande suivante :+Arrêtez le service **firewalld** :
  
 <code> <code>
-root@debian8:~# firewall-cmd --zone=work --add-interface=ip_fixe +[root@centos7 ~]systemctl stop firewalld
-success +
-root@debian8:~# firewall-cmd --get-active-zones +
-work +
-  interfaces: eth0 ip_fixe+
 </code> </code>
  
-Pour supprimer l'interface ip_fixe à la zone work, utilisez la commande suivante :+Lancez openvpn en ligne de commande et en arrière plan en spécifiant une journalisation :
  
 <code> <code>
-root@debian8:~# firewall-cmd --zone=work --remove-interface=ip_fixe +[root@centos7 ~]openvpn --config /etc/openvpn/client.conf > /var/log/vpn 2>&1 &
-success +
-root@debian8:~# firewall-cmd --get-active-zones +
-work +
-  interfaces: eth0+
 </code> </code>
  
-Pour ajouter le service **http** à la zone **work**, utilisez la commande suivante :+Vérifiez ensuite que le **socket** d'openvpn soit ouvert :
  
 <code> <code>
-root@debian8:~# firewall-cmd --zone=work --add-service=http +[root@centos7 ~]netstat -an | grep 1194 
-success +udp        0      0 0.0.0.0:1194                0.0.0.0:   
-root@debian8:~# firewall-cmd --zone=work --list-services +
-dhcpv6-client http ssh+
 </code> </code>
  
-Pour supprimer le service **http** de la zone **work**, utilisez la commande suivante :+Constatez ensuite la table de routage :
  
-<code> +<code>                             
-root@debian8:~# firewall-cmd --zone=work --remove-service=http +[root@centos7 ~]netstat -ar  
-success +Kernel IP routing table 
-root@debian8:~# firewall-cmd --zone=work --list-services +Destination     Gateway         Genmask         Flags   MSS Fenêtre irtt Iface 
-dhcpv6-client ssh+default         gateway         0.0.0.0         UG        0 0          0 enp0s3 
 +10.0.0.1        0.0.0.0         255.255.255.255 UH        0 0          0 tun0 
 +10.0.2.0        0.0.0.0         255.255.255.0           0 0          0 enp0s3
 </code> </code>
  
-Pour ajouter un nouveau bloc ICMP, utilisez la commande suivante :+Notez la présence de la route via **tun0**.
  
-<code> +Constatez ensuite le montage du tunnel en regardant le contenu du fichier de journalisation **/var/log/vpn** :
-root@debian8:~# firewall-cmd --zone=work --add-icmp-block=echo-reply +
-success +
-root@debian8:~# firewall-cmd --zone=work --list-icmp-blocks +
-echo-reply +
-</code> +
- +
-Pour supprimer un bloc ICMP, utilisez la commande suivante :+
  
 <code> <code>
-root@debian8:~# firewall-cmd --zone=work --remove-icmp-block=echo-reply +[root@centos7 ~]tail /var/log/vpn
-success +
-root@debian8:~# firewall-cmd --zone=work --list-icmp-blocks +
-root@debian8:~#  +
 </code> </code>
  
-Pour ajouter le port 591/tcp à la zone work, utilisez la commande suivante :+====6.4 - Configuration du serveur====
  
-<code> +Créez le fichier **/etc/openvpn/server.conf** :
-root@debian8:~# firewall-cmd --zone=work --add-port=591/tcp +
-success +
-root@debian8:~# firewall-cmd --zone=work --list-ports +
-591/tcp +
-</code> +
- +
-Pour supprimer le port 591/tcp à la zone work, utilisez la commande suivante :+
  
 <code> <code>
-root@debian8:~# firewall-cmd --zone=work --remove-port=591/tcp +[root@centos7 ~]vi /etc/openvpn/server.conf 
-success +[root@centos7 ~]cat /etc/openvpn/server.conf 
-root@debian8:~# firewall-cmd --zone=work --list-ports +dev tun 
-root@debian8:~# +ifconfig 10.0.0.1 10.0.0.2 
 +secret /etc/openvpn/static.key 
 +port 1194 
 +proto udp 
 +user nobody 
 +group nobody 
 +daemon 
 +comp-lzo 
 +keepalive 10 60 
 +ping-timer-rem 
 +persist-tun 
 +persist-key 
 +log /var/log/vpn 
 +verb 1
 </code> </code>
  
-Pour créer un nouveau service, il convient de :+<WRAP center round important 50%> 
 +**Important** - Trouvez la signification de chacune des directives dans ce fichier. 
 +</WRAP>
  
-  * copier un fichier existant se trouvant dans le répertoire **/usr/lib/firewalld/services** vers **/etc/firewalld/services**, +Arrêtez le service **firewalld** :
-  * modifier le fichier, +
-  * recharger la configuration de firewalld, +
-  * vérifier que firewalld voit le nouveau service. +
- +
-Par exemple :+
  
 <code> <code>
-root@debian8:~# cp /usr/lib/firewalld/services/http.xml /etc/firewalld/services/filemaker.xml  +[root@centos7 ~]systemctl stop firewalld
-root@debian8:~# cat /etc/firewalld/services/filemaker.xml  +
-<?xml version="1.0" encoding="utf-8"?> +
-<service> +
-  <short>WWW (HTTP)</short> +
-  <description>HTTP is the protocol used to serve Web pages. If you plan to make your Web server publicly available, enable this option. This option is not required for viewing pages locally or developing Web pages.</description> +
-  <port protocol="tcp" port="80"/> +
-</service> +
-root@debian8:~# vi /etc/firewalld/services/filemaker.xml +
-root@debian8:~# cat /etc/firewalld/services/filemaker.xml  +
-<?xml version="1.0" encoding="utf-8"?> +
-<service> +
-  <short>FileMakerPro</short> +
-  <description>fichier de service firewalld pour FileMaker Pro</description> +
-  <port protocol="tcp" port="591"/> +
-</service> +
-root@debian8:~# firewall-cmd --reload +
-success +
-root@debian8:~# firewall-cmd --get-services +
-amanda-client amanda-k5-client bacula bacula-client dhcp dhcpv6 dhcpv6-client dns filemaker freeipa-ldap freeipa-ldaps freeipa-replication ftp high-availability http https imaps ipp ipp-client ipsec kadmin kerberos kpasswd ldap ldaps libvirt libvirt-tls mdns mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s postgresql privoxy proxy-dhcp puppetmaster radius rpc-bind samba samba-client sane smtp squid ssh synergy telnet tftp tftp-client tor-socks transmission-client vnc-server wbem-https xmpp-bosh xmpp-client xmpp-local xmpp-server+
 </code> </code>
  
-===La Configuration Avancée de firewalld=== +Lancez openvpn en ligne de commande et en arrière plan en spécifiant une journalisation :
- +
-La configuration de base de firewalld ne permet que la configuration des zones, services, blocs ICMP et les ports non-standard. Cependant firewalld peut également être configuré avec des **Rich Rules** ou **//Règles Riches//**. Rich Rules ou Règles Riches évaluent des **critères** pour ensuite entreprendre une **action**.  +
- +
-Les **Critères** sont : +
- +
-  * **source address="<adresse_IP>"** +
-  * **destination address="<adresse_IP>"**, +
-  * **rule port port="<numéro_du_port>"**, +
-  * **service name=<nom_d'un_sevice_prédéfini>**. +
- +
-Les **Actions** sont : +
- +
-  * **accept**, +
-  * **reject**, +
-    * une Action reject peut être associée avec un message d'erreur spécifique par la clause **type="<type_d'erreur>**, +
-  * **drop**. +
- +
-Saisissez la commande suivante pour ouvrir le port 80 :+
  
 <code> <code>
-root@debian8:~# firewall-cmd --add-rich-rule='rule port port="80" protocol="tcp" accept' +[root@centos7 ~]openvpn --config /etc/openvpn/server.conf > /var/log/vpn 2>&1 & 
-success+[1] 7751
 </code> </code>
  
-<WRAP center round important 50%> +Vérifiez ensuite que le **socket** d'openvpn soit ouvert :
-Notez que la Rich Rule doit être entourée de caractères **'**.  +
-</WRAP> +
- +
-Saisissez la commande suivante pour visualiser la règle iptables pour IPv4 :+
  
 <code> <code>
-root@debian8:~# iptables -L -n | grep 80 +[root@centos7 ~]netstat -an | grep 1194 
-ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:80 ctstate NEW+udp        0      0 0.0.0.0:1194                0.0.0.0:*    
 </code> </code>
  
-Saisissez la commande suivante pour visualiser la règle iptables pour IPv6 :+Constatez ensuite la table de routage :
  
-<code> +<code>                             
-root@debian8:~# ip6tables -L -n | grep 80 +[root@centos7 ~]netstat -ar  
-ACCEPT     udp      ::/                fe80::/64            udp dpt:546 ctstate NEW +Kernel IP routing table 
-ACCEPT     tcp      ::/                ::/                tcp dpt:80 ctstate NEW+Destination     Gateway         Genmask         Flags   MSS Fenêtre irtt Iface 
 +0.0.0.0         10.0.2.2        0.0.0.0         UG        0 0          0 enp0s3 
 +10.0.0.1        0.0.0.0         255.255.255.255 UH        0 0          0 tun0 
 +10.0.2.0        0.0.0.0         255.255.255.0                    enp0s3
 </code> </code>
  
-<WRAP center round important 50%> +Constatez ensuite le montage du tunnel en regardant le contenu du fichier de journalisation **/var/log/vpn** :
-**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**. +
-</WRAP> +
- +
-Cette nouvelle règle est écrite en mémoire mais non pas sur disque. Pour l'écrire sur disque dans le fichier zone se trouvant dans **/etc/firewalld**, il faut ajouter l'option **--permanent** :+
  
 <code> <code>
-root@debian8:~# firewall-cmd --add-rich-rule='rule port port="80" protocol="tcp" accept' --permanent +[root@centos7 ~]tail /var/log/vpn
-success +
-root@debian8:~# cat /etc/firewalld/zones/work.xml +
-<?xml version="1.0" encoding="utf-8"?> +
-<zone> +
-  <short>Work</short> +
-  <description>For use in work areas. You mostly trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description> +
-  <service name="dhcpv6-client"/> +
-  <service name="ssh"/> +
-  <rule> +
-    <port protocol="tcp" port="80"/> +
-    <accept/+
-  </rule> +
-</zone>+
 </code> </code>
  
-<WRAP center round important 50%> +====6.Tests====
-**Important** - Attention ! La règle ajoutée avec l'option --permanent n'est pas prise en compte imédiatement mais uniquement au prochain redémmargePour qu'une règle soit appliquée immédiatement **et** être écrite sur disque, il faut saisir la commande deux fois dont une avec l'option --permanent et l'autre sans l'option --permanent. +
-</WRAP>+
  
-Pour visualiser cette règle dans la configuration de firewalld, il convient de saisir la commande suivante :+===Du client vers le serveur===
  
-<code> +Sur le clientutilisez la commande ping pour envoyer des paquets dans le tunnel :
-root@debian8:~# firewall-cmd --list-all-zones +
-...  +
-work (defaultactive) +
-  interfaces: eth0 +
-  sources:  +
-  services: dhcpv6-client ssh +
-  ports:  +
-  masquerade: no +
-  forward-ports:  +
-  icmp-blocks:  +
-  rich rules:  +
- rule port port="80" protocol="tcp" accept +
- +
-</code> +
- +
-Notez que la Rich Rule est créée dans la Zone par Défaut. Il est possible de créer une Rich Rule dans une autre zone en utilisant l'option **--zone=<zone>** de la commande firewall-cmd :+
  
 <code> <code>
-root@debian8:~# firewall-cmd --zone=public --add-rich-rule='rule port port="80" protocol="tcp" accept' +[root@centos7 ~]ping -c3 10.0.0.1 
-success +PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data. 
-root@debian8:~# firewall-cmd --list-all-zones +64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=7.62 ms 
-... +64 bytes from 10.0.0.1icmp_seq=2 ttl=64 time=1.35 ms 
-public +64 bytes from 10.0.0.1icmp_seq=3 ttl=64 time=0.000 ms
-  interfaces +
-  sources:  +
-  services: dhcpv6-client ssh +
-  ports:  +
-  masquerade: no +
-  forward-ports:  +
-  icmp-blocks:  +
-  rich rules:  +
- rule port port="80" protocol="tcp" accept +
-trusted +
-  interfaces +
-  sources:  +
-  services:  +
-  ports:  +
-  masquerade: no +
-  forward-ports:  +
-  icmp-blocks:  +
-  rich rules:  +
-  +
-work (default, active) +
-  interfaces: eth0 +
-  sources:  +
-  services: dhcpv6-client ssh +
-  ports:  +
-  masquerade: no +
-  forward-ports:  +
-  icmp-blocks:  +
-  rich rules:  +
- rule port port="80" protocol="tcp" accept +
-</code>+
  
- +--- 10.0.0.1 ping statistics --- 
-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** : +3 packets transmitted, 3 received, 0% packet loss, time 2047ms 
- +rtt min/avg/max/mdev 0.000/2.994/7.629/3.323 ms
-<code> +
-root@debian8:~# firewall-cmd --zone=public --remove-rich-rule='rule port port="80" protocol="tcp" accept' +
-success+
 </code> </code>
  
-===Le mode Panic de firewalld===+===Du serveur vers le client===
  
-Le mode Panic de firewalld permet de bloquer tout le trafic avec une seule commande. Pour connaître l'état du mode Panic, utilisez la commande suivante :+Sur le serveur, utilisez la commande ping pour envoyer des paquets dans le tunnel :
  
 <code> <code>
-root@debian8:~# firewall-cmd --query-panic +[root@centos7 ~]ping -c5 10.0.0.2 
-no +PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data. 
-</code>+64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=2.59 ms 
 +64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=9.08 ms 
 +64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=7.24 ms 
 +64 bytes from 10.0.0.2: icmp_seq=4 ttl=64 time=7.03 ms 
 +64 bytes from 10.0.0.2: icmp_seq=5 ttl=64 time=4.08 ms
  
-Pour activer le mode Panic, il convient de saisir la commande suivante : +--- 10.0.0.2 ping statistics --- 
- +5 packets transmitted, 5 received, 0% packet loss, time 4034ms 
-<code> +rtt min/avg/max/mdev = 2.597/6.008/9.084/2.340 ms
-root@debian8:~# firewall-cmd --panic-on +
-success +
-root@debian8:~# firewall-cmd --query-panic +
-yes +
-</code> +
- +
-Pour désactiver le mode Panic, il convient de saisir la commande suivante : +
- +
-<code> +
-root@debian8:~# firewall-cmd --panic-off +
-success +
-root@debian8:~# firewall-cmd --query-panic +
-no+
 </code> </code>
  
Ligne 7642: Ligne 6574:
  
 {{:redhat:lx04:crypto9.gif|Cette image issue de Comment Ça Marche (www.commentcamarche.net) est mise à disposition sous les termes de la licence Creative Commons. Vous pouvez copier, modifier des copies de l'image, dans les conditions fixées par la licence, tant que cette note apparaît clairement.}} {{:redhat:lx04:crypto9.gif|Cette image issue de Comment Ça Marche (www.commentcamarche.net) est mise à disposition sous les termes de la licence Creative Commons. Vous pouvez copier, modifier des copies de l'image, dans les conditions fixées par la licence, tant que cette note apparaît clairement.}}
 +
 +=====Annexe 4 - La Commande iw=====
 +
 +La commande **iw** permet de gérer le wifi :
 +
 +<code>
 +root@debian11:~# iw dev wlo1 link
 +Connected to 00:5f:67:53:be:f4 (on wlo1)
 + SSID: TP-Link_BEF5_5G
 + freq: 5220
 + RX: 3323698885 bytes (7423914 packets)
 + TX: 1238020520 bytes (5751871 packets)
 + signal: -30 dBm
 + rx bitrate: 433.3 MBit/s VHT-MCS 9 80MHz short GI VHT-NSS 1
 + tx bitrate: 433.3 MBit/s VHT-MCS 9 80MHz short GI VHT-NSS 1
 +
 + bss flags: short-slot-time
 + dtim period: 1
 + beacon int: 100
 +root@debian11:~# iwconfig wlo1
 +wlo1      IEEE 802.11  ESSID:"TP-Link_BEF5_5G"  
 +          Mode:Managed  Frequency:5.22 GHz  Access Point: 00:5F:67:53:BE:F4   
 +          Bit Rate=433.3 Mb/s   Tx-Power=22 dBm   
 +          Retry short limit:  RTS thr:off   Fragment thr:off
 +          Encryption key:off
 +          Power Management:on
 +          Link Quality=70/70  Signal level=-30 dBm  
 +          Rx invalid nwid: Rx invalid crypt: Rx invalid frag:0
 +          Tx excessive retries: Invalid misc:  Missed beacon:0
 +</code>
 +
 +Les options de cette commande sont :
 +
 +<code>
 +root@debian11:~# iw --help
 +Usage:  iw [options] command
 +Options:
 +        --debug         enable netlink debugging
 +        --version       show version (5.9)
 +Commands:
 +        dev <devname> ap stop 
 +                Stop AP functionality
 +
 +
 +        dev <devname> ap start 
 +                <SSID> <control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]] <beacon interval in TU> <DTIM period> [hidden-ssid|zeroed-ssid] head <beacon head in hexadecimal> [tail <beacon tail in hexadecimal>] [inactivity-time <inactivity time in seconds>] [key0:abcde d:1:6162636465]
 +
 +
 +        phy <phyname> coalesce show 
 +                Show coalesce status.
 +
 +        phy <phyname> coalesce disable 
 +                Disable coalesce.
 +
 +        phy <phyname> coalesce enable <config-file>
 +                Enable coalesce with given configuration.
 +                The configuration file contains coalesce rules:
 +                  delay=<delay>
 +                  condition=<condition>
 +                  patterns=<[offset1+]<pattern1>,<[offset2+]<pattern2>,...>
 +                  delay=<delay>
 +                  condition=<condition>
 +                  patterns=<[offset1+]<pattern1>,<[offset2+]<pattern2>,...>
 +                  ...
 +                delay: maximum coalescing delay in msec.
 +                condition: 1/0 i.e. 'not match'/'match' the patterns
 +                patterns: each pattern is given as a bytestring with '-' in
 +                places where any byte may be present, e.g. 00:11:22:-:44 will
 +                match 00:11:22:33:44 and 00:11:22:33:ff:44 etc. Offset and
 +                pattern should be separated by '+', e.g. 18+43:34:00:12 will
 +                match '43:34:00:12' after 18 bytes of offset in Rx packet.
 +
 +
 +        dev <devname> auth <SSID> <bssid> <type:open|shared> <freq in MHz> [key 0:abcde d:1:6162636465]
 +                Authenticate with the given network.
 +
 +
 +        dev <devname> connect [-w] <SSID> [<freq in MHz>] [<bssid>] [key 0:abcde d:1:6162636465] [mfp:req/opt/no]
 +                Join the network with the given SSID (and frequency, BSSID).
 +                With -w, wait for the connect to finish or fail.
 +
 +        dev <devname> disconnect
 +                Disconnect from the current network.
 +
 +        dev <devname> cqm rssi <threshold|off> [<hysteresis>]
 +                Set connection quality monitor RSSI threshold.
 +
 +
 +        event [-t|-r] [-f]
 +                Monitor events from the kernel.
 +                -t - print timestamp
 +                -r - print relative timestamp
 +                -f - print full frame for auth/assoc etc.
 +
 +        dev <devname> ftm start_responder [lci=<lci buffer in hex>] [civic=<civic buffer in hex>]
 +                Start an FTM responder. Needs a running ap interface
 +
 +
 +        dev <devname> ftm get_stats 
 +                Get FTM responder statistics.
 +
 +
 +        phy <phyname> hwsim wakequeues 
 +
 +
 +        phy <phyname> hwsim stopqueues 
 +
 +
 +        phy <phyname> hwsim setps <value>
 +
 +
 +        phy <phyname> hwsim getps 
 +
 +
 +        dev <devname> ibss join <SSID> <freq in MHz> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [fixed-freq] [<fixed bssid>] [beacon-interval <TU>] [basic-rates <rate in Mbps,rate2,...>] [mcast-rate <rate in Mbps>] [key d:0:abcde]
 +                Join the IBSS cell with the given SSID, if it doesn't exist create
 +                it on the given frequency. When fixed frequency is requested, don't
 +                join/create a cell on a different frequency. When a fixed BSSID is
 +                requested use that BSSID and do not adopt another cell's BSSID even
 +                if it has higher TSF and the same SSID. If an IBSS is created, create
 +                it with the specified basic-rates, multicast-rate and beacon-interval.
 +
 +        dev <devname> ibss leave
 +                Leave the current IBSS cell.
 +
 +        features 
 +
 +
 +        commands
 +                list all known commands and their decimal & hex value
 +
 +        phy
 +        list
 +                List all wireless devices and their capabilities.
 +
 +        phy <phyname> info
 +                Show capabilities for the specified wireless device.
 +
 +        dev <devname> switch channel <channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]
 +        dev <devname> switch freq <freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]
 +        dev <devname> switch freq <control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]] [beacons <count>] [block-tx]
 +                Switch the operating channel by sending a channel switch announcement (CSA).
 +
 +        dev
 +                List all network interfaces for wireless hardware.
 +
 +        dev <devname> info
 +                Show information for this interface.
 +
 +        dev <devname> del
 +                Remove this virtual interface
 +
 +        dev <devname> interface add <name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*] [addr <mac-addr>]
 +        phy <phyname> interface add <name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*] [addr <mac-addr>]
 +                Add a new virtual interface with the given configuration.
 +                Valid interface types are: managed, ibss, monitor, mesh, wds.
 +
 +                The flags are only used for monitor interfaces, valid flags are:
 +                none:     no special flags
 +                fcsfail:  show frames with FCS errors
 +                control:  show control frames
 +                otherbss: show frames from other BSSes
 +                cook:     use cooked mode
 +                active:   use active mode (ACK incoming unicast packets)
 +                mumimo-groupid <GROUP_ID>: use MUMIMO according to a group id
 +                mumimo-follow-mac <MAC_ADDRESS>: use MUMIMO according to a MAC address
 +
 +                The mesh_id is used only for mesh mode.
 +
 +        help [command]
 +                Print usage for all or a specific command, e.g.
 +                "help wowlan" or "help wowlan enable".
 +
 +        dev <devname> link
 +                Print information about the current link, if any.
 +
 +        dev <devname> measurement ftm_request <config-file> [timeout=<seconds>] [randomise[=<addr>/<mask>]]
 +                Send an FTM request to the targets supplied in the config file.
 +                Each line in the file represents a target, with the following format:
 +                <addr> bw=<[20|40|80|80+80|160]> cf=<center_freq> [cf1=<center_freq1>] [cf2=<center_freq2>] [ftms_per_burst=<samples per burst>] [ap-tsf] [asap] [bursts_exp=<num of bursts exponent>] [burst_period=<burst period>] [retries=<num of retries>] [burst_duration=<burst duration>] [preamble=<legacy,ht,vht,dmg>] [lci] [civic] [tb] [non_tb]
 +
 +        dev <devname> mesh leave
 +                Leave a mesh.
 +
 +        dev <devname> mesh join <mesh ID> [[freq <freq in MHz> <NOHT|HT20|HT40+|HT40-|80MHz>] [basic-rates <rate in Mbps,rate2,...>]], [mcast-rate <rate in Mbps>] [beacon-interval <time in TUs>] [dtim-period <value>] [vendor_sync on|off] [<param>=<value>]*
 +                Join a mesh with the given mesh ID with frequency, basic-rates,
 +                mcast-rate and mesh parameters. Basic-rates are applied only if
 +                frequency is provided.
 +
 +        dev <devname> mgmt dump frame <type as hex ab> <pattern as hex ab:cd:..> [frame <type> <pattern>]* [count <frames>]
 +                Register for receiving certain mgmt frames and print them.
 +                Frames are selected by their type and pattern containing
 +                the first several bytes of the frame that should match.
 +
 +                Example: iw dev wlan0 mgmt dump frame 40 00 frame 40 01:02 count 10
 +
 +
 +        dev <devname> mpath dump
 +                List known mesh paths.
 +
 +        dev <devname> mpath set <destination MAC address> next_hop <next hop MAC address>
 +                Set an existing mesh path's next hop.
 +
 +        dev <devname> mpath new <destination MAC address> next_hop <next hop MAC address>
 +                Create a new mesh path (instead of relying on automatic discovery).
 +
 +        dev <devname> mpath del <MAC address>
 +                Remove the mesh path to the given node.
 +
 +        dev <devname> mpath get <MAC address>
 +                Get information on mesh path to the given node.
 +
 +        dev <devname> mpath probe <destination MAC address> frame <frame>
 +                Inject ethernet frame to given peer overriding the next hop
 +                lookup from mpath table.
 +                .Example: iw dev wlan0 mpath probe xx:xx:xx:xx:xx:xx frame 01:xx:xx:00
 +
 +
 +        dev <devname> mpp dump
 +                List known mesh proxy paths.
 +
 +        dev <devname> mpp get <MAC address>
 +                Get information on mesh proxy path to the given node.
 +
 +        wdev <idx> nan add_func type <publish|subscribe|followup> [active] [solicited] [unsolicited] [bcast] [close_range] name <name> [info <info>] [flw_up_id <id> flw_up_req_id <id> flw_up_dest <mac>] [ttl <ttl>] [srf <include|exclude> <bf|list> [bf_idx] [bf_len] <mac1;mac2...>] [rx_filter <str1:str2...>] [tx_filter <str1:str2...>]
 +
 +
 +        wdev <idx> nan rm_func cookie <cookie>
 +
 +
 +        wdev <idx> nan config [pref <pref>] [bands [2GHz] [5GHz]]
 +
 +
 +        wdev <idx> nan stop 
 +
 +
 +        wdev <idx> nan start pref <pref> [bands [2GHz] [5GHz]]
 +
 +
 +        dev <devname> ocb leave
 +                Leave the OCB mode network.
 +
 +        dev <devname> ocb join <freq in MHz> <5MHz|10MHz>
 +                Join the OCB mode network.
 +
 +        dev <devname> offchannel <freq> <duration>
 +                Leave operating channel and go to the given channel for a while.
 +
 +        wdev <idx> p2p stop 
 +
 +
 +        wdev <idx> p2p start 
 +
 +
 +        dev <devname> cac channel <channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]
 +        dev <devname> cac freq <freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]
 +        dev <devname> cac freq <control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]
 +        dev <devname> cac trigger channel <channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]
 +        dev <devname> cac trigger freq <frequency> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]
 +        dev <devname> cac trigger freq <frequency> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]
 +                Start or trigger a channel availability check (CAC) looking to look for
 +                radars on the given channel.
 +
 +        phy <phyname> channels
 +                Show available channels.
 +
 +        reg reload
 +                Reload the kernel's regulatory database.
 +
 +        phy <phyname> reg get
 +                Print out the devices' current regulatory domain information.
 +
 +        reg get
 +                Print out the kernel's current regulatory domain information.
 +
 +        reg set <ISO/IEC 3166-1 alpha2>
 +                Notify the kernel about the current regulatory domain.
 +
 +        dev <devname> roc start <freq> <time in ms>
 +
 +
 +        dev <devname> scan [-u] [freq <freq>*] [duration <dur>] [ies <hex as 00:11:..>] [meshid <meshid>] [lowpri,flush,ap-force,duration-mandatory] [randomise[=<addr>/<mask>]] [ssid <ssid>*|passive]
 +                Scan on the given frequencies and probe for the given SSIDs
 +                (or wildcard if not given) unless passive scanning is requested.
 +                If -u is specified print unknown data in the scan results.
 +                Specified (vendor) IEs must be well-formed.
 +
 +        dev <devname> scan sched_stop 
 +                Stop an ongoing scheduled scan.
 +
 +        dev <devname> scan sched_start [interval <in_msecs> | scan_plans [<interval_secs:iterations>*] <interval_secs>] [delay <in_secs>] [freqs <freq>+] [matches [ssid <ssid>]+]] [active [ssid <ssid>]+|passive] [randomise[=<addr>/<mask>]]
 +                Start a scheduled scan at the specified interval on the given frequencies
 +                with probing for the given SSIDs (or wildcard if not given) unless passive
 +                scanning is requested.  If matches are specified, only matching results
 +                will be returned.
 +
 +        dev <devname> scan abort 
 +                Abort ongoing scan
 +
 +        dev <devname> scan trigger [freq <freq>*] [duration <dur>] [ies <hex as 00:11:..>] [meshid <meshid>] [lowpri,flush,ap-force,duration-mandatory] [randomise[=<addr>/<mask>]] [ssid <ssid>*|passive]
 +                Trigger a scan on the given frequencies with probing for the given
 +                SSIDs (or wildcard if not given) unless passive scanning is requested.
 +                Duration(in TUs), if specified, will be used to set dwell times.
 +
 +
 +        dev <devname> scan dump [-u]
 +                Dump the current scan results. If -u is specified, print unknown
 +                data in scan results.
 +
 +        dev <devname> set bitrates [legacy-<2.4|5> <legacy rate in Mbps>*] [ht-mcs-<2.4|5> <MCS index>*] [vht-mcs-<2.4|5> [he-mcs-<2.4|5|6> <NSS:MCSx,MCSy... | NSS:MCSx-MCSy>*] [sgi-2.4|lgi-2.4] [sgi-5|lgi-5] [he-gi-<2.4|5|6> <0.8|1.6|3.2>] [he-ltf-<2.4|5|6> <1|2|4>]
 +                Sets up the specified rate masks.
 +                Not passing any arguments would clear the existing mask (if any).
 +
 +        dev <devname> set tidconf [peer <MAC address>] tids <mask> [override] [sretry <num>] [lretry <num>] [ampdu [on|off]] [amsdu [on|off]] [noack [on|off]] [rtscts [on|off]][bitrates <type [auto|fixed|limit]> [legacy-<2.4|5> <legacy rate in Mbps>*] [ht-mcs-<2.4|5> <MCS index>*] [vht-mcs-<2.4|5> <NSS:MCSx,MCSy... | NSS:MCSx-MCSy>*] [sgi-2.4|lgi-2.4] [sgi-5|lgi-5]]
 +                Setup per-node TID specific configuration for TIDs selected by bitmask.
 +                If MAC address is not specified, then supplied TID configuration
 +                applied to all the peers.
 +                Examples:
 +                  $ iw dev wlan0 set tidconf tids 0x1 ampdu off
 +                  $ iw dev wlan0 set tidconf tids 0x5 ampdu off amsdu off rtscts on
 +                  $ iw dev wlan0 set tidconf tids 0x3 override ampdu on noack on rtscts on
 +                  $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x1 ampdu off tids 0x3 amsdu off rtscts on
 +                  $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates auto
 +                  $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates limit vht-mcs-5 4:9
 +
 +
 +        dev <devname> set mcast_rate <rate in Mbps>
 +                Set the multicast bitrate.
 +
 +        dev <devname> set peer <MAC address>
 +                Set interface WDS peer.
 +
 +        dev <devname> set noack_map <map>
 +                Set the NoAck map for the TIDs. (0x0009 = BE, 0x0006 = BK, 0x0030 = VI, 0x00C0 = VO)
 +
 +        dev <devname> set 4addr <on|off>
 +                Set interface 4addr (WDS) mode.
 +
 +        dev <devname> set type <type>
 +                Set interface type/mode.
 +                Valid interface types are: managed, ibss, monitor, mesh, wds.
 +
 +        dev <devname> set meshid <meshid>
 +        dev <devname> set monitor <flag>*
 +                Set monitor flags. Valid flags are:
 +                none:     no special flags
 +                fcsfail:  show frames with FCS errors
 +                control:  show control frames
 +                otherbss: show frames from other BSSes
 +                cook:     use cooked mode
 +                active:   use active mode (ACK incoming unicast packets)
 +                mumimo-groupid <GROUP_ID>: use MUMIMO according to a group id
 +                mumimo-follow-mac <MAC_ADDRESS>: use MUMIMO according to a MAC address
 +
 +        dev <devname> set mesh_param <param>=<value> [<param>=<value>]*
 +                Set mesh parameter (run command without any to see available ones).
 +
 +        phy <phyname> set txq limit <packets> | memory_limit <bytes> | quantum <bytes>
 +                Set TXQ parameters. The limit and memory_limit are global queue limits
 +                for the whole phy. The quantum is the DRR scheduler quantum setting.
 +                Valid values: 1 - 2**32
 +
 +        phy <phyname> set antenna <bitmap> | all | <tx bitmap> <rx bitmap>
 +                Set a bitmap of allowed antennas to use for TX and RX.
 +                The driver may reject antenna configurations it cannot support.
 +
 +        dev <devname> set txpower <auto|fixed|limit> [<tx power in mBm>]
 +                Specify transmit power level and setting type.
 +
 +        phy <phyname> set txpower <auto|fixed|limit> [<tx power in mBm>]
 +                Specify transmit power level and setting type.
 +
 +        phy <phyname> set distance <auto|distance>
 +                Enable ACK timeout estimation algorithm (dynack) or set appropriate
 +                coverage class for given link distance in meters.
 +                To disable dynack set valid value for coverage class.
 +                Valid values: 0 - 114750
 +
 +        phy <phyname> set coverage <coverage class>
 +                Set coverage class (1 for every 3 usec of air propagation time).
 +                Valid values: 0 - 255.
 +
 +        phy <phyname> set netns { <pid> | name <nsname> }
 +                Put this wireless device into a different network namespace:
 +                    <pid>    - change network namespace by process id
 +                    <nsname> - change network namespace by name from /run/netns
 +                               or by absolute path (man ip-netns)
 +
 +
 +        phy <phyname> set retry [short <limit>] [long <limit>]
 +                Set retry limit.
 +
 +        phy <phyname> set rts <rts threshold|off>
 +                Set rts threshold.
 +
 +        phy <phyname> set frag <fragmentation threshold|off>
 +                Set fragmentation threshold.
 +
 +        dev <devname> set channel <channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]
 +        phy <phyname> set channel <channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]
 +        dev <devname> set freq <freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]
 +        dev <devname> set freq <control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]
 +        phy <phyname> set freq <freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]
 +        phy <phyname> set freq <control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]
 +                Set frequency/channel the hardware is using, including HT
 +                configuration.
 +
 +        phy <phyname> set name <new name>
 +                Rename this wireless device.
 +
 +        dev <devname> set power_save <on|off>
 +                Set power save state to on or off.
 +
 +        dev <devname> get mesh_param [<param>]
 +                Retrieve mesh parameter (run command without any to see available ones).
 +
 +        phy <phyname> get txq 
 +                Get TXQ parameters.
 +
 +        dev <devname> get power_save <param>
 +                Retrieve power save state.
 +
 +        dev <devname> station dump [-v]
 +                List all stations known, e.g. the AP on managed interfaces
 +
 +        dev <devname> station set <MAC address> txpwr <auto|limit> [<tx power dBm>]
 +                Set Tx power for this station.
 +
 +        dev <devname> station set <MAC address> airtime_weight <weight>
 +                Set airtime weight for this station.
 +
 +        dev <devname> station set <MAC address> mesh_power_mode <active|light|deep>
 +                Set link-specific mesh power mode for this station
 +
 +        dev <devname> station set <MAC address> vlan <ifindex>
 +                Set an AP VLAN for this station.
 +
 +        dev <devname> station set <MAC address> plink_action <open|block>
 +                Set mesh peer link action for this station (peer).
 +
 +        dev <devname> station del <MAC address> [subtype <subtype>] [reason-code <code>]
 +                Remove the given station entry (use with caution!)
 +                Example subtype values: 0xA (disassociation), 0xC (deauthentication)
 +
 +        dev <devname> station get <MAC address>
 +                Get information for a specific station.
 +
 +        dev <devname> survey dump
 +                List all gathered channel survey data
 +
 +        dev <devname> vendor recvbin <oui> <subcmd> <filename|-|hex data>
 +
 +
 +        dev <devname> vendor recv <oui> <subcmd> <filename|-|hex data>
 +
 +
 +        dev <devname> vendor send <oui> <subcmd> <filename|-|hex data>
 +
 +
 +        phy <phyname> wowlan show 
 +                Show WoWLAN status.
 +
 +        phy <phyname> wowlan disable 
 +                Disable WoWLAN.
 +
 +        phy <phyname> wowlan enable [any] [disconnect] [magic-packet] [gtk-rekey-failure] [eap-identity-request] [4way-handshake] [rfkill-release] [net-detect [interval <in_msecs> | scan_plans [<interval_secs:iterations>*] <interval_secs>] [delay <in_secs>] [freqs <freq>+] [matches [ssid <ssid>]+]] [active [ssid <ssid>]+|passive] [randomise[=<addr>/<mask>]]] [tcp <config-file>] [patterns [offset1+]<pattern1> ...]
 +                Enable WoWLAN with the given triggers.
 +                Each pattern is given as a bytestring with '-' in places where any byte
 +                may be present, e.g. 00:11:22:-:44 will match 00:11:22:33:44 and
 +                00:11:22:33:ff:44 etc.
 +                Offset and pattern should be separated by '+', e.g. 18+43:34:00:12 will match '43:34:00:12' after 18 bytes of offset in Rx packet.
 +
 +                The TCP configuration file contains:
 +                  source=ip[:port]
 +                  dest=ip:port@mac
 +                  data=<hex data packet>
 +                  data.interval=seconds
 +                  [wake=<hex packet with masked out bytes indicated by '-'>]
 +                  [data.seq=len,offset[,start]]
 +                  [data.tok=len,offset,<token stream>]
 +
 +                Net-detect configuration example:
 +                 iw phy0 wowlan enable net-detect interval 5000 delay 30 freqs 2412 2422 matches ssid foo ssid bar
 +
 +
 +Commands that use the netdev ('dev') can also be given the
 +'wdev' instead to identify the device.
 +
 +You can omit the 'phy' or 'dev' if the identification is unique,
 +e.g. "iw wlan0 info" or "iw phy0 info". (Don't when scripting.)
 +
 +Do NOT screenscrape this tool, we don't consider its output stable.
 +</code>
 +
  
 ----- -----
-<html> +Copyright © 2022 Hugh Norris.
-<div align="center"> +
-Copyright © 2020 Hugh Norris +
-</div> +
-</html> +
------+
Menu