Changes between Version 10 and Version 11 of Realisations/2006-2007/Projet/Entreprise2/Client1


Ignore:
Timestamp:
Apr 28, 2007, 12:35:40 PM (18 years ago)
Author:
alladoum
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Realisations/2006-2007/Projet/Entreprise2/Client1

    v10 v11  
    1717
    1818----
    19 = '''''Configuration d'un flux IPSec en mode Transport sous FreeBSD''''' =
    20 
    21 == Configuration d'IPSec ==
    22 Cet exemple a été écrit pour la création d'un flux IPSec en mode Transport entre [wiki:Entreprise2Client1 CLIENT1.ENT2](10.40.0.13) et [wiki:Entreprise2Serveur1 SERVEUR1.ENT2] (10.40.0.9). [[BR]]
    23 
    24 === Vérifiez les options ===
    25 Les options
    26 {{{
    27 options  IPSEC
    28 options  IPSEC_ESP
    29 options  IPSEC_DEBUG (optionnel mais fortement recommandé)
    30 }}}
    31  doivent être installées sur le noyau que vous exécutez, sinon [http://www.freebsdebutant.org/index.php?page=configuration_noyau recompilez votre noyau].
    32    * Installez IPSec-tools et Racoon ( votre bonheur se trouve dans les /usr/ports/security)
    33 === Configurez IPSec pour FreeBSD ===
    34 [[BR]]
    35    * Créer le fichier /etc/ipsec.conf :
    36 {{{
    37 $ cat > /etc/ipsec.conf << EOF
    38 # Definition des SA + Cles
    39 # Rappel :
    40 # 3des-cbc,cle de 192 bits (24o)
    41 # hmac-md5,cle de 128 bits(16o)
    42 flush;
    43 
    44 ## de client1 vers serveur1
    45 add 10.40.0.13 10.40.0.9 ah  1000 -m transport -A hmac-md5 "1234567890123456";
    46 add 10.40.0.13 10.40.0.9 esp 1001 -m transport -E 3des-cbc "123456789012345678901234";
    47 
    48 ## de serveur1 vers client1
    49 add 10.40.0.9 10.40.0.13 ah  2000 -m transport -A hmac-md5 "1234567890123456";
    50 add 10.40.0.9 10.40.0.13 esp  2001 -m transport -E 3des-cbc "123456789012345678901234";
    51 
    52 # Definition des SPD
    53 spdflush;
    54 spdadd 10.40.0.13 10.40.0.9 any -P out ipsec
    55 esp/transport/10.40.0.13-10.40.0.9/use
    56 ah/transport/10.40.0.13-10.40.0.9/use;
    57 # politique en entree
    58 spdadd 10.40.0.9 10.40.0.13 any -P in ipsec
    59 ah/transport/10.40.0.9-10.40.0.13/use
    60 esp/transport/10.40.0.9-10.40.0.13/use;
    61 EOF
    62 }}}
    63    * Puis entrez
    64 {{{
    65 $ setkey -v -f /etc/ipsec.conf
    66 }}}
    67    * Maintenant, si vous entrez
    68 {{{
    69 $ setkey -D -P
    70 }}}
    71 la création des SA et SP devraient vous produire un affichage à peu près similaire à
    72 {{{
    73 [root@SERVEUR1 ~]# setkey -P -D
    74 10.40.0.13[any] 10.40.0.9[any] any
    75         in ipsec
    76         ah/transport/10.40.0.13-10.40.0.9/use
    77         esp/transport/10.40.0.13-10.40.0.9/use
    78         created: Apr 20 18:10:44 2007  lastused: Apr 20 18:10:44 2007
    79         lifetime: 0(s) validtime: 0(s)
    80         spid=16393 seq=1 pid=7761
    81         refcnt=1
    82 10.40.0.9[any] 10.40.0.13[any] any
    83         out ipsec
    84         ah/transport/10.40.0.9-10.40.0.13/use
    85         esp/transport/10.40.0.9-10.40.0.13/use
    86         created: Apr 20 18:10:44 2007  lastused: Apr 20 18:10:44 2007
    87         lifetime: 0(s) validtime: 0(s)
    88         spid=16392 seq=0 pid=7761
    89         refcnt=1
    90 }}}
    91    * Pour automatiser cette procédure au démarrage de la machine, éditez dans /etc/rc.conf en ajoutant :
    92 {{{
    93 ipsec_enable="YES"
    94 ipsec_file="/etc/ipsec.conf"
    95 }}}
    96    * '''Votre démon IPSec sera actif avec les bons paramètres dès le prochain démarrage'''
    97 [[BR]]
    98 
    99 === Configurer Racoon ===
    100 [[BR]]
    101 
    102    * Créer psk.txt initiant l'échange de clé partagé
    103 {{{
    104 $ cat > psk.txt << EOF
    105 10.40.0.9       mot_de_passe_t3$T
    106 EOF
    107 }}}
    108 L'adresse IP est celle de la cible (ici Serveur1), suivi du mot de passe.
    109    * Créer racoon.conf. Vous pouvez vous inspirer de l'exemple fourni par défaut avec Racoon, ou bien utiliser (en le modifiant) celui-ci:
    110 {{{
    111 $ cat > racoon.conf << EOF
    112 #  $File: /home/chris/PRes/Postes_Rackables/ipsec_client1/racoon.conf $
    113 #  $MD5: 2922df40b60a8f1eb7116f90a485f84a $
    114 #  $By Christophe Alladoum <christophe[dot]alladoum[at]gmail[dot]com>$
    115 #  $Last-Modified: Fri Apr 20 18:28:11 2007$
    116 
    117 #
    118 # Configuration de RACOON cote client
    119 #
    120 
    121 path include "/chemin/absolu/vers/ce/repertoire" ;
    122 
    123 path pre_shared_key "/chemin/absolu/vers/psk.txt" ;
    124 # path pre_shared_key "/root/ipsec_client1/psk.txt" ;
    125 # path certificate "/usr/local/etc/cert" ;
    126 
    127 # "log" indique le niveau de debug
    128 # choix : notify, debug, debug2
    129 # log debug;
    130 
    131 padding
    132 {
    133         maximum_length 20;      # maximum padding length.
    134         randomize off;          # enable randomize length.
    135         strict_check off;       # enable strict check.
    136         exclusive_tail off;     # extract last one octet.
    137 }
    138 
    139 # Interfaces a ecouter (IPv4 et/ou v6)
    140 # Si aucune, ecoute sur toutes les interfaces de la machine
    141 listen
    142 {
    143         # pour le client IPv4
    144         isakmp 10.40.0.13 [500];
    145         # pour le client IPv6
    146         # isakmp ::1 [7000];
    147 }
    148 
    149 # Temporisateurs d echange de cle
    150 timer
    151 {
    152         counter 5;              # maximum trying count to send.
    153         interval 20 sec;        # maximum interval to resend.
    154         persend 1;              # the number of packets per a send.
    155 
    156         # Temps max. pour chaque phase
    157         phase1 2 min;
    158         phase2 4 min;
    159 }
    160 
    161 # Cas du client1
    162 remote 10.40.0.9
    163 {
    164         exchange_mode aggressive,main;
    165         doi ipsec_doi;
    166         situation identity_only;
    167 
    168         nonce_size 16;
    169         lifetime time 60 min;   # sec,min,hour
    170         initial_contact on;
    171         support_proxy on;
    172         proposal_check obey;    # obey, strict or claim
    173 
    174         proposal {
    175                 encryption_algorithm blowfish;
    176                 hash_algorithm sha1;
    177                 authentication_method pre_shared_key ;
    178                 dh_group 5 ;
    179         }
    180 }
    181 
    182 # Cas du client1
    183 sainfo anonymous
    184 {
    185         pfs_group 5;
    186         lifetime time 48 hour;
    187         encryption_algorithm 3des, cast128, blowfish 448, des;
    188         authentication_algorithm hmac_md5, hmac_sha1;
    189         compression_algorithm deflate ;
    190 }
    191 EOF
    192 }}}
    193    * A présent, lancez:
    194 {{{
    195 $ /usr/local/sbin/racoon -l /var/log/racoon.log -f /chemin/vers/racoon.conf
    196 }}}
    197 Un fichier de log (utile pour le debug) sera crée à l'adresse /var/log/racoon.log
    198    * ''' Votre Racoon est lancé  !! '''
    199 === Vérifier le fonctionnement ===
    200 Via le monitoring, vous devriez observer des échanges similaires aux suivants.
    201 {{{
    202 Capturing on dc3
    203 [...]
    204 Echange de cle avec ISAKMP
    205 904.714799    10.40.0.9 -> 10.40.0.13   ISAKMP Aggressive
    206 904.715327    10.40.0.9 -> 10.40.0.13   ISAKMP Aggressive
    207 904.715883    10.40.0.9 -> 10.40.0.13   ISAKMP Aggressive
    208 [...]
    209 Communication Securisee via IPSec/ESP
    210 1 0.000000 10.40.0.9  10.40.0.13 ESP ESP (SPI=0x000007d1)
    211 2 0.000588 10.40.0.9  10.40.0.13 ESP ESP (SPI=0x000007d1)
    212 3 0.000711 10.40.0.13 10.40.0.9  TCP 61738 > 10987 [ACK] Seq=0 Ack=0 Win=17879 Len=1424 TSV=2005181 TSER=751670683
    213 4 0.001238 10.40.0.13 10.40.0.9  TCP [TCP Out-Of-Order] 61738 > 10987 [ACK] Seq=0 Ack=0 Win=17879 Len=1424 TSV=2005181 TSER=751670683
    214 5 0.001792 10.40.0.13 10.40.0.9  TCP [TCP Out-Of-Order] 61738 > 10987 [ACK] Seq=0 Ack=0 Win=17879 Len=1424 TSV=2005181 TSER=751670683
    215 6 0.002747 10.40.0.13 10.40.0.9  TCP 61738 > 10987 [ACK] Seq=1424 Ack=1399 Win=17691 Len=1424 TSV=2005183 TSER=751670687
    216 7 0.002864 10.40.0.9  10.40.0.13 ESP ESP (SPI=0x000007d1)
    217 8 0.003315 10.40.0.13 10.40.0.9  TCP [TCP Out-Of-Order] 61738 > 10987 [ACK] Seq=1424 Ack=1399 Win=17691 Len=1424 TSV=2005183 TSER=751670687
    218 
    219 Authentication Header
    220 
    221 Data (1424 bytes)
    222 
    223 0000  01 56 07 d2 b2 50 99 a6 fc 4c 1d bb 2a 88 d9 09   .V...P...L..*...
    224 0010  e5 05 ad fa c1 4b 62 a5 7b c6 dd d2 ee 4e d7 c7   .....Kb.{....N..
    225 0020  a8 95 6b da b3 ec 28 5c f4 5a 99 08 0a dd 39 20   ..k...(\.Z....9
    226 0030  c0 ef 9c 7c 6b dc 66 e1 b0 c0 a5 bb 9f bc 4e 99   ...|k.f.......N.
    227 0040  bc f3 38 70 d4 8f 1c f8 fe 8d 4c 8a 94 97 b4 b6   ..8p......L.....
    228 0050  12 1f a1 1b 57 ac 28 97 1a 67 0e e7 aa b8 3a 1b   ....W.(..g....:.
    229 0060  4e 8b 19 6c 80 48 77 aa 80 c5 05 46 74 37 2d 5a   N..l.Hw....Ft7-Z
    230 0070  b3 94 73 9a 13 b7 bf 81 65 11 d8 16 e8 88 e2 5f   ..s.....e......_
    231 0080  6f dc c6 7d fc a7 77 e7 f4 39 12 b3 e9 17 52 b6   o..}..w..9....R.
    232 [...]
    233 }}}
    234 [[BR]]
    235 Vous pouvez télécharger un exemple de trames échangées entre les stations [wiki:Entreprise2Client1 CLIENT1.ENT2] et [wiki:Entreprise2Serveur1 SERVEUR1.ENT2] via ce
    236 [http://projet.reseau.free.fr/data/AS65004/trace_ipsec lien]. A noter que la trace pèse env. 14Mo (10 000 paquets capturés).
    237 Pour voir les échanges, vous devrez ouvrir cette trace avec un outil, comme Wireshark.
    238 ----
    239 Pour plus d'infos, se référer aux '''man de Setkey , Racoon  , IPSec'''
    240 [[BR]]
    241 Références:
    242    * http://www.onlamp.com/pub/a/bsd/2001/12/10/ipsec.html
    243    * http://www.onlamp.com/pub/a/bsd/2002/12/26/FreeBSD_Basics.html
    244 ----
    24519
    24620   * ''' Annexes:'''