BGP : Local-AS, No-Prepend et Replace-AS
Dans ce Lab « simple » on va explorer les fonctionnalités de « local-as » et ses options « no-prepend » et « replace-as » dans BGP.
Petit rappel rapide :
- Contrairement à iBGP, le eBGP « prepend » ou « annonce » toujours l’attribut obligatoire « AS-PATH » dans les Updates BGP vers les Neighbors d’autres ASs.
- A part qu’elle soit une métrique de BGP, l’AS-PATH est très utile pour la détection des Loops (tout Update BGP reçu avec le même AS Number est Dropé).
Ce Lab BGP est composé des 3 routeurs dans 3 AS différents : R1 dans l’AS 100, R2 dans l’AS 65210 et R3 dans l’AS 300. Trois interfaces Loopbacks sont déclarées et annoncées dans BGP au niveau des 3 routeurs : 1.1.1.1 (R1), 2.2.2.2 (R2) et 3.3.3.3 (R3).
L’utilité de la fonctionnalité « local-as » dans BGP est de faire appartenir un routeur à un AS « virtuel » non réellement présent dans la topologie. Plus simplement, un routeur présent dans un AS « X » s’annonce aux autres voisins comme étant présent dans un AS « Y ». Cela est utile lors des migrations lorsqu'on veut cacher l'AS réel ou pour éviter les boucles et/ou drops BGP.
Revenons au Lab, le but final est que R2 cache son AS réel 65210 et annonce l’AS fictif 200.
Prenons les configs initiales suivantes pour les trois équipements :
R1: router bgp 100 no synchronization bgp log-neighbor-changes neighbor 192.168.10.2 remote-as 200 network 1.1.1.1 mask 255.255.255.255 no auto-summary R2: router bgp 65210 no synchronization bgp log-neighbor-changes neighbor 192.168.10.1 remote-as 100 neighbor 192.168.100.2 remote-as 300 network 2.2.2.2 mask 255.255.255.255 no auto-summary R3: router bgp 300 no synchronization bgp log-neighbor-changes neighbor 192.168.100.1 remote-as 65210 network 3.3.3.3 mask 255.255.255.255 no auto-summary
On Remarque bien d’après les Outputs qui suivent que le voisinage entre R1 et R2 ne s’est pas établi vu que R2 est réellement dans l’AS 65210 (alors qu’on veut prétendre qu’il est dans l’AS 200 tel que R1 est configuré).
Initialement, l’output des commandes « sh bgp all summary » et « sh bgp ipv4 unicast all » sur les 3 équipements est le suivant :
R1#sh bgp sum BGP router identifier 1.1.1.1, local AS number 100 BGP table version is 2, main routing table version 2 1 network entries using 132 bytes of memory 1 path entries using 52 bytes of memory 2/1 BGP path/bestpath attribute entries using 336 bytes of memory BGP using 520 total bytes of memory BGP activity 1/0 prefixes, 1/0 paths, scan interval 60 secs Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 192.168.10.2 4 200 195 199 0 0 0 never Idle R1#sh bgp ipv4 unicast BGP table version is 2, local router ID is 1.1.1.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 0.0.0.0 0 32768 i *Jan 17 17:22:44.503: %BGP-3-NOTIFICATION: sent to neighbor 192.168.10.2 2/2 (peer in wrong AS) 2 bytes FEBA
R2#sh bgp sum BGP router identifier 2.2.2.2, local AS number 65210 BGP table version is 3, main routing table version 3 2 network entries using 264 bytes of memory 2 path entries using 104 bytes of memory 3/2 BGP path/bestpath attribute entries using 504 bytes of memory 1 BGP AS-PATH entries using 24 bytes of memory Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory BGP using 928 total bytes of memory BGP activity 2/0 prefixes, 2/0 paths, scan interval 60 secs Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 192.168.10.1 4 100 209 210 0 0 0 never Idle 192.168.100.2 4 300 7 6 3 0 0 00:04:04 1 R2#sh bgp ipv4 unicast BGP table version is 3, local router ID is 2.2.2.2 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 2.2.2.2/32 0.0.0.0 0 32768 i *> 3.3.3.3/32 192.168.100.2 0 0 300 i *Jan 17 17:23:19.891: %BGP-3-NOTIFICATION: received from neighbor 192.168.10.1 2/2 (peer in wrong AS) 2 bytes FEBA
R3#sh bgp summ BGP router identifier 3.3.3.3, local AS number 300 BGP table version is 3, main routing table version 3 2 network entries using 264 bytes of memory 2 path entries using 104 bytes of memory 3/2 BGP path/bestpath attribute entries using 504 bytes of memory 1 BGP AS-PATH entries using 24 bytes of memory 0 BGP route-map cache entries using 0 bytes of memory 0 BGP filter-list cache entries using 0 bytes of memory Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory BGP using 928 total bytes of memory BGP activity 2/0 prefixes, 2/0 paths, scan interval 60 secs Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 192.168.100.1 4 65210 8 9 3 0 0 00:06:03 1 R3#sh bgp ipv4 unicast BGP table version is 3, local router ID is 3.3.3.3 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 2.2.2.2/32 192.168.100.1 0 0 65210 i *> 3.3.3.3/32 0.0.0.0 0 32768 i
On applique donc le correctif : R2 prétend qu’il est dans l’AS 200 avec la commande « local-as ».
Par conséquent, R1 va « croire » et « admettre » que R2 est bien dans l’AS 200 alors que réellement ce n’est pas le cas (noter que la session BGP reste toujours UP entre R2 et R3 avec les AS 65210 et 300).
R2 :
router bgp 65210
neighbor 192.168.10.1 local-as 200
*Jan 17 17:38:00.527: %BGP-5-ADJCHANGE: neighbor 192.168.10.1 Up
La session BGP monte bien entre R1 et R2 et les résultats des Outputs précédents sont les suivants :
R1#sh bgp sum BGP router identifier 1.1.1.1, local AS number 100 BGP table version is 4, main routing table version 4 3 network entries using 396 bytes of memory 3 path entries using 156 bytes of memory 4/3 BGP path/bestpath attribute entries using 672 bytes of memory 2 BGP AS-PATH entries using 48 bytes of memory Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory BGP using 1304 total bytes of memory BGP activity 3/0 prefixes, 3/0 paths, scan interval 60 secs Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 192.168.10.2 4 200 888 905 4 0 0 00:04:27 2 R1#sh bgp ipv4 unicast BGP table version is 4, local router ID is 1.1.1.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 0.0.0.0 0 32768 i *> 2.2.2.2/32 192.168.10.2 0 0 200 65210 i *> 3.3.3.3/32 192.168.10.2 0 200 65210 300 i
On voit clairement que l’AS 200 est annoncé (prepended) vers R1.
Malgré que le BGP est UP avec les préfixes reçus, on remarque un petit effet de bord de la commande : l’AS réel 65210 et l’AS fictif annoncé 200 sont tous les deux conservés ensemble dans le paramètre AS-PATH.
R2#sh bgp sum BGP router identifier 2.2.2.2, local AS number 65210 BGP table version is 4, main routing table version 4 3 network entries using 396 bytes of memory 3 path entries using 156 bytes of memory 4/3 BGP path/bestpath attribute entries using 672 bytes of memory 2 BGP AS-PATH entries using 48 bytes of memory Bitfield cache entries: current 3 (at peak 3) using 96 bytes of memory BGP using 1368 total bytes of memory BGP activity 3/0 prefixes, 3/0 paths, scan interval 60 secs Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 192.168.10.1 4 100 862 864 4 0 0 00:07:10 1 192.168.100.2 4 300 30 30 4 0 0 00:27:10 1 R2#sh bgp ipv4 unicast BGP table version is 4, local router ID is 2.2.2.2 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 192.168.10.1 0 0 200 100 i *> 2.2.2.2/32 0.0.0.0 0 32768 i *> 3.3.3.3/32 192.168.100.2 0 0 300 i
R3#sh bgp summ BGP router identifier 3.3.3.3, local AS number 300 BGP table version is 4, main routing table version 4 3 network entries using 396 bytes of memory 3 path entries using 156 bytes of memory 4/3 BGP path/bestpath attribute entries using 672 bytes of memory 2 BGP AS-PATH entries using 48 bytes of memory Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory BGP using 1304 total bytes of memory BGP activity 3/0 prefixes, 3/0 paths, scan interval 60 secs Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 192.168.100.1 4 65210 31 31 4 0 0 00:28:09 2 R3#sh bgp ipv4 unicast BGP table version is 4, local router ID is 3.3.3.3 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 192.168.100.1 0 65210 200 100 i *> 2.2.2.2/32 192.168.100.1 0 0 65210 i *> 3.3.3.3/32 0.0.0.0 0 32768 i
Afin de supprimer cet ajout -qui porte confusion et perturbant pour certains-, on peut bloquer la propagation de l’AS fictif crée en utilisant l’option « no-prepend ».
La commande est la suivante :
R2: router bgp 65210 neighbor 192.168.10.1 local-as 200 no-prepend
*Jan 17 17:56:52.455: %BGP-5-ADJCHANGE: neighbor 192.168.10.1 Down Local AS change *Jan 17 17:56:54.339: %BGP-5-ADJCHANGE: neighbor 192.168.10.1 Up
On peut déduire les résultats maintenant : Pas de « prepending » de l’AS 200 crée vers R1 :
R1#sh bgp ipv4 unicast
BGP table version is 8, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 i
*> 2.2.2.2/32 192.168.10.2 0 0 65210 i
*> 3.3.3.3/32 192.168.10.2 0 65210 300 i
R2#sh bgp ipv4 unicast
BGP table version is 6, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 192.168.10.1 0 0 100 i
*> 2.2.2.2/32 0.0.0.0 0 32768 i
*> 3.3.3.3/32 192.168.100.2 0 0 300 i
R3#sh bgp ipv4 unicast
BGP table version is 6, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 192.168.100.1 0 65210 100 i
*> 2.2.2.2/32 192.168.100.1 0 0 65210 i
*> 3.3.3.3/32 0.0.0.0 0 32768 i
Voilà, tout ce qui sort par R2 vers R1 ne contient pas l’AS fictif 200. Pour certains, c’est une faille aussi, car on n’est pas arrivé au but final :
On veut - à part que toutes les sessions BGP soient UP - que R1 ne voit que l’AS 200 depuis R2 et que cet AS reste non visible de la part de R3 (R3 ne sait que 65210).
Il suffit alors de « remplacer » l’AS réel « prepended » par celui fictif 200 (toujours en sortie depuis R2 vers R1 uniquement).
Config :
R2: router bgp 65210 neighbor 192.168.10.1 local-as 200 no-prepend replace-as
*Jan 17 18:10:02.051: %BGP-5-ADJCHANGE: neighbor 192.168.10.1 Down Local AS change *Jan 17 18:10:07.671: %BGP-5-ADJCHANGE: neighbor 192.168.10.1 Up
Les résultats finaux sont les suivants :
R1#sh bgp ipv4 unicast
BGP table version is 12, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 i
*> 2.2.2.2/32 192.168.10.2 0 0 200 i
*> 3.3.3.3/32 192.168.10.2 0 200 300 i
R2#sh bgp ipv4 unicast
BGP table version is 8, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 192.168.10.1 0 0 100 i
*> 2.2.2.2/32 0.0.0.0 0 32768 i
*> 3.3.3.3/32 192.168.100.2 0 0 300 i
R3#sh bgp ipv4 unicast
BGP table version is 8, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 192.168.100.1 0 65210 100 i
*> 2.2.2.2/32 192.168.100.1 0 0 65210 i
*> 3.3.3.3/32 0.0.0.0 0 32768 i
Recap :
Local-as : Je suis dans un autre AS, virtuel.
No-prepend : n’annonce pas cet AS fictif dans l’AS-PATH des Updates BGP (car par défaut les deux AS réel et fictif sont prepended).
Replace-as : permet de remplacer l’AS réel annoncé vers un neighbor par celui virtuel afin de cacher l’AS réel à ce neighbor là.
Ce contenu t’a plu ? T'as trouvé utile ?
Tu peux m’offrir alors un Super Café ☕☕:)
Ton soutien me permet de continuer à créer des ressources gratuites et utiles :)
✔ Soutien volontaire
✔ Aucun abonnement
✔ Paiement 100% sécurisé
🔒 Paiement sécurisé via Stripe
Ajouter un commentaire
Commentaires