Sunteți pe pagina 1din 53

Intro au protocole BGP

Quelques termes utiliss dans ce


cours
IGP (Interior Gateway Protocol)
RIP, IGRP, EIGRP, OSPF
Protocoles de routage utiliss l'intrieur d'un systme
autonome (AS)

EGP (Exterior Gateway Protocol)


BGP
Protocole de routage utilis pour changer des informations de
routage entre
diffrents systmes autonomes (AS)

Autonomous System
(RFC 1771) Un ensemble de routeurs sous une seule
administration, qui utilise
un IGP et des mtriques communes pour faire le routage des
paquets l'intrieur
d'un AS and et un EGP pour le routage vers d'autres ASs.

BGP un protocole de routage vecteur de chemin (path


vector)

Est-il obligatoire d'utiliser BGP ?


L'utilisation de BGP dpend du niveau de
connaissance technique et de la
prsence d'une de ces situations :
Le AS permet le transit de paquets d'autres AS
Le AS a plusieurs connexions d'autres ASs
(multihomed)
Les flux entrants ou sortants de l'AS doivent tre
manipuls

BGP n'est pas ncessaire si


Ne pas utiliser BGP si :
il n'y a qu'une seule connexion ver un autre AS ou FAI
votre AS ne requiert des filtrages ou manipulations des
flux
les routeurs sont limits en mmoire ou capacit de
calcul
l'administrateur a une connaissance limite du processus
de filtrage et
slection des chemins BGP
la liaison entre les AS a une faible bande passante

Dfinition des Systmes Autonomes


(AS)
AS - Un ensemble de routeurs qui partagent des
politiques de routage
similaires et qui sont grs dans un mme domaine
administratif. De
l'extrieur, un AS est vu comme une entit unique
Un AS peut tre compos :
d'un ensemble de routeurs qui tourne le mme protocole IGP
d'un ensemble de routeurs qui tournent diffrents protocoles
de routage (une
grande entreprise ou un FAI, par exemple)

Identification des AS
Dfini par le RFC 1772
Les numros des AS
Attribus par une entit (IANA)
Entre 1 et 65535
Les adresse de 64512 65535 sont rservs pour un usage
prive

Attribution des AS
cause du nombre limit d'AS, il faut justifier le besoin d'un
numro AS
+- 40000 dj attribus
Aujourd'hui, la IANA (Internet Assigned Numbers Authority)
conseille fortement l'usage

des AS 64512-65535 pour les AS qui sont connects un seul


AS

BGP concepts de base


BGP est un protocole de routage par vecteur de chemin
path vector
Une route indique la liste d'ASs qu'il faut traverser pour arriver
la destination
Ex : pour le rseau 10.3.0.0/16, il faut passer par les AS 50, 75,
28

BGP concepts de base


BGP a por objectif :
l'change d'informations de routage entre les ASs
garantir le choix d'une route sans boucle (loop-free)
BGP4 est la premire version de BGP qui supporte
CIDR et agrgation de
routes
IGPs comme RIP, OSPF et EIGRP utilisent des
mtriques
BGP
n'utilise pas une mtrique
fait les dcisions selon des politiques de routage

n'indique pas les dtails internes des ASs


ne reprsente qu'un arbre d'ASs
show ip bgp commande IOS pour afficher la table de
routage BGP

BGP concepts de base


Les mises jour BGP utilisent
TCP sur le port 179
RIP utilise UDP sur le port 520
EIGRP utilise RTP
OSPF n'utilise pas un protocole
de couche 4
Du fait d'utiliser TCP, BGP a besoin de :
une connectivit IP entre les voisins BGP
ouvrir des connexions TCP avant d'changer des
donnes
BGP bnficie de la fiabilit de TCP

Chemin sans boucle (Loop-free)


Pour viter les boucles, BGP construit un graphe avec
les donnes envoyes
par les voisins
La connexion entre deux AS reprsente un chemin
AS Path Le chemin pour atteindre un AS est
reprsent comme une
squence de numros d'AS
Grce aux numros d'AS, un systme autonome peut
dtecter un chemin qui
passe deux fois par le mme AS

12
34
56
Son propre AS

BGP Updates AS Path


500
AS Path
100, 500
AS Path
200, 100, 500 AS Path
300, 200, 100, 500
AS Path
400, 300, 200, 100, 500
AS Path
400, 300, 200, 100, 500

Chemin sans boucles


AS_PATH
Liste des AS associs une
route
L'un des attributs associs aux
routes ( voir plus tard)
La stratgie la plus simple consiste
choisir le chemin le plus court
Pour deux annonces de rseaux
identiques (mmes prefixes), BGP
prfre les routes avec le AS_PATH
le plus petit
Dans cet example, AS7 choisit le
chemin le plus court (4, 2, 1)

Fonctionnement de BGP
Voisins ou pairs Deux routeurs qui tablissent une
connexion TCP
Chaque routeur doit excuter le protocole BGP

change Initial
Lorsqu'une connexion est tablie, les routeurs changent leurs
routes candidates
Aprs l'change initial, des mises jour incrmentales sont
envoyes entre les
routeurs

Suppression de Routes
Les informations sur les routes peuvent tre
aussi concerner
une route qui devient inaccessible
un meilleur chemin disponible

Les routeurs BGP gardent un tableau de


numros de version
Liste des numros de version des mises jour reues de
chaque routeur
Incrment chaque modification des tables de routage
BGP
Une incrmentation rapide indique normalement un
rseau instable ou
mal configur

BGP Keepalives
Les pairs changent des messages keepalive pour
garder la connexion
active

Le dfaut Cisco est de 60 secondes (le RFC 1771


n'espcifie pas une valeur)
Si l'intervalle est dpass trois fois (180 seconds) un
pair est considr down
Les intervalles peuvent tre configures

Les types de message BGP


Avant toute communication entre deux peers il est ncessaire
de dmarrer une connexion
TCP sur le port 179
Une fois ouverte la connexion, BGP change plusieurs
messages avec les paramtres de la
connexion et les informations de routage
Tous les messages BGP sont unicasts vers un seul partenaire
Il y a 4 types de message BGP :
Type 1: OPEN identification initiale entre les peers
Type 2: KEEPALIVE
Type 3: UPDATE mises jour
Type 4: NOTIFICATION - erreurs

Types de message BGP


Chaque message BGP contient l'entte suivante :
Marker : Le champs marker est utilis soit pour authentifier
un message entrant ou
pour dtecter la perte de synchronisation entre les pairs BGP
Length : Le champs length indique la taille totale du message
BGP, entte incluse

Type 1 : BGP Open


Aprs l'tablissement de la connexion TCP, les
routeurs changent
des messages Open

Ce message tabli le voisinage entre les pairs


Chaque voisin s'identifie et spcifie ses
paramtres BGP tems
que :
La version du protocole BGP
Le numro d'AS
Son identifiant BGP
Des paramtres optionnels
Le message BGP Keepalive est envoy priodiquement
entre les pairs afin de
garder la connexion ouverte
Si un routeur accepte les paramtres spcifis dans le
message Open de son
voisin, il rpond avec un Keepalive
Par la suite, les messages Keepalive sont envoys
chaque 60 secondes par les
routeurs Cisco, ou 1/3 du hold time agre (180 secondes)

Type 2 : BGP Keepalive


Les messages UPDATE contiennent toutes les
information
ncessaires afin d'tablir des chemins sans
boucle

Les messages Update servent annoncer des


routes candidates,
supprimer des routes, ou les deux
Les trois composants principaux d'un message
UPDATE sont :
Network-Layer Reachability Information
(NLRI)
Attributs des chemins
Routes supprimes

Type 3 : Update
Network-Layer Reachability Information
(NLRI)
Ce champs annonce les prfixes des adresses
IP et la longueur
de leurs masques
192.168.160.0/19
Prfixe = 192.168.160.0
Longueur = 19
Attributs du chemin (plus tard)
Ce champs contient des informations qui
permettent BGP de

choisir le chemin le plus court, dtecter les


boucles de routage et
la politique de routage
Routes supprimer
Ce sont des rseaux qui sont devenus
inatteignables et doivent
tre supprims

Type 3 : Update
Un message de notification est envoy
lorsqu'une erreur est dtect
et toujours lorsqu'une connexion est ferme
Le message NOTIFICATION est compos des
champs
Code d'Erreur (8 bits)
Sous-code d'Erreur (8 bits)
Un champs de donnes (detaille variable)

Type 4 : Notification
Attributs d'un Chemin
Chaque route a son propre ensemble d'attributs, qui peut
inclure
des informations sur le chemin
prfrences sur les routes
next-hop
informations d'agrgation

Les admins utilisent ces informations pour composer des


politiques de routage
partir des valeurs des attributs, BGP peut tre configur
pour
filtrer des informations sur certaines routes
choisir des chemins prfrentiels

Attributs de Chemin
Certains attributs ne sont pas reconnus par tous les fabricants
Les attributs de chemin ont quatre types

Well-known mandatory
Well-known discretionary
Optional transitive
Optional non-transitive

Attributs de Chemin
Well-known mandatory

Un attribut qui doit tre prsent dans une mise


jour BGP (UPDATE)
Reconnu par toute implmentation BGP
Si un attribut well-known est manquant, une notification
d'erreur sera cre
tablit un standard minimum des attributs
Exemple : l'attribut AS_PATH

Attributs de Chemin
Well-known discretionary

Attribut qui doit aussi tre reconnu par toute


implmentation BGP
Peut ne pas tre envoy dans un message BGP UPDATE
Exemple : LOCAL_PREF

Attributs de Chemin
Optional transitive

Un attribut qui peut ne pas tre reconnu par une


implmentation BGP (donc
optionnel)
Cet attribut est transitif
BGP doit accepter et annoncer l'attribut mme s'il ne
le reconnat pas

Exemple : COMMUNITY

Attributs de Chemin
Optional non-transitive

Un attribut qui peut ne pas tre reconnu par une


implmentation BGP
Mme si un router reconnat l'attribut, il est nontransitif
Ne doit PAS tre repass aux autres pairs BGP
Exemple : ORIGINATOR_ID

Configurer BGP
Pour commencer, entrer dans le mode configuration BGP
Router(config)#router bgp AS-number
Attention, les commandes BGP sont presque similaires ceux
des IGP
Leur fonction peut tre assez diffrente
Note : L'IOS cisco ne permet qu'un seule processus BGP par
routeur
alors un routeur n'appartient qu' un seul AS

Configurer BGP
Router(config-router)#network network-number [mask
networkmask]
Les rseaux doivent tre prsents dans la table de
routage (show ip route) pour

tre distribus
Les routes apprises avec BGP sont diffuses par dfaut,
mais souvent elles sont
filtres par des politiques de routage
Router(config-router)#network network-number [mask
networkmask]

" Avec les IGPs, la commande network indique les interfaces


qui participent ainsi que les
routes annonces
" Dans le cas du protocole BGP, la commande network
n'affecte pas les interfaces
" En BGP, network indique les routes apprises localement qui
seront annonces
" Les rseaux peuvent tre des routes connectes, statiques ou
apprises dynamiquement
" Seulement configurer network ne suffit pas pour tablir des
connexions BGP

Configurer BGP

Configurer BGP
Router(config-router)#neighbor ip-address remote-as ASnumber

La commande Neighbor Utilise pour tablire une


rlation de voisinage
avec un autre routeur BGP
Le paramtre AS-number indique si le routeur est un
voisin EBGP ou IBGP

IBGP versus EBGP


Lorsque BGP s'excute l'intrieur
d'un AS, il est appel Internal BGP
(IBGP).
Un routeur de transit execute IBGP
Utilis presque exclusivement dans le
cas des AS multi-homed

BGP entre deux AS est appel


External BGP (EBGP)
Un routeur de frontire

IBGP versus EBGP


Les routeurs A et B tournent EBGP (BGP) alors que les
routeurs B et C tournent IBGP
On observe que :

les pairs EBGP (BGP) doivent tre directement connects


les pairs IBGP n'ont pas besoin d'tre directement connects
il suffit d'avoir un protocole IGP (OSPF, EIGRP, etc) pour
router les messages
l'intrieur d'un AS

EBGP
RTA(config)#router bgp 100
RTA(config-router)#neighbor 10.1.1.1 remote-as 200
RTB(config)#router bgp 200
RTB(config-router)#neighbor 10.1.1.2 remote-as 100

Observez que la valeur remote-as 100 de la commande


neighbor est diffrente de la
valeur AS-number spcifie par la commande router bgp (200)
Avec deux numros AS diffrents, RTB inicie une connexion
EBGP avec RTA

IBGP
RTB(config)#router bgp 200
RTB(config-router)#neighbor 172.16.1.2 remote-as 200
RTB(config-router)#neighbor 172.16.1.2 update-source
loopback 0
RTC(config)#router bgp 200
RTC(config-router)#neighbor 172.16.1.1 remote-as 200
RTC(config-router)#neighbor 172.16.1.1 update-source
loopback 0

RTB(config-router)#neighbor 172.16.1.2 update-source


loopback 0
RTC(config-router)#neighbor 172.16.1.1 update-source
loopback 0

update-source loopback 0 - indique au routeur


d'utiliser toute interface
oprationnelle pour tablir les connexions TCP (tant que
Lo0 est active et
configure avec une adresse IP)
Sans cette commande update-source loopback 0, les
routeurs BGP ne
peuvent utiliser que l'interface la plus proche
Utiliser n'importe quelle interface augmente la
robustesse de BGP si un lien est
dfaillant

Considrez que la route suivante est entre dans la table


de RTB
0 192.168.1.0/24 [110/74] via 10.2.2.1, 00:31:34, Serial2

RTB a appris cette route grce un IGP (OSPF)


Cet AS utilise OSPF pour changer les routes internes
Comment RTB pourra annoncer cette route via BGP ?
Avec la redistribution des routes OSPF sur BGP ou
Avec la commande BGP network

EBGP
RTB(config)#router bgp 200
RTB(config-router)#network 172.16.1.0 mask 255.255.255.254

RTB(config-router)#network 10.1.1.0 mask 255.255.255.254


RTB(config-router)#network 192.168.1.0

Les deux premires commandes network indiquent le masque


d'un sous-rseau
spcifique
La troisime commande network annonce le rseau
192.168.1.0 sans avoir besoin d'une
redistribution OSPF
route statique
Attention : network ici indique les routes qui seront annoncs
sur toute connexion BGP

EBGP Multihop
EBGP doit connecter directement les pairs pour tablir
une session
Exception : l'IOS Cisco a une option multihop pour
permettre la connexion
logique entre RTW et RTU mme si RTV n'implmente
pas BGP
quivalent augmenter le TTL d'un annonce BGP
Cette option doit tre configure pour chaque pair
Router(config-router)#neighbor IP-address ebgpmultihop
[hops]
EBGP Multihop
EBGP Multihop
I do not speak BGP. But RTW and
RTU can use EBGP multihop to
speak BGP.

EBGP
EBGP Multihop
EBGP Multihop
I do not speak BGP. But RTW and RTU
can use EBGP multihop to speak BGP.

RTW(config)#router bgp 200


RTW(config-router)#neighbor 1.1.1.2 remote-as 300
RTW(config-router)#neighbor 1.1.1.2 ebgp-multihop 2

AS200
AS300
1.1.1.1
1.1.1.2
RTU(config)#router bgp 300
RTU(config-router)#neighbor 1.1.1.1 remote-as 200
RTU(config-router)#neighbor 1.1.1.1 ebgp-multihop 2

Configurer BGP
Lors de la configuration de BGP, les modifications ne
sont pas immdiatement
visibles
Pour forcer BGP de reinitialiser ses tables, utiliser la
commande clear ip bgp
Router#clear ip bgp *
Router#clear ip bgp 10.0.0.0
Utilisez cette commande avec beaucoup d'attention, voir pas
du tout sur un rseau
de production

clear ip bgp * OOPS! Not me but a colleague who was an


employee of a large ISP
with a 3 letter title. Got back from a Cisco routing course and
thought they would try out
some commands on the core network. It took 45 minutes for the
core to reconverge.
P45 followed

Exemple
Comment vrifier la config BGP
Si le routeur n'a pas install les routes prvues, on peut
utiliser la commande
show ip bgp pour vrifier les routes que BGP a appris
RTA#show ip bgp
BGP table version is 3, local router ID is 10.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* i1.0.0.0 192.168.1.6 0 100 0 200 400 e
*>i10.1.1.1/32 10.1.1.1 0 100 0 i
*>i172.16.1.0/24 10.1.1.1 0 100 0 i
* i192.168.1.32/27 192.168.1.6 0 100 0 200 i

RouterC#show ip bgp
BGP table version is 8, local router ID is 200.200.200.66
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 11.0.0.0 0.0.0.0 0 32768 i
*> 12.0.0.0 200.200.200.65 0 300 200 i

*> 192.10.2.0 200.200.200.65 0 0 300 i

BGP table version numro de version interne,


augmente chaque
update
local router ID adresse IP du routeur
Status codes Statut des entres dans la table
s l'entre a t supprime
* l'entre est valide
> l'entre est le meilleur chemin pour le rseau (path
vector)
i l'entre a t apprise par une session IBGP

show ip bgp
RouterC#show ip bgp
BGP table version is 8, local router ID is 200.200.200.66
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal

Origin codes: i - IGP, e - EGP, ? - incomplete


Network Next Hop Metric LocPrf Weight Path
*> 11.0.0.0 0.0.0.0 0 32768 i
*> 12.0.0.0 200.200.200.65 0 300 200 i
*> 193.10.2.0 200.200.200.65 0 0 300 i

Origin codes L'origine des entres :


i entre origine d'un IGP
e entre origine d'un EGP
? entre avec une origine non tablie. Normalement
est un
routeur BGP appris partir d'un IGP

Network adresse IP du rseau


Next Hop adresse IP du prochain saut. Une entre 0.0.0.0
indique que le
routeur a une route non-BGP vers la destination

show ip bgp
RouterC#show ip bgp
BGP table version is 8, local router ID is 200.200.200.66
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal

Origin codes: i - IGP, e - EGP, ? - incomplete


Network Next Hop Metric LocPrf Weight Path
*> 11.0.0.0 0.0.0.0 0 32768 i
*> 12.0.0.0 200.200.200.65 0 300 200 i
*> 193.10.2.0 200.200.200.65 0 0 300 i

Metric Si affiche, indique une mtrique du systme


interautonome
LocPrf Prfrence locale, dfinie avec la commande
set localpreference.
La valeur dfaut est de 100
Weight Poids d'une route, dfinie par les filtres de
l'AS
Path Le chemin vers la destination
Si un routeur BGP n'apparat dans les tables BGP, on
peut utiliser show ip bgp
neighbors pour vrifier les connexions tablies
RTA#show ip bgp neighbors
BGP neighbor is 172.24.1.18, remote AS 200, external link
BGP version 4, remote router ID 172.16.1.1
BGP state = Established, up for 00:03:25
Last read 00:00:25, hold time is 180, keepalive interval is 60 seconds

Neighbor capabilities:
Route refresh: advertised and received
Address family IPv4 Unicast: advertised and received
Received 7 messages, 0 notifications, 0 in queue
Sent 8 messages, 0 notifications, 0 in queue
Route refresh request: received 0, sent 0
Minimum time between advertisement runs is 30 seconds

Comment vrifier la config BGP

Voisinage BGP
Split Horizon Des routes apprises via IBGP ne sont pas
propages vers d'autres
noeuds IBGP
Cela vite la formation de boucles de routage
Pour qu'un routeur IBGP apprend sur les autres routeurs IBGP
l'intrieur d'un AS, ils
doivent tre connects en full mesh
Il suffit qu'une connexion TCP soit possible, pas besoin d'tre
directement connect

Synchronisation des AS
Quand un routeur IBGP reoit un update partir d'un
pair IBGP, il vrifie
cette destination avec un IGP, comme EIGRP ou OSPF
Si le routeur IBGP ne peut pas trouver le rseau dans la
table de routage

IGP, il n'annonce pas cette destinations aux autres


routeurs BGP

Synchronisation des AS
Si la route n'est pas atteignable via IGP, des routeurs
non-BGP ne seront pas
capables de directionner le trafic qui traverse le AS vers
sa destination
Il est inutile d'annoncer des routes aux pairs externes si
les donnes
envoyes travers cet AS seront rejets par un routeur
non-BGP tt ou
tard

Synchronisation des AS
La rgle de synchronisation BGP empche un routeur
BGP (RTC)
d'annoncer aux pairs extrieurs (ISP2) les destinations
(192.213.1.0/24)
apprises par un voisin intrieur (RTA) moins que cette
destination soit
vrifiable via IGP (RTD and RTB).
Si un routeur vrifie la route via IGP, il assume que
cette route a dj t
annonc dans l'AS et que le rseau est atteignable

Synchronisation des AS
Si un routeur IBGP (RTC) a une route IGP vers cette
destination, la route est
considre synchronise et la route sera annonc aux
autres pairs BGP
(ISP2)

Synchronisation des AS
L'injection d'une route BGP dans un AS est assez
coteuse
La redistribution des routes BGP ver un IGP reprsente
une surcharge que
certains routeurs ne sont pas capables de tolrer
une table BGP reprsente autour de 200MB
De plus, connatre toutes les routes BGP l'intrieur
d'un AS n'est pas
ncessaire

Synchronisation des AS
L'IOS Cisco a une option no synchronization
Cette commande donne la possibilit de propager des
routes sans les avoir
vrifi

Synchronisation des AS

Dans la pratique, deux situations permettent d'arrter la


synchronisation sans
danger :
Quand tous les routeurs dans l'AS sont des routeurs IBGP (et
par consquent
totalement connects)
La liaison interne est garantie par l'interconnexion en mesh
IBGP
Lorsque l'AS n'est pas un AS de passage

BGP est un protocole flexible car il reste essentiellement


simple
Dans BGP, les routes sont changes avec des messages
UPDATE
Lorsqu'un routeur reoit un message UPDATE, BGP
applique les politiques
de routage et les filtres sur les mises--jour, avant de
repasser les nouvelles
aux autres routeurs
L'implmentation BGP de Cisco stocke les mises--jour
dans une table spare
de la table de routage IP : show ip bgp!

Le routage BGP
BGP(config)#route-map SET_M_5 permit 10
BGP(config-route-map)#match ip address 1
BGP(config-route-map)#set metric 5
BGP(config-route-map)#exit
BGP(config)#access-list 1 permit 1.1.1.0 0.0.0.255
BGP(config)#route bgp 100
BGP(config-route)#neighbor 172.16.20.2 remote-as 300
BGP(config-route)#neighbor 172.16.20.2 route-map
SET_M_5 out

Une mise--jour sous la forme 1.1.1.x


correspondra l'access list
et sera donc annonce avec une mtrique "cinq"
(5)
Un route-map peut tre appliqu l'entre (mot
cl in) ou la
sortie des paquets UPDATE BGP, avec le mot
cl out

Utilisation d'un Route-map avec


BGP
Lorsqu'un routeur BGP reoit des updates
partir de plusieurs

systmes autonomes qui indiquent des chemins


diffrents vers la
mme destination, BPG doit choisir LE meilleur
chemin
Une fois choisi, BGP annonce ce meilleurs chemin ses
voisins
la dcision est fonde sur la valeur des attributs (tels que
NEXT_HOP ou LOCAL_PREF) inclus dans les updates,
mais aussi par
d'autres facteurs configurables sur la machine

Utilisation des Attributs BGP


ORIGIN
NEXT_HOP
AS_PATH
LOCAL_PREF
Weight
MULTI_EXIT_DISC (MED)
ATOMIC_AGGREGATE

Quelques Attributs BGP importants


" BGP choisit un seul chemin (pas d'quilibrage de charge)

" Quand un chemin est choisi, il est plac dans la table de


routage et annonc aux autres
routeurs
" L'ordre de choix :
1. Si le prochain saut est inaccessible, ignore le chemin
2. Prfrence aux chemins avec le plus grand poids
3. Prfrence aux chemins avec la plus grande prfrence
locale
4. Prfrence aux chemins indiqus par le processus BGP
5. Prfrence aux chemins avec le plus court AS_PATH
6. Prfrence aux chemins avec le plus petit type d'origine
IGP < EGP < Incomplete
7. Prfrence aux chemins avec le plus petit attribut MED
8. Prfrence aux chemins extrieurs
9. Prfrence aux chemins avec le plus proche voisin IGP
10. Prfrence aux chemins avec la plus petite adresse IP,
comme indiqu par BGP router
ID.

Rsum de la procdure du choix des


routes

The ORIGIN attribute


The origin attribute provides information about the origin
of the route. The
origin of a route can be one of three values:
IGPThe route is interior to the originating AS, and is
represented by
the letter i.

This value is set when the network router configuration


command is
used to inject the route into BGP.
EGPThe route is learned via the Exterior Gateway
Protocol (EGP), is
represented by the letter e .
IncompleteThe origin of the route is unknown or
learned in some
other way, and is represented by the ? .
An origin of Incomplete occurs when a route is
redistributed into
BGP.

The ORIGIN attribute


Use a route map and the set origin command to
manipulate the
ORIGIN attribute.

route-map SET_ORIGIN_OSPF permit 10


set origin igp

NEXT_HOP
The NEXT_HOP attribute is a well-known mandatory
attribute
In terms of an IGP, such as RIP, the next hop to reach a
route is the IP
address of the router that has announced the route.

The NEXT_HOP concept with BGP is slightly more


elaborate.
For EBGP sessions, the next hop is the IP address of the
neighbor that
announced the route
For IBGP sessions, for routes originated inside the AS,
the next-hop
is the IP address of the neighbor that announced the
route.
For routes injected into the AS via EBGP, the next hop
learned from
EBGP is carried unaltered into IBGP.
The next hop is the IP address of the EBGP neighbor
from which
the route was learned.

NEXT_HOP and Multiaccess


Media
Routers C and D are in AS 300 are running OSPF.
Router C is running BGP with Router A.
Router C can reach network 180.20.0.0 via 170.10.20.3.
When Router C sends a BGP update to Router A
regarding 180.20.0.0,
it sets the next hop attribute to 170.10.20.3, instead of its
own IP
address (170.10.20.2).

This is because Routers A, B, and C are in the same


subnet, and it
makes more sense for Router A to use Router D as the
next hop, rather
than taking an extra hop via Router C.

NEXT_HOP and Multiaccess


Media
Routers A, C, and D, use a common
media such as Frame Relay (or any
NBMA cloud).
Router C advertises 180.20.0.0 to
Router A with a next hop of
170.10.20.3, just as it would do if the
common media were Ethernet.
Router C
router bgp 300
neighbor 170.10.20.1 remote-as 100
neighbor 170.10.20.1 next-hop-self

The problem is that Router A does


not have a direct permanent virtual
connection (PVC) to Router D and
cannot reach the next hop, so
routing will fail.
To remedy this situation, use the
neighbor next-hop-self router
configuration command.
The neighbor next-hop-self
command causes Router C to

advertise 180.20.0.0 with the next


hop attribute set to 170.10.20.2.

AS_PATH private AS numbers


BGP uses the AS_PATH attribute as part of the routing
updates
(UPDATE packet) to ensure a loop-free topology on the
Internet.
Each route that gets passed between BGP peers will carry
a list of all
AS numbers that the route has already been through.
If the route is advertised to the AS that originated it, that
AS will see
itself as part of the AS_PATH attribute list and will not
accept the
route.
EBGP: BGP speakers prepend their AS numbers when
advertising
routing updates to other autonomous systems (external
peers).

IBGP: When the route is passed to a BGP speaker within


the same
AS, the AS_PATH information is left intact.

AS_PATH private AS numbers


AS_PATH information is one of the attributes, BGP looks
at to
determine the best route to take to get to a destination.
In comparing two or more different routes, given that all
other
attributes are identical, a shorter path is always
preferred.
In case of a tie in AS_PATH length, other attributes are
used to
make the decision.
Private AS numbers cannot be leaked to the Internet
because they
are not unique.
Cisco has implemented a feature, remove-private-as, to
strip
private AS numbers out of the AS_PATH list before the
routes get
propagated to the Internet.
AS_PATH
RTB(config)#router bgp 1
RTB(config-router)#neighbor 172.16.20.2 remote-as 65001

RTB(config-router)#neighbor 192.168.6.3 remote-as 7


RTB(config-router)#neighbor 192.168.6.3 remove-private-as

Note how RTB is using the remove-private-as keyword


in its
neighbor connection to AS7.

The WEIGHT attribute


AS 200
AS 100 1000
2000

The weight attribute is a special Cisco attribute that is


used in the
path selection process when there is more than one route
to the
same destination.
The weight attribute is local to the router on which it is
assigned,
and it is not propagated in routing updates.
By default, the weight attribute is 32768 for paths that the
router
originates and zero for other paths.
Routes with a higher weight are preferred when there
are multiple
routes to the same destination.

AS 200
1000

weight 2000 weight 1000


Higher
weight
preferred
AS 100
2000

RouterC
Using the neighbor weight Command to Set the Weight Attribute
The following configuration for Router C uses the neighbor weight
router configuration
command:
Router C
router bgp 300
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 weight 2000
neighbor 2.2.2.2 remote-as 200
neighbor 2.2.2.2 weight 1000
This configuration sets the weight of all route updates from AS 100 to
2000, and the
weight of all route updates coming from AS 200 to 1000.
Result: The higher weight assigned to route updates from AS 100
causes Router C to
send traffic through Router A.

Regular Expressions
Character
Description

Matches the beginning of the input


string.
Matches the end of the input string.

Matches a space, comma, left brace, right


brace, the beginning of an input string, or
the ending of an input stream

Matches any single character


Matches 0 or more single- or multiplecharacter
patterns.

weight 2000 weight 1000

The WEIGHT attribute


AS 200
AS 100

RouterC
Using an Access List to Set the Weight Attribute
The following commands on Router C use access lists and the value of
the AS_path
attribute to assign a weight to route updates:
Router C
router bgp 300
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 filter-list 5 weight 2000
neighbor 2.2.2.2 remote-as 200
neighbor 2.2.2.2 filter-list 6 weight 1000
ip as-path access-list 5 permit ^100$
ip as-path access-list 6 permit ^200$

weight 2000 weight 1000


AS 200
AS 100

RouterC
Using a Route Map to Set the Weight Attribute

The following commands on Router C use a route map to assign a weight to route
updates:
Router C
router bgp 300
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 route-map SET-WEIGHT-IN in
neighbor 2.2.2.2 remote-as 200
neighbor 2.2.2.2 route-map SET-WEIGHT-IN in
ip as-path access-list 5 permit ^100$
route-map SET-WEIGHT-IN permit 10
match as-path 5
set weight 2000
route-map SET-WEIGHT-IN permit 20
set weight 1000

The LOCAL_PREF Attribute


Well-known discretionary attribute
Degree of preference given to a route to compare it with other
routes for the
same destination
Higher LOCAL_PREF values are preferred
Local to the AS
Exchanged between IBGP peers only
It is not advertised to EBGP peers
Unlike the weight attribute, which is only relevant to the local
router, the
local preference attribute is part of the routing update and is
exchanged
among routers in the same AS (iBGPs).

AS 256 receives route updates for network 170.10.0.0


from AS 100 and
AS 300.
There are two ways to set local preference:
Using the bgp default local-preference command

Using a Route Map to Set Local Preference


Local Pref = 150
All traffic in AS 256 destined for
170.10.0.0 (and other ASes)
Local Pref = 200

Higher Local
Preference is
preferred!
Router C
router bgp 256
bgp default local-preference 150
Router D
router bgp 256
bgp default local-preference 200
Local Pref = 150
All traffic in AS 256 destined for
170.10.0.0 (and other ASs)

Higher Local
Preference is
preferred!
Local Pref = 200

Router D
router bgp 256
neighbor 3.3.3.4 remote-as 300
neighbor 3.3.3.4 route-map SET_LOCAL_IN in
neighbor 128.213.11.1 remote-as 256
ip as-path access-list 7 permit ^300$
route-map SET_LOCAL_IN permit 10
match as-path 7
set local-preference 200

route-map SET_LOCAL_IN permit 20

AS_PATH Attribute
Router D
router bgp 256
neighbor 3.3.3.4 remote-as 300
neighbor 3.3.3.4 route-map SET_LOCAL_IN in
neighbor 128.213.11.1 remote-as 256
ip as-path access-list 7 permit ^300$
route-map SETLOCALIN permit 10
match as-path 7
set local-preference 200
route-map SETLOCALIN permit 20

This command creates a special kind of access


list
that looks at the AS_PATH attribute.
The ip as-path access-list command is used with route maps to match part (or all)
of a
routes AS PATH.
Regular expressions are used with this command to provide specificity.

The MED attribute


Multi-Exit Discriminator Attribute
A lower MED value is preferred over a higher MED value.
The default value of the MED attribute is 0.
Unlike local preference, the MED attribute is exchanged
between ASs, but a
MED attribute that comes into an AS does not leave the AS.
When an update enters the AS with a certain MED value, that
value is used for

decision making within the AS.


When BGP sends that update to another AS, the MED is reset
to 0.
Unless otherwise specified, the router compares MED
attributes for paths from
external neighbors that are in the same AS.
If you want MED attributes from neighbors in other AS to
be compared, you
must configure the bgp always--compare-med command.
value.
By default, BGP compares the MED
attributes of routes coming from
neighbors in the same external AS as
the route (such as AS 300).
RouterA can
only compare
MEDs from the
same AS
Router A
router bgp 100

Router A can only compare the MED


attribute coming from Router C (120) to
the MED attribute coming from Router D
(200) even though the update coming
from Router B has the lowest MED Router C
router bgp 300
remote-as 300
remote-as 300
remote-as 400
neighbor 2.2.2.1
neighbor 3.3.3.3
neighbor 4.4.4.3
Router B
neighbor 2.2.2.2 remote-as 100
SETMEDOUT out

400
300
router bgp 400
neighbor 4.4.4.4
neighbor 4.4.4.4
remote-as 100
route-map
neighbor 2.2.2.2
neighbor 5.5.5.5
neighbor 1.1.1.2
route-map SETMEDOUT
route-map
remote-as
remote-as
permit 10
set metric 120
Router D
router bgp 300
out
remote-as 300
permit 10
SETMEDOUT
neighbor 5.5.5.4
route-map SETMEDOUT
set metric 50
neighbor 3.3.3.2
neighbor 3.3.3.2
neighbor 1.1.1.1
route-map SETMEDOUT
remote-as 100
route map SETMEDOUT out
remote-as 300
permit 10
set metric 200
Router A
router bgp 100

To force Router A to include updates for


network 180.10.0.0 from Router B in the

comparison, use the bgp alwayscomparemed router configuration


command on Router A:
Router A will choose Router B as the
best next hop for reaching network
180.10.0.0 (assuming that all other
attributes are the same). Router C
router bgp 300
300
300
400
neighbor 2.2.2.1 remote-as
neighbor 3.3.3.3 remote-as
neighbor 4.4.4.3 remote-as
bgp always-compare-med
neighbor 2.2.2.2 remote-as 100
SETMEDOUT out
400
300
Router B
router bgp 400
neighbor 4.4.4.4 remote-as 100
neighbor 2.2.2.2
neighbor 5.5.5.5
neighbor 1.1.1.2
route-map SETMEDOUT
route-map
remote-as
remote-as
permit 10
set metric 120
Router D
router bgp 300
neighbor 4.4.4.4 route-map
SETMEDOUT out
neighbor 5.5.5.4 remote-as 300
route-map SETMEDOUT permit 10
set metric 50
neighbor 3.3.3.2

neighbor 3.3.3.2
remote-as 100
route map SETMEDOUT out
remote-as 300
permit 10
neighbor 1.1.1.1
route-map SETMEDOUT
set metric 200

BGP Golden Rules


Attribute Direction Applied Traffic Flow
Affected
Weight
Local-Preference
AS-Path
MED
Inbound
Inbound
Outbound
Outbound
Outbound
Outbound
Inbound
Inbound

ATOMIC_AGGREGATE
Well-known discretionary
172.16.0.0/24 172.16.1.0/24 172.16.2.0/24 172.16.3.0/24 172.16.0.0/22 (Aggregate)
172.16.0.0/24
1 72.16.1.0/24
172.16.2.0/24
RTA RTB 172.16.3.0/24
1 0.1.1.2

AS 2
1 0.1.1.1

AS 1

The purpose is to create an aggregate (summarized) entry


in the
BGP table.
There are two ways to create an aggregate address under
BGP:
1. Create a static entry in the routing table for the
aggregate address
and then advertise it with the network command.
2. Use the aggregate-address command.
An aggregate is created only if a more-specific route to
the aggregate
exists in the BGP table.
172.16.0.0/24
172.16.1.0/24
172.16.2.0/24

Example 1: Aggregating Local Routes


172.16.3.0/24
172.16.0.0/22 (Aggregate)
172.16.0.0/24
1 72.16.1.0/24
172.16.2.0/24
RTA RTB 172.16.3.0/24
1 0.1.1.2

AS 2
1 0.1.1.1

AS 1

show ip bpg 172.16.0.0 will display that this route has the atomicaggregate attribute set.
RTB(config-router)#aggregate-address 172.16.0.0 255.255.252.0
RTA#show ip bgp 172.16.0.0 255.255.252.0
BGP routing table entry for 172.16.0.0/22, version 18
Paths: (1 available, best #1)
<text omitted>
Origin IGP, localpref 100, valid, external, atomic- aggregate, best

BGP Route Filtering


Route filtering empowers a BGP speaker to choose what
routes to
exchange with any of its BGP peers.
Route filtering is the cornerstone of policy routing.
An AS can identify inbound traffic it is willing to
accept, by filtering
its outbound advertisements
An AS can control what routes its outbound traffic uses,
by
specifying the routes to accept from EBGP neighbors
Even more precise policies can be defined via route
filters.
For example, BGP routes passing through a filter can
have their
attributes manipulated to affect the best-path decision
process.
You can apply route filters to or from a particular
neighbor by using the

distribute-list command.
RTA filters update to
RTC so it does not
include the
192.69.10.0/24 network.
RTA(config)#router bgp 3
RTA(config-router)#neighbor 172.16.1.2 remote-as 3
RTA(config-router)#neighbor 172.16.20.1 remote-as 1
RTA(config-router)#neighbor 172.16.20.1 distribute-list 1 out
RTA(config-router)#exit
RTA(config)#access-list 1 deny 192.69.10.0 0.0.0.255
RTA(config)#access-list 1 permit any

Default Routes
It is important to control default information in BGP
because improper
configuration can cause serious Internet routing
problems.
For example, a misconfigured BGP speaker could end up
flooding a
default route to all of its neighbors and quickly find itself
consumed with
default routed traffic from surrounding autonomous
systems.
To protect against misadvertisements, the Cisco IOS
provides a way to

target default information at a specific neighbor by using


the defaultoriginate
option with the neighbor command:
RTC(config)#router bgp 3
RTC(config-router)#neighbor 172.16.20.1 remote-as 1
RTC(config-router)#neighbor 172.16.20.1 default-originate

Default Routes
If a BGP router is to be configured to advertise a default
to all of its
peers, use the network command shown as follows:
RTC(config)#router bgp 3
RTC(config-router)#neighbor 172.16.20.1 remote-as 1
RTC(config-router)#neighbor 172.17.1.1 remote-as 2
RTC(config-router)#network 0.0.0.0

Symmetry
Symmetry is achieved when traffic leaving the AS from one exit
point
comes back through the same point.
Symmetry always exists if an AS maintains a single connection
to outside
networks.
An asymmetrical traffic flow can result in increased delay and
other
routing problems.

In general, customers and providers would like to see their


traffic come back
by way of the same point or close to the same point that it left
the AS.
To promote symmetry, choose a primary path and configure
routing policies
that force traffic to flow along this path.
A default route with a low administrative distance or a high
Local
Preference might serve to control the flow of outbound traffic,
but
inbound traffic can be more complex to manipulate.
Through appropriate planning and use of BGP attributes and
route filters, an
AS can control which paths the outside world finds most
desirable.

Load Balancing
Load balancing is the capability to divide data traffic over
multiple connections.
A BGP speaker may learn two identical EBGP paths for a prefix
from a
neighboring AS.
If this happens, it will choose the path with the lowest route ID
as the best path.
This best path is installed in the IP routing table.
To enable BGP load balancing over equal cost paths, use the
maximum-paths
command, which has the following syntax:
Router(config-router)# maximum-paths number

By default, BGP will install only one path to the IP routing


table.

Les risques de BGP appropriation


de routes
Le cas du FAI pakistanais et de YouTube
Le dimanche 24 fvrier 2008, Pakistan Telecom (AS17557) a
annonc sans
autorisation le prfixe 208.65.153.0/24.
Selon l'ambassade du Pakistan, c'tait une mesure
gouvernementale destine
bloquer l'accs de YouTube en Pakistan
L'un des FAI de Pakistan Telecom (PCCW Global - AS3491) a
transmis cet annonce sur
l'Internet, ce qui a rsult dans le dtournement global du trafic
destin YouTube

Le dbut
AS36561 (YouTube) annonce 208.65.152.0/22.
Dimanche 24 fvrier 2008, 18:47 (UTC) :
AS17557 (Pakistan Telecom) commence annoncer
208.65.153.0/24
AS3491 (PCCW Global Hong Kong) retransmet l'annonce
Les routeurs du monde entier reoivent l'annonce et le trafic
de YouTube est
redirig vers le Pakistan

Suite et fin
Dimanche 24 fvrier 2008, 20:07 (UTC):
AS36561 (YouTube) annonce 208.65.153.0/24.
Avec deux prfixes identiques, des politiques de routage BGP
telles que le chemin le plus
court font leur choix
AS17557 (Pakistan Telecom) continue recevoir une partie du
trafic destin YouTube.
Dimanche 24 fvrier 2008, 20:18 (UTC):
AS36561 (YouTube) annonce 208.65.153.128/25 et
208.65.153.0/25 (et aussi /26)
cause du prfixe plus long, chaque routeur qui reoit cet
annonce choisit de s'adresser
YouTube
Dimanche 24 fvrier 2008, 20:51 (UTC):
Pakistan Telecom via AS3491 (PCCW Global) annonce les
prfixes /25 et /26
La plupart des routeurs continu s'adresser YouTube cause de
la longueur du chemin
Dimanche 24 fvrier 2008, 21:01 (UTC):
AS3491 (PCCW Global) retire tous les prfixes annoncs par
AS17557 (Pakistan
Telecom), finissant le dtournement des routes.

S-ar putea să vă placă și