MDstable
NoteSnippetChecklistPlaybook

OSPF — Configuration et Troubleshooting

Configurer OSPF single-area et multi-area, LSA types, redistribution

snippetadvanced 2025-05-14 7 min read
ospfroutingciscoarealsaredistributionospfv3igp

Concepts fondamentaux

OSPF Open Shortest Path First protocole IGP link-state RFC 2328
Mtrique cost rfrence 100 Mbps par dfaut configurable
cost reference-bandwidth interface-bandwidth
Gi cost 1 Fa cost 10 Serial cost 64 avec ref
Modifier reference-bandwidth si liens > 100 Mbps
Types de LSA Link State Advertisement
LSA 1 Router LSA liens de chaque routeur dans larea
LSA 2 Network LSA gnr par le DR sur les rseaux multi-accès
LSA 3 Summary LSA inter-area gnr par ABR
LSA 4 ASBR Summary LSA localise lASBR
LSA 5 AS External LSA routes redistribues ASBR
LSA 7 NSSA External LSA routes redistribues dans une NSSA
Types dareas
Backbone Area 0 obligatoire toutes les autres areas sy connectent
Standard reoit tous les types de LSA
Stub pas de LSA 5 route par dfaut injecte par ABR
Totally Stub pas de LSA 3/4/5 uniquement route par dfaut Cisco
NSSA pas de LSA 5 mais accepte LSA 7 redistribution locale
Totally NSSA pas de LSA 3/4/5/7 sauf route dfaut Cisco
DR/BDR sur rseaux multi-accès broadcast
DR Designated Router synchronise la LSDB pour le segment
BDR Backup DR prend le relais si DR tombe
lection base sur priorit OSPF dfaut 1 puis Router-ID plus lev gagne

OSPF Single-Area

Configuration de base

text
Variables
{{ROUTER_ID}}
{{LAN_SUBNET}}
{{WILDCARD}}
{{LOOPBACK_IP}}
conf t
! Bonne pratique : toujours configurer le router-id manuellement
router ospf 1
router-id {{ROUTER_ID}} ! ex: 1.1.1.1 (loopback0 ou arbitraire)
! reference-bandwidth en Mbps — adapter si liens > 100M
auto-cost reference-bandwidth 10000 ! 10 Gbps comme référence
! Méthode 1 : network statement (avec wildcard mask)
network {{LAN_SUBNET}} {{WILDCARD}} area 0
network {{LOOPBACK_IP}} 0.0.0.0 area 0
! Interfaces passives (ne pas envoyer de Hello — serveurs, clients)
passive-interface GigabitEthernet0/1
passive-interface default ! toutes passives par défaut
no passive-interface GigabitEthernet0/0 ! activer OSPF seulement sur les liens P2P

Méthode interface (plus propre)

text
Variables
{{LOOPBACK_IP}}
conf t
! Méthode 2 : activer OSPF directement sur l'interface
interface GigabitEthernet0/0
ip ospf 1 area 0
ip ospf cost 10 ! forcer le cost si besoin
ip ospf priority 255 ! favoriser ce routeur comme DR
ip ospf hello-interval 10 ! défaut = 10s (broadcast), 30s (serial)
ip ospf dead-interval 40 ! défaut = 4× hello
no shutdown
interface Loopback0
ip address {{LOOPBACK_IP}} 255.255.255.255
ip ospf 1 area 0

Timers Hello/Dead

text
conf t
interface GigabitEthernet0/0
! Les timers doivent être identiques entre voisins !
ip ospf hello-interval 5
ip ospf dead-interval 20
! Fast Hello (sub-second) — convergence ultra-rapide
ip ospf dead-interval minimal hello-multiplier 5 ! Dead = 1s, Hello = 200ms

OSPF Multi-Area

ABR (Area Border Router)

text
Variables
{{ABR_ROUTER_ID}}
{{BACKBONE_NET}}
{{WILDCARD}}
{{AREA1_NET}}
{{AREA2_NET}}
{{SUMMARY_NET}}
{{SUMMARY_MASK}}
conf t
router ospf 1
router-id {{ABR_ROUTER_ID}}
auto-cost reference-bandwidth 10000
! Interfaces dans area 0 (backbone)
network {{BACKBONE_NET}} {{WILDCARD}} area 0
! Interfaces dans area 1
network {{AREA1_NET}} {{WILDCARD}} area 1
! Interfaces dans area 2 (stub)
network {{AREA2_NET}} {{WILDCARD}} area 2
area 2 stub ! définir area 2 comme stub
! area 2 stub no-summary ! totally stub (Cisco)
! Résumer les routes inter-area (sur ABR)
area 1 range {{SUMMARY_NET}} {{SUMMARY_MASK}} ! agrège les LSA 3 vers area 0

NSSA

text
conf t
router ospf 1
area 3 nssa ! NSSA — permet redistribution locale
! area 3 nssa no-summary ! totally NSSA
area 3 nssa default-information-originate ! injecter route défaut dans NSSA

DR/BDR — Forcer l'élection

text
conf t
! Priorité 0 = jamais DR ni BDR (DROTHER permanent)
interface GigabitEthernet0/2
ip ospf priority 0
! Priorité 255 = toujours DR (si priorité identique → Router-ID décide)
interface GigabitEthernet0/1
ip ospf priority 255
! Forcer la ré-élection DR/BDR (clear les voisinages OSPF)
clear ip ospf process

Redistribution

text
conf t
router ospf 1
! Redistribuer les routes connectées
redistribute connected subnets
! Redistribuer les routes statiques
redistribute static subnets metric 20 metric-type 2
! Redistribuer depuis BGP (ASBR)
redistribute bgp 65000 subnets metric 100 metric-type 2
! Redistribuer depuis une autre instance OSPF
redistribute ospf 2 subnets
! Injecter une route par défaut (si ce routeur a accès Internet)
default-information originate ! seulement si route défaut existe
default-information originate always ! forcer même sans route défaut locale

Filtrage de routes

text
Variables
{{MGMT_SUBNET}}
{{MGMT_PREFIX}}
conf t
! Prefix-list
ip prefix-list DENY_MGMT seq 5 deny {{MGMT_SUBNET}}/{{MGMT_PREFIX}}
ip prefix-list DENY_MGMT seq 10 permit 0.0.0.0/0 le 32
! Distribute-list sur les routes reçues (inbound)
router ospf 1
distribute-list prefix DENY_MGMT in GigabitEthernet0/1
! Filtrage inter-area avec prefix-list (sur ABR)
router ospf 1
area 1 filter-list prefix DENY_MGMT in ! filtre LSA 3 entrant dans area 1
area 1 filter-list prefix DENY_MGMT out ! filtre LSA 3 sortant de area 1

Authentification MD5

text
Variables
{{OSPF_MD5_KEY}}
conf t
! Authentification par area
router ospf 1
area 0 authentication message-digest
! Clé sur chaque interface
interface GigabitEthernet0/0
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 {{OSPF_MD5_KEY}}

OSPFv3 (IPv6)

text
Variables
{{ROUTER_ID}}
{{IPV6_ADDR}}
{{PREFIX}}
conf t
ipv6 unicast-routing
ipv6 router ospf 1
router-id {{ROUTER_ID}}
interface GigabitEthernet0/0
ipv6 address {{IPV6_ADDR}}/{{PREFIX}}
ipv6 ospf 1 area 0
no shutdown
! Vérification
show ipv6 ospf neighbor
show ipv6 ospf database
show ipv6 route ospf

Vérifications

text
! Voisins OSPF
show ip ospf neighbor
show ip ospf neighbor detail
! Base de données LSDB
show ip ospf database
show ip ospf database router
show ip ospf database network
show ip ospf database summary
! Routes OSPF dans la table de routage
show ip route ospf
show ip route ospf | include O
! Interfaces OSPF
show ip ospf interface
show ip ospf interface brief
show ip ospf interface GigabitEthernet0/0
! Statistiques et informations générales
show ip ospf
show ip ospf statistics
! Processus en cours
show ip protocols

Troubleshooting — Voisins qui ne montent pas

text
! Causes fréquentes :
! 1. Area mismatch → show ip ospf interface
! 2. Hello/Dead timer → show ip ospf interface (comparer les deux côtés)
! 3. MTU mismatch → ip ospf mtu-ignore sur l'interface (ou corriger le MTU)
! 4. Authentication → show ip ospf interface | include auth
! 5. Subnet mismatch → vérifier ip address + masque identiques /30 ou /31
! 6. Network type mismatch → point-to-point vs broadcast
! 7. ACL bloquant le port 89 → show ip access-lists
! 8. Passive interface → show ip ospf interface
! Debug (lab uniquement — très verbeux en prod)
debug ip ospf adj ! adjacences (hello, exchange, loading)
debug ip ospf events ! tous les events
undebug all ! arrêter tous les debugs
! Vérifier les paquets OSPF sur une interface
debug ip ospf hello

Corriger un problème MTU

text
conf t
interface GigabitEthernet0/0
ip mtu 1500
! Ou ignorer le MTU dans OSPF (workaround)
ip ospf mtu-ignore
💡 Tip —

Toujours configurer un router-id manuellement avec une adresse loopback stable (ex: 1.1.1.1). Si aucun router-id n'est configuré, OSPF en choisit un automatiquement parmi les IPs d'interface — si cette interface tombe, OSPF redémarre le processus et force une re-convergence complète. Une loopback ne tombe jamais tant que le routeur est up.

OPS·BRAIN v1.027 notes · Networklocal