MDstable
NoteSnippetChecklistPlaybook

Routage statique et dynamique

Configurer des routes statiques, OSPF et BGP sur Cisco IOS

snippetintermediate 2025-05-10 4 min read
routingciscoospfbgpstatic-routeIOSrip

Routes statiques

cisco
Variables
{{TARGET}}
{{SERVER_IP}}
! Route statique simple
ip route {{TARGET}} 255.255.255.0 {{SERVER_IP}}
! Route par défaut
ip route 0.0.0.0 0.0.0.0 {{SERVER_IP}}
! Route flottante (backup — distance administrative plus haute)
ip route 10.0.0.0 255.255.0.0 192.168.2.1 200 ! AD 200 > 1 (statique)
! Route vers interface (PPP/serial)
ip route 0.0.0.0 0.0.0.0 Serial0/0
! Vérifier
show ip route
show ip route static
show ip route 10.0.0.0

Distances administratives par défaut

| Protocole | AD | |------------------|-----| | Connecté | 0 | | Statique | 1 | | EIGRP (interne) | 90 | | OSPF | 110 | | RIP | 120 | | EIGRP (externe) | 170 | | eBGP | 20 | | iBGP | 200 |

OSPF

cisco
Variables
{{PASSWORD}}
! Activer OSPF
conf t
router ospf 1
router-id 1.1.1.1
network 192.168.1.0 0.0.0.255 area 0
network 10.0.0.0 0.0.0.255 area 0
passive-interface GigabitEthernet0/1 ! ne pas envoyer de hello
! Sur les interfaces
interface GigabitEthernet0/0
ip ospf 1 area 0
ip ospf cost 10
ip ospf priority 100 ! DR/BDR election
! OSPF authentification (MD5)
interface GigabitEthernet0/0
ip ospf authentication message-digest
ip ospf message-digest-key 1 md5 {{PASSWORD}}
! Redistribuer les routes statiques dans OSPF
router ospf 1
redistribute static subnets
! Vérifier
show ip ospf neighbor
show ip ospf database
show ip ospf interface brief
show ip route ospf
debug ip ospf events

Types d'aires OSPF

| Type | Description | |----------------|------------------------------------------------------| | Backbone (0) | Aire centrale — toutes les autres s'y connectent | | Standard | Reçoit toutes les LSA (intra, inter, externe) | | Stub | Pas de routes externes (LSA type 5 bloquées) | | Totally Stub | Seulement route par défaut (LSA 3,4,5 bloquées) | | NSSA | Stub avec redistribution de routes externes locales |

BGP

cisco
Variables
{{ASN}}
{{SERVER_IP}}
! Configurer eBGP
conf t
router bgp {{ASN}}
bgp router-id 1.1.1.1
neighbor {{SERVER_IP}} remote-as {{ASN}} ! Peer AS
! Annoncer un réseau
router bgp {{ASN}}
network 203.0.113.0 mask 255.255.255.0
! iBGP (même AS)
router bgp {{ASN}}
neighbor 10.0.0.2 remote-as {{ASN}}
neighbor 10.0.0.2 update-source Loopback0
neighbor 10.0.0.2 next-hop-self
! Route Reflector (iBGP full mesh alternative)
router bgp {{ASN}}
neighbor 10.0.0.2 route-reflector-client
neighbor 10.0.0.3 route-reflector-client
! Vérifier
show bgp summary
show bgp neighbors {{SERVER_IP}}
show ip bgp
show ip bgp 203.0.113.0

BGP Attributes (sélection du meilleur chemin)

Ordre de prfrence mnmonique We Love Oranges AS Oranges Mean Pure Refreshment
1 Weight Cisco local plus haut prfr
2 Local Preference plus haut prfr dfaut 100
3 Locally Originated
4 AS Path plus court prfr
5 Origin IGP < EGP < Incomplete
6 MED plus bas prfr
7 eBGP > iBGP
8 IGP metric vers next-hop
9 Route la plus ancienne
10 Router-ID plus bas prfr

Diagnostic réseau

cisco
! Ping étendu
ping 8.8.8.8 source GigabitEthernet0/0 repeat 100
! Traceroute
traceroute 8.8.8.8
traceroute ip 8.8.8.8 source GigabitEthernet0/0
! Table de routage filtrée
show ip route | include 192.168.
show ip route summary
! Interface stats
show interfaces GigabitEthernet0/0
show ip interface brief
! ARP
show arp
clear arp-cache
! Debug (attention en prod)
debug ip routing
debug ip ospf events
no debug all

Linux — ip route

bash
Variables
{{SERVER_IP}}
# Voir la table de routage
ip route show
ip route get 8888 # quel chemin pour cette destination
# Ajouter une route
ip route add 10000/8 via {{SERVER_IP}} dev eth0
ip route add 10000/8 via {{SERVER_IP}} dev eth0 metric 100
# Route par défaut
ip route add default via {{SERVER_IP}}
# Supprimer
ip route del 10000/8
# Persistant (Debian/Ubuntu — /etc/network/interfaces ou netplan)
# Netplan (/etc/netplan/01-netcfg.yaml)
network
ethernets
eth0
addresses 192168110/24
gateway4 19216811
routes
to 10000/8
via 1921681254
💡 Tip —

Pour OSPF en production : toujours configurer une router-id statique (sinon basée sur la plus haute IP d'interface, ce qui peut changer au reboot). Et activer l'authentification sur toutes les interfaces OSPF pour éviter l'injection de routes.

OPS·BRAIN v1.027 notes · Networklocal