Skip to content

#36 — Configuration OSPF Dynamique

PLANIFIÉ

Priorité: 🔵 MOYENNE · Type: TYPE F · Conteneur: rgz-ospf (V2 Q3-2026) · Code: config/ospf/Dépendances: #7 rgz-gateway


Description

Routage OSPF dynamique inter-sites pour découverte automatique de topologie réseau et équilibrage de charge. NON DÉPLOYÉ EN V1. Prévu pour V2 (Q3 2026) après stabilisation stack core. Actuellement, les routes inter-sites sont statiques via #35 WireGuard et routes manuelles dans les tables de routage des gateways.

L'architecture OSPF sera basée sur FRRouting (suite de protocoles de routage pour Linux). Chaque gateway revendeur exécutera un daemon OSPF qui annoncera ses subnets VLAN (10.100-499.0.0/24) et découvrira automatiquement les autres sites. Le NOC central agira en tant que routeur de bordure (ASBR - Autonomous System Border Router) pour contrôler la redistribution de routes.

Les avantages: convergence automatique en cas de défaillance lien inter-site, optimisation chemins, scaling à +100 sites sans gestion manuelle des routes, support du multicast natif OSPF. Les inconvénients : complexité opérationnelle accrue, nécessité d'un NOC hautement disponible (réplica OSPF), CPU supplémentaire sur CPE/gateway.

Cette implémentation est documentée à titre de référence pour V2. Le déploiement V1 utilise des routes statiques et WireGuard uniquement.

Architecture Interne (V2 Q3-2026)

1. Topologie OSPF:

   Area 0.0.0.0 (backbone):
   └─ NOC: ASBR + DR (Designated Router)
      ├─ OSPF IP: 172.16.0.1 (management network)
      ├─ Annonce routes: 10.0.0.0/24 (core services)
      └─ RID: 1.1.1.1

   Area 0.0.0.1 (sites revendeurs):
   └─ Site A: ABR (Area Border Router)
      ├─ OSPF IP: 172.16.1.2 (point-to-point WireGuard)
      ├─ Annonce route: 10.150.0.0/24 (VLAN Site A)
      └─ RID: 2.2.2.2

   └─ Site B: ABR
      ├─ OSPF IP: 172.16.1.3
      ├─ Annonce route: 10.160.0.0/24
      └─ RID: 3.3.3.3

2. Adjacencies OSPF (via WireGuard tunnel):
   └─> NOC (1.1.1.1, cost 1) ↔ Site A (2.2.2.2, cost 10)
   └─> NOC (1.1.1.1, cost 1) ↔ Site B (3.3.3.3, cost 10)
   └─> Site A ↔ Site B (cost = 20, VIA NOC)

3. Redistribution statique:
   └─> NOC redistribue routes manuelles (legacy) en OSPF
   └─> Sites reçoivent routes via OSPF, ignorent routes statiques

4. Convergence:
   └─> Hello interval: 10s (LAN) / 40s (WireGuard)
   └─> Dead interval: 40s / 160s
   └─> SPF run: <5s (détection défaillance)
   └─> Reconvergence: ~10s (détection + SPF + route install)

5. Monitoring OSPF:
   └─> Prometheus: instance per router → scrappe port 9184 (FRRouting exporter)
   └─> Métriques: adjacencies, routes, LSA count, SPF runs
   └─> Alertes: no-adjacency avec ABR, unknown-routes, high-SPF-runs

6. FRRouting daemon (daemons actuels):
   └─> zebra: kernel routing
   └─> ospfd: OSPF protocol
   └─> bgpd: BGP (future pour scaling +1000 sites)
   └─> ripd: RIP (legacy, deprecated)

Configuration

Variables d'environnement (V2)

env
# OSPF core
OSPF_ROUTER_ID=1.1.1.1                # Unique per router
OSPF_AREA_ID=0.0.0.0                  # Backbone area
OSPF_AREA_TYPE=backbone               # backbone ou normal
OSPF_HELLO_INTERVAL=10                # secondes (LAN), 40 (WireGuard)
OSPF_DEAD_INTERVAL=40                 # 4x hello
OSPF_REDISTRIBUTE_STATIC=true         # Import routes statiques
OSPF_DEFAULT_METRIC=100               # Pour routes redistributed

# Infrastructure
FRROUTING_VERSION=9.0                 # FRRouting latest stable
FRROUTING_EXPORTER_PORT=9184          # Prometheus
FRROUTING_CONFIG=/etc/frr/frr.conf
FRROUTING_DAEMONS=zebra,ospfd

# Sécurité
OSPF_AUTH_TYPE=md5                    # Authentification LSA
OSPF_AUTH_KEY=shared_ospf_key_...     # HMAC-MD5 (env var)

# Monitoring
OSPF_METRIC_PREFIX=rgz.ospf           # Prometheus metrics namespace

FRRouting Config (V2 exemple)

conf
# /etc/frr/frr.conf (NOC - ASBR)

!
! FRRouting OSPF configuration
!

hostname rgz-noc-ospf
!

router ospf
 ospf router-id 1.1.1.1
 passive-interface default  # Don't send hello on unneeded interfaces
 no passive-interface wg0   # Enable OSPF on WireGuard tunnel

 area 0.0.0.0 authentication message-digest  # MD5 auth

 # Network declarations (interfaces)
 network 172.16.0.0/24 area 0.0.0.0  # Management network
 network 10.0.0.0/24 area 0.0.0.0    # Core services

 # Timers
 timers spf delay 100 initial-holdoff 100 max-holdoff 5000
 timers throttle spf 100 100 5000

 # Redistribute static routes (legacy)
 redistribute static metric-type 2
 default-metric 100

 # LSA flooding (optional)
 max-metric router-lsa on-shutdown

 # Cost/metric per interface
 interface wg0
  ip ospf cost 10
  ip ospf hello-interval 40  # Longer on wireless
  ip ospf dead-interval 160
  ip ospf authentication message-digest
  ip ospf message-digest-key 1 md5 [OSPF_AUTH_KEY]
!

line vty
 exec-timeout 0 0
!

# Enable services
log file /var/log/frr/ospfd.log

! End
conf
# /etc/frr/frr.conf (Site A - ABR)

hostname rgz-site-a-ospf
!

router ospf
 ospf router-id 2.2.2.2
 passive-interface default
 no passive-interface wg0

 area 0.0.0.0 authentication message-digest

 network 172.16.1.2/32 area 0.0.0.0    # Site A management
 network 10.150.0.0/24 area 0.0.0.1    # Site A VLAN

 timers spf delay 100 initial-holdoff 100 max-holdoff 5000

 interface wg0
  ip ospf cost 10
  ip ospf hello-interval 40
  ip ospf dead-interval 160
  ip ospf authentication message-digest
  ip ospf message-digest-key 1 md5 [OSPF_AUTH_KEY]
!

line vty
 exec-timeout 0 0
!

Endpoints API (indirects, V2)

MéthodeRouteRéponseAuth
GET/api/v1/ospf/topology200 {routers: [...], links: [...], areas: [...]}Admin
GET/api/v1/ospf/routes200 {items: [{dest, via, cost, distance, ...}]}Admin
GET/api/v1/ospf/adjacencies200 {items: [{rid, state, uptime, ...}]}Admin
GET/api/v1/ospf/lsa/{area_id}200 LSA databaseAdmin

Commandes Utiles (V2)

bash
# Vérifier status OSPF (si déployé)
vtysh -c "show ip ospf"

# Voir voisins (adjacencies)
vtysh -c "show ip ospf neighbor"

# Voir routes apprises via OSPF
vtysh -c "show ip route ospf"

# Voir database LSA
vtysh -c "show ip ospf database"

# Voir métriques par interface
vtysh -c "show ip ospf interface"

# Debug: logs OSPF
vtysh -c "debug ospf ism"
vtysh -c "debug ospf lsa"

# FRRouting CLI (vtysh)
vtysh
show ip ospf
show ip ospf neighbor
show ip ospf database
show ip ospf database router
exit

# Tester adjacency manuellement
ping [neighbor-ospf-ip]
traceroute [neighbor-ospf-ip]

# Vérifier convergence après failover
watch vtysh -c "show ip ospf neighbor"  # Observe state changes

# Reload config (non-disruptive)
vtysh -c "reload"

# Save config
vtysh -c "write memory"

# Prometheus scrape FRRouting exporter
curl http://localhost:9184/metrics | grep ospf

Implémentation TODO (V2 Q3-2026)

  • [ ] V1 (maintenant): Skip OSPF, utiliser routes statiques + WireGuard
  • [ ] Dockerfile frrouting (multi-stage, slim)
  • [ ] Configuration frr.conf pour NOC + sites
  • [ ] Setup MD5 authentication OSPF (generation clé)
  • [ ] Interface WireGuard dans OSPF (timers ajustés)
  • [ ] Redistribution routes statiques (backward compatibility)
  • [ ] Prometheus exporter FRRouting (port 9184)
  • [ ] Tests: adjacency NOC-Site, apprise routes, convergence
  • [ ] High availability: NOC avec 2 nodes OSPF (pacemaker/corosync)
  • [ ] Documentation: OSPF design, troubleshooting, migration path
  • [ ] Monitoring: alertes adjacency down, routes missing, SPF spike
  • [ ] Intégration Grafana: topology visual, LSA counts, convergence time
  • [ ] Phase V2 Q3-2026: Deploy OSPF + remove static routes

Status V1 (Février 2026)

CECI EST UN OUTIL V2 — NON DÉPLOYÉ EN V1

La V1 utilise des routes statiques et WireGuard (#35) uniquement. Les routes inter-sites sont configurées manuellement sur chaque gateway et ne changent pas en cas de défaillance. L'implémentation OSPF est documentée pour préparation V2 (Q3 2026) afin de supporter scaling vers 100+ sites avec reconvergence automatique.

Pour V1, ignorer ce fichier et utiliser #35 WireGuard + routes statiques.


Dernière mise à jour: 2026-02-21

PROJET MOSAÏQUE — 81 outils, 22 conteneurs, 500+ revendeurs WiFi Zone