ospfroutingcisco
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 2328Mtrique cost rfrence 100 Mbps par dfaut configurablecost reference-bandwidth interface-bandwidthGi cost 1 Fa cost 10 Serial cost 64 avec refModifier reference-bandwidth si liens > 100 MbpsTypes de LSA Link State AdvertisementLSA 1 Router LSA liens de chaque routeur dans lareaLSA 2 Network LSA gnr par le DR sur les rseaux multi-accèsLSA 3 Summary LSA inter-area gnr par ABRLSA 4 ASBR Summary LSA localise lASBRLSA 5 AS External LSA routes redistribues ASBRLSA 7 NSSA External LSA routes redistribues dans une NSSATypes dareasBackbone Area 0 obligatoire toutes les autres areas sy connectentStandard reoit tous les types de LSAStub pas de LSA 5 route par dfaut injecte par ABRTotally Stub pas de LSA 3/4/5 uniquement route par dfaut CiscoNSSA pas de LSA 5 mais accepte LSA 7 redistribution localeTotally NSSA pas de LSA 3/4/5/7 sauf route dfaut CiscoDR/BDR sur rseaux multi-accès broadcastDR Designated Router synchronise la LSDB pour le segmentBDR Backup DR prend le relais si DR tombelection 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 manuellementrouter ospf 1router-id {{ROUTER_ID}} ! ex: 1.1.1.1 (loopback0 ou arbitraire)! reference-bandwidth en Mbps — adapter si liens > 100Mauto-cost reference-bandwidth 10000 ! 10 Gbps comme référence! Méthode 1 : network statement (avec wildcard mask)network {{LAN_SUBNET}} {{WILDCARD}} area 0network {{LOOPBACK_IP}} 0.0.0.0 area 0! Interfaces passives (ne pas envoyer de Hello — serveurs, clients)passive-interface GigabitEthernet0/1passive-interface default ! toutes passives par défautno 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'interfaceinterface GigabitEthernet0/0ip ospf 1 area 0ip ospf cost 10 ! forcer le cost si besoinip ospf priority 255 ! favoriser ce routeur comme DRip ospf hello-interval 10 ! défaut = 10s (broadcast), 30s (serial)ip ospf dead-interval 40 ! défaut = 4× hellono shutdowninterface Loopback0ip address {{LOOPBACK_IP}} 255.255.255.255ip ospf 1 area 0
Timers Hello/Dead
text
conf tinterface GigabitEthernet0/0! Les timers doivent être identiques entre voisins !ip ospf hello-interval 5ip ospf dead-interval 20! Fast Hello (sub-second) — convergence ultra-rapideip 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 trouter ospf 1router-id {{ABR_ROUTER_ID}}auto-cost reference-bandwidth 10000! Interfaces dans area 0 (backbone)network {{BACKBONE_NET}} {{WILDCARD}} area 0! Interfaces dans area 1network {{AREA1_NET}} {{WILDCARD}} area 1! Interfaces dans area 2 (stub)network {{AREA2_NET}} {{WILDCARD}} area 2area 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 trouter ospf 1area 3 nssa ! NSSA — permet redistribution locale! area 3 nssa no-summary ! totally NSSAarea 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/2ip ospf priority 0! Priorité 255 = toujours DR (si priorité identique → Router-ID décide)interface GigabitEthernet0/1ip ospf priority 255! Forcer la ré-élection DR/BDR (clear les voisinages OSPF)clear ip ospf process
Redistribution
text
conf trouter ospf 1! Redistribuer les routes connectéesredistribute connected subnets! Redistribuer les routes statiquesredistribute 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 OSPFredistribute ospf 2 subnets! Injecter une route par défaut (si ce routeur a accès Internet)default-information originate ! seulement si route défaut existedefault-information originate always ! forcer même sans route défaut locale
Filtrage de routes
text
Variables
{{MGMT_SUBNET}}
{{MGMT_PREFIX}}
conf t! Prefix-listip 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 1distribute-list prefix DENY_MGMT in GigabitEthernet0/1! Filtrage inter-area avec prefix-list (sur ABR)router ospf 1area 1 filter-list prefix DENY_MGMT in ! filtre LSA 3 entrant dans area 1area 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 arearouter ospf 1area 0 authentication message-digest! Clé sur chaque interfaceinterface GigabitEthernet0/0ip ospf authentication message-digestip ospf message-digest-key 1 md5 {{OSPF_MD5_KEY}}
OSPFv3 (IPv6)
text
Variables
{{ROUTER_ID}}
{{IPV6_ADDR}}
{{PREFIX}}
conf tipv6 unicast-routingipv6 router ospf 1router-id {{ROUTER_ID}}interface GigabitEthernet0/0ipv6 address {{IPV6_ADDR}}/{{PREFIX}}ipv6 ospf 1 area 0no shutdown! Vérificationshow ipv6 ospf neighborshow ipv6 ospf databaseshow ipv6 route ospf
Vérifications
text
! Voisins OSPFshow ip ospf neighborshow ip ospf neighbor detail! Base de données LSDBshow ip ospf databaseshow ip ospf database routershow ip ospf database networkshow ip ospf database summary! Routes OSPF dans la table de routageshow ip route ospfshow ip route ospf | include O! Interfaces OSPFshow ip ospf interfaceshow ip ospf interface briefshow ip ospf interface GigabitEthernet0/0! Statistiques et informations généralesshow ip ospfshow ip ospf statistics! Processus en coursshow 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 eventsundebug all ! arrêter tous les debugs! Vérifier les paquets OSPF sur une interfacedebug ip ospf hello
Corriger un problème MTU
text
conf tinterface GigabitEthernet0/0ip 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