📋 IKEv2 Policy — Cisco IOS

Sélection du proposal · Match FVRF · Match adresse locale · ENARSI

C'est quoi une IKEv2 Policy ?

Rôle

La policy fait le lien entre le contexte réseau (adresse locale, VRF) et le proposal à utiliser. Elle est consultée avant l'envoi du IKE_SA_INIT — Cisco sélectionne la policy qui matche, puis envoie ses proposals dans le MSG 1.

Position dans la chaîne IKEv2

ObjetRôleLié à
ProposalDéfinit les algos (encryption, integrity, DH…)Référencé dans Policy
PolicyChoisit le(s) proposal(s) selon le contexte réseauRéférence Proposal(s)
ProfileGère l'identité et l'authentification (PSK/cert)Indépendant de Policy
1
IPsec déclenche IKEv2
L'interface tunnel (tunnel source, tunnel fvrf) fournit : adresse locale + FVRF
2
Cisco cherche une Policy
IKEv2:Searching Policy with fvrf 0, local address 192.168.1.1
3
Policy trouvée → Proposals extraits
Les proposals sont mis dans le payload SA du IKE_SA_INIT (MSG 1 — en clair)
4
Aucune Policy → Erreur
IKEv2-ERROR: Failed to initiate sa — tunnel reste DOWN
Policy default : matche tout (any FVRF, any IP). Active uniquement si aucune policy user-defined n'est configurée.
⚠️ Piège : dès que tu crées UNE policy user-defined, la default ne s'applique plus — même si ton contexte ne la matche pas. Résultat : tunnel DOWN.
Créer et configurer une IKEv2 Policy
! ── Créer la policy ─────────────────────────────────────────
Router(config)#crypto ikev2 policy ikev2_policy
IKEv2 policy MUST have at least one complete proposal attached
Router(config-ikev2-policy)#

! ── Commandes disponibles ────────────────────────────────────
Router(config-ikev2-policy)#?
  exit      Exit from IKEv2 policy configuration mode
  match     Match values of local fields
  no        Negate a command or set its defaults
  proposal  Specify Proposal
! ── Attacher un proposal (doit être complet et existant) ─────
Router(config-ikev2-policy)#proposal PROP-IKEv2

! ── Erreur : proposal inexistant ────────────────────────────
Router(config-ikev2-policy)#proposal PROP-INEXISTANT
% No Proposal exists with the specified name PROP-INEXISTANT

! ── Erreur : proposal incomplet ─────────────────────────────
Router(config-ikev2-policy)#proposal PROP-INCOMPLET
Proposal PROP-INCOMPLET is not complete to be attached to policy
! ── Config minimale complète ─────────────────────────────────
crypto ikev2 proposal PROP-IKEv2
 encryption aes-cbc-256
 integrity  sha256
 group      14
!
crypto ikev2 policy POL-IKEv2
 proposal PROP-IKEv2       ← sans match = global VRF, toutes IPs
Match Statements — Logique OR / AND
match address local
match fvrf
Qu'est-ce que c'est ?L'IP source des paquets IKEv2 = tunnel source = adresse WAN
Qu'est-ce que c'est ?Le VRF de l'interface WAN par laquelle entrent/sortent les paquets IKEv2
Plusieurs valeurs → ORmatch local 192.168.1.1
match local 192.168.2.1
→ l'une OU l'autre suffit
Plusieurs valeurs → ORmatch fvrf mpls
match fvrf internet
→ l'un OU l'autre suffit
Types différents → ANDaddress local ET fvrf doivent tous deux matcher simultanément
Sans matchLa policy s'applique à toutes les IPs en Global VRF
! ── Exemple : (mpls OR internet) AND (192.168.1.1 OR 2001::1) ──
Router(config-ikev2-policy)#match fvrf mpls
Router(config-ikev2-policy)#match fvrf internet
Router(config-ikev2-policy)#match address local 192.168.1.1
Router(config-ikev2-policy)#match address local 2001::1
! ── Per-peer policy : adresses locales différentes ──────────
crypto ikev2 policy Policy1
 match address local 192.168.1.1  ← Peer1 : tunnel dest 192.168.1.1
 proposal Proposal1              ← AES-GCM-128, DH19 (NGE)
!
crypto ikev2 policy Policy2
 match address local 192.168.2.1  ← Peer2 : tunnel dest 192.168.2.1
 proposal Proposal2              ← AES-CBC-128, DH14
💡 IKEv2 policy ne peut pas matcher sur l'adresse distante. Pour des algos différents par peer → utiliser des adresses locales différentes.
! ── Policy avec deux proposals (GCM + CBC) ───────────────────
crypto ikev2 policy default
 proposal Proposal1    ← AES-GCM-128, DH19 (préféré)
 proposal Proposal2    ← AES-CBC-128, DH14 (fallback)
! Les deux partent dans le SA payload du IKE_SA_INIT (MSG 1)
! DH pré-calculé sur Proposal1 (le préféré de l'initiateur)
Show & Debug
show crypto ikev2 policy
Router#show crypto ikev2 policy

IKEv2 policy : default
  Match fvrf          : any
  Match address local : any
  Proposal            : default

IKEv2 policy : POL-IKEv2
  Match fvrf          : global
  Match address local : 192.168.1.1
  Proposal            : PROP-IKEv2
show crypto ikev2 policy <name>
Router#show crypto ikev2 policy ikev2_policy

IKEv2 policy : ikev2_policy
  Match fvrf          : mpls
  Match fvrf          : internet
  Match address local : 192.168.1.1
  Match address local : 2001::1
  Proposal            : ikev2_proposal1
  Proposal            : ikev2_proposal2
show run — policy complète
Router#show run | begin ikev2 policy
crypto ikev2 policy POL-IKEv2
 match fvrf mpls
 match address local 192.168.1.1
 proposal PROP-IKEv2
show run — policy incomplète
Router#show run | begin ikev2 policy
crypto ikev2 policy POL-VIDE
 ! Policy Incomplete
 ! (MUST have at least one
 !  complete proposal attached)
🔍 Debug — Sélection de policy en temps réel
Router#terminal monitor
Router#debug crypto ikev2 error

! ── Policy trouvée (initiateur) ──────────────────────────────
IKEv2:Searching Policy with fvrf 0, local address 192.168.1.1
IKEv2:Found Policy 'default'
IKEv2:(SESSION ID = 3,SA ID = 1):Generating IKE_SA_INIT message

! ── Aucune policy (initiateur) ───────────────────────────────
IKEv2:Searching Policy with fvrf 0, local address 192.168.1.1
IKEv2-ERROR:Failed to initiate sa

! ── Aucune policy (répondeur — après IKE_SA_INIT reçu) ───────
IKEv2:Searching Policy with fvrf 0, local address 192.168.1.2
IKEv2-ERROR:(SESSION ID = 851):Failed to locate an item in the database
IKEv2:(SESSION ID = 851):Failed SA init exchange
IKEv2:(SESSION ID = 851):Abort exchange
IKEv2:(SESSION ID = 851):Deleting SA
Default policy — désactiver / restaurer
! Désactiver
Router(config)#no crypto ikev2 policy default

Router#show crypto ikev2 policy default
IKEv2 policy : default Disabled

! Restaurer
Router(config)#default crypto ikev2 policy
Modifier la default policy
! Supprimer "any" avant fvrf spécifique
Router(config-ikev2-policy)#match fvrf mpls
% Specific vrf cannot be configured
  when fvrf type any is already set.

Router(config-ikev2-policy)#no match fvrf any
Router(config-ikev2-policy)#match fvrf mpls ← OK
Règles & Pièges ENARSI
1
Au moins un proposal complet obligatoire
Sans proposal attaché → policy Incomplete, ignorée. Le proposal doit exister ET être complet au moment de l'attacher.
2
La default policy disparaît dès qu'une user-defined policy existe
Même si ton contexte ne matche aucune policy configurée, la default ne prend PAS le relais → Failed to initiate sa. Piège classique exam.
3
Match : même type = OR, types différents = AND
Deux match fvrf = OR. Un match fvrf + un match address local = les deux doivent être vrais simultanément.
4
Pas de match sur l'adresse distante (remote IP)
Pour des algos différents par peer → utiliser des adresses locales différentes + une policy par adresse.
5
Overlapping policies : la plus spécifique gagne
Déconseillé, mais si deux policies matchent, Cisco prend la meilleure correspondance.
6
Modifier la default policy : retirer "any" d'abord
Si match fvrf any est présent, ajouter un fvrf spécifique provoque une erreur. Faire no match fvrf any en premier.
7
Plusieurs proposals → tous envoyés dans IKE_SA_INIT
DH pré-calculé sur le premier proposal. Si le répondeur choisit le second avec un DH différent → nouvel échange DH.
8
Policy ≠ Profile
Policy = algos Phase 1 (IKE SA). Profile = identité + authentification (PSK, certs, DPD). Indépendants.
💡 Lab Insight — EVE-NG EDG Router
Q : Si un routeur Cisco n'a pas de crypto ikev2 policy configurée explicitement, que se passe-t-il ?
R : Cisco utilise automatiquement la default policy, qui pointe sur le default proposal. Si le default proposal contient les algorithmes compatibles avec le peer distant, la négociation IKEv2 fonctionne sans aucune configuration explicite de policy.
C'est exactement le cas du routeur EDG en lab EVE-NG : aucune crypto ikev2 policy n'est configurée, mais le tunnel négocie correctement parce que le default proposal inclut AES-CBC-128 + SHA256 + DH Group 2 — qui correspondent aux algorithmes configurés côté Palo Alto.
! EDG — show crypto ikev2 proposal
IKEv2 proposal: Prop-Ikev2       ← configuré mais jamais utilisé (pas de policy)
  Encryption : AES-CBC-128
  Integrity  : SHA256
  PRF        : SHA256
  DH Group   : DH_GROUP_1024_MODP/Group 2

IKEv2 proposal: default          ← celui qui est réellement utilisé via la default policy
  Encryption : AES-CBC-256 AES-CBC-192 AES-CBC-128
  Integrity  : SHA512 SHA384 SHA256 SHA96 MD596
  PRF        : SHA512 SHA384 SHA256 SHA1 MD5
  DH Group   : DH_GROUP_1536_MODP/Group 5 DH_GROUP_1024_MODP/Group 2
⚠️ Corollaire : le proposal Prop-Ikev2 est présent dans la running-config mais n'est jamais utilisé — aucune policy ne le référence. Pour l'activer : crypto ikev2 policy POL-EDG → proposal Prop-Ikev2.