Lab 2: BGP Local Preference

Fala pessoal, vamos juntos aprender mais um pouco sobre BGP (Border Gateway Protocol) desta vez vou falar de Local Preference. Sabemos que o BGP escolhe o melhor caminho, caso queira saber um pouco mais sobre os algoritimos de melhor caminho e so clicar no texto em destaque. Neste lab nosso objetivo e influenciar na decisão de roteamento e sugerir um outro caminho AS mais longo.

Como falei no primeiro Lab1 – MED and AS-Path Prepending que vamos sempre começar configurando nossa interfase Loopback, lembrando que é uma interface virtual usada para criar uma conexão lógica de lookback. Normalmente é usado para fornecer um endereço IP consistente para acesso de gerenciamento ao roteador e também pode ser usado para protocolos de roteamento como OSPF e EIGRP. Depois estarei fazendo um artigo somente cobre loopback.

Vamos ao nosso lab 2.

Iniciando com as nossas configurações basicas em nossos ROUTERs:

R1:
interface Loopback0
ip address 1.0.0.1 255.0.0.0
!
interface Loopback1
ip address 2.0.0.1 255.0.0.0
!
interface Ethernet0/0
ip address 12.0.0.1 255.255.255.0
no shutdown
!
interface Ethernet0/1
ip address 13.0.0.1 255.255.255.0
no shutdown
R2:
interface Ethernet0/0
ip address 12.0.0.2 255.255.255.0
no shutdown
!
interface Ethernet0/1
ip address 24.0.0.2 255.255.255.0
no shutdown
R3:
interface Ethernet0/0
ip address 13.0.0.3 255.255.255.0
no shutdown
!
interface Ethernet0/1
ip address 25.0.0.3 255.255.255.0
no shutdown
R4:
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface Ethernet0/0
ip address 24.0.0.4 255.255.255.0
no shutdown
!
interface Ethernet0/1
ip address 10.100.1.4 255.255.255.248
no shutdown
R5:
interface Loopback0
ip address 5.5.5.5 255.255.255.255
!
interface Ethernet0/0
ip address 25.0.0.5 255.255.255.0
no shutdown
!
interface Ethernet0/1
ip address 10.100.1.5 255.255.255.248
no shutdown
R6:
interface Loopback0
ip address 6.6.6.6 255.255.255.255
!
interface Ethernet0/0
ip address 10.100.1.6 255.255.255.248
no shutdown
R7:
interface Loopback0
ip address 7.7.7.7 255.255.255.255
!
interface tEthernet0/0
ip address 10.100.1.3 255.255.255.248
no shutdown

Demorou um pouco mas configuramos todas as nossas interfases necessária para este lab. Vamos agora configurar o EIGRP nos AS 4567 onde esta nossos router R4, R5, R6 e R7 e anunciar a sub-rede 10.100.1.0/29

R4:
router eigrp 4567
network 4.4.4.4 0.0.0.0
network 10.100.1.0 0.0.0.7
R5:
router eigrp 4567
network 5.5.5.5 0.0.0.0
network 10.100.1.0 0.0.0.7
R6:
router eigrp 4567
network 6.6.6.6 0.0.0.0
network 10.100.1.0 0.0.0.7
R7:
router eigrp 4567
network 7.7.7.7 0.0.0.0
network 10.100.1.0 0.0.0.7

Lembrando que o EIGRP usa métrica do resultado da equação que pode usar a Banda (Bandwidth), Delay, Confiabilidade (Realiability), Carga (Load) e MTU, que são os valores que vemos no (K-values) e ainda podemos definir o número máximo de saltos (Hop Count).

Configure o iBGP no AS 4567, use a interface loopback 0 para peering e use o grupo de pares configuração.

  • Configure o eBGP entre AS 4567 e AS 2 e AS 3.
  • Configure o eBGP entre AS 2 e AS 1.
  • Configure o eBGP entre AS 3 e AS 1.

E anuncie as sub-redes 1.0.0.0/8 e 2.0.0.0/8 no BGP:

R4:
router bgp 4567
network 10.100.1.0 mask 255.255.255.248
neighbor INTERNAL peer-group
neighbor INTERNAL remote-as 4567
neighbor INTERNAL update-source Loopback0
neighbor INTERNAL next-hop-self
neighbor 5.5.5.5 peer-group INTERNAL
neighbor 6.6.6.6 peer-group INTERNAL
neighbor 7.7.7.7 peer-group INTERNAL
neighbor 24.0.0.2 remote-as 2
R5:
router bgp 4567
network 10.100.1.0 mask 255.255.255.248
neighbor INTERNAL peer-group
neighbor INTERNAL remote-as 4567
neighbor INTERNAL update-source Loopback0
neighbor INTERNAL next-hop-self
neighbor 4.4.4.4 peer-group INTERNAL
neighbor 6.6.6.6 peer-group INTERNAL
neighbor 7.7.7.7 peer-group INTERNAL
neighbor 35.0.0.3 remote-as 3
R6:
router bgp 4567
neighbor INTERNAL peer-group
neighbor INTERNAL remote-as 4567
neighbor INTERNAL update-source Loopback0
neighbor 4.4.4.4 peer-group INTERNAL
neighbor 5.5.5.5 peer-group INTERNAL
neighbor 7.7.7.7 peer-group INTERNAL
R7:
router bgp 4567
neighbor INTERNAL peer-group
neighbor INTERNAL remote-as 4567
neighbor INTERNAL update-source Loopback0
neighbor 4.4.4.4 peer-group INTERNAL
neighbor 5.5.5.5 peer-group INTERNAL
neighbor 6.6.6.6 peer-group INTERNAL
R1:
router bgp 1
network 1.0.0.0
network 2.0.0.0
neighbor 12.0.0.2 remote-as 2
neighbor 13.0.0.3 remote-as 3
R2:
router bgp 2
neighbor 12.0.0.1 remote-as 1
neighbor 24.0.0.4 remote-as 4567
R3:
router bgp 3
neighbor 13.0.0.1 remote-as 1
neighbor 35.0.0.5 remote-as 4567

Vamos verificar o peer-group e ver os membros atuais, os membros deste grupo são: R5 5.5.5.5, R6 6.6.6.6 e R7 7.7.7.7:

R4#sh ip bgp peer-group INTERNAL
BGP peer-group is INTERNAL, remote AS 4567
  BGP version 4
  Default minimum time between advertisement runs is 0 seconds

For address family: IPv4 Unicast
 BGP neighbor is INTERNAL, peer-group internal, members:
 5.5.5.5 6.6.6.6 7.7.7.7
 Index 0, Offset 0, Mask 0x0
 NEXT_HOP is always this router
 Update messages formatted 0, replicated 0
 Number of NLRIs in the update sent: max 0, min 0

Os peer groups são usados para menor poder de processamento, vamos verificar as adjacências:

R1(config-router)#do show ip bgp sum
BGP router identifier 2.0.0.1, local AS number 1
BGP table version is 6, main routing table version 6
3 network entries using 351 bytes of memory
4 path entries using 208 bytes of memory
4/2 BGP path/bestpath attribute entries using 496 bytes of memory
2 BGP AS-PATH entries using 48 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
BGP using 1103 total bytes of memory
BGP activity 3/0 prefixes, 4/0 paths, scan interval 60 secs

Neighbor   V  AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
12.0.0.2   4  2        6       6      6   0    0 00:01:33       1
13.0.0.3   4  3        6       6      6   0    0 00:00:34       1
R4(config-router)#do show ip bgp sum
BGP router identifier 4.4.4.4, local AS number 4567
BGP table version is 5, main routing table version 5
3 network entries using 351 bytes of memory
6 path entries using 312 bytes of memory
5/2 BGP path/bestpath attribute entries using 620 bytes of memory
2 BGP AS-PATH entries using 48 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
BGP using 1331 total bytes of memory
BGP activity 3/0 prefixes, 6/0 paths, scan interval 60 secs

Neighbor    V   AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
5.5.5.5     4 4567      11      11 5 0 0 00:06:58 3
6.6.6.6     4 4567      10      12 5 0 0 00:07:05 0
7.7.7.7     4 4567      10      12 5 0 0 00:06:27 0
24.0.0.2    4    2       7        6 5 0 0 00:01:55 2
R7(config-router)#do show ip bgp sum
BGP router identifier 7.7.7.7, local AS number 4567
BGP table version is 5, main routing table version 5
3 network entries using 351 bytes of memory
6 path entries using 312 bytes of memory
4/2 BGP path/bestpath attribute entries using 496 bytes of memory
2 BGP AS-PATH entries using 48 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
BGP using 1207 total bytes of memory
BGP activity 3/0 prefixes, 6/0 paths, scan interval 60 secs

Neighbor   V   AS   MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
4.4.4.4    4 4567        12      10      5   0    0 00:06:47       3
5.5.5.5    4 4567        12      10      5   0    0 00:07:08       3
6.6.6.6    4 4567         9       9      5   0    0 00:06:56       0

Agora vamos verificar se AS 4567 está usando o link entre R3-R5 para chegar até o rede 2.0.0.0/8 usando LOCAL_PREF apenas. Antes de fazermos as configurações de LOCAL_PREF vamos usar um traceroute em R6 e R7 para vermos em quais caminhos eles estão indo para alcançar o nossa rede 2.0.0.1

Podemos ver que o tracer passar por R4 e R2

R6#traceroute 2.0.0.1 
Type escape sequence to abort. 
Tracing the route to 2.0.0.1 
1 10.100.1.4 72 msec 24 msec 24 msec 
2 24.0.0.2 60 msec 28 msec 80 msec 
3 12.0.0.1 96 msec * 96 msec 
Traceroute de R6 até 2.0.0.1
R7(config-router)#do traceroute 2.0.0.1
Type escape sequence to abort.
Tracing the route to 2.0.0.1
1 10.100.1.4 56 msec 56 msec 12 msec
2 24.0.0.2 52 msec 48 msec 32 msec
3 12.0.0.1 84 msec * 108 msec
traceroute de R7 até 2.0.0.1

Todos os dois route R6 e R7 estao indo pelo pelor caminho de menor custo, observe que a melhor rota para chegar a 2.0.0.0/8 é via R4 (4.4.4.4) denotada por “*>i ” em ambos R6 e R7:

R6#show ip bgp
BGP table version is 5, local router ID is 6.6.6.6
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
* i1.0.0.0        5.5.5.5    0         100      0 3 1 i
*>i               4.4.4.4    0         100      0 2 1 i
* i2.0.0.0        5.5.5.5    0         100      0 3 1 i
*>i               4.4.4.4    0         100      0 2 1 i
r i10.100.1.0/29  5.5.5.5    0         100      0 i
r>i               4.4.4.4    0         100      0 i
R7(config-router)#do show ip bgp
BGP table version is 5, local router ID is 7.7.7.7
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
* i1.0.0.0         5.5.5.5          0    100      0 3 1 i
*>i                4.4.4.4          0    100      0 2 1 i
* i2.0.0.0         5.5.5.5          0    100      0 3 1 i
*>i                4.4.4.4          0    100      0 2 1 i
r i10.100.1.0/29   5.5.5.5          0    100      0 i
r>i                4.4.4.4          0    100      0 i

Para garantir que o tráfego passe por R5–R3, você dirá ao R5 para anunciar no BGP AS 4567 o prefixo 2.0.0.0/24 com uma local-preference melhor (maior) que R4 como segue, por padrão o LOCAL_PREF é igual a 100:

R5
router bgp 4567
neighbor 25.0.0.3 route-map RM_LOC_PREF in
!
ip prefix-list NET-2 seq 5 permit 2.0.0.0/8
!
route-map RM_LOC_PREF permit 10
match ip address prefix-list NET-2
set local-preference 200
!
route-map RM_LOC_PREF permit 20

Estemos dizendo que agora ele fará esta caminho pois colocamos um route-map fazendo um match e alterando o local-preference para 200

A melhor rota agora para 2.0.0.0/8 de R6 ou R7 é via R5 (5.5.5.5) porque melhor

(maior) Local-Preference 200:

R6#show ip bgp
BGP table version is 6, local router ID is 6.6.6.6
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
* i1.0.0.0       5.5.5.5       0    100      0 3 1 i
*>i              4.4.4.4       0    100      0 2 1 i
*>i2.0.0.0       5.5.5.5       0    200      0 3 1 i
r i10.100.1.0/29 5.5.5.5       0    100      0 i
r>i              4.4.4.4       0    100      0 i
R7(config)#do show ip bgp
BGP table version is 6, local router ID is 7.7.7.7
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
* i1.0.0.0       5.5.5.5       0    100      0 3 1 i
*>i              4.4.4.4       0    100      0 2 1 i
*>i2.0.0.0       5.5.5.5       0    200      0 3 1 i
r i10.100.1.0/29 5.5.5.5       0    100      0 i
r>i              4.4.4.4       0    100      0 i

O traceroute agora mostra que o pacote passa por R5–R3 para chegar a 2.0.0.0/8:

R6#traceroute 2.0.0.1
Type escape sequence to abort.
Tracing the route to 2.0.0.1
  1 10.100.1.5 76 msec 108 msec 20 msec
  2 25.0.0.3 100 msec 120 msec 32 msec
  3 13.0.0.1 148 msec * 176 msec
R7(config)#do traceroute 2.0.0.1
Type escape sequence to abort.
Tracing the route to 2.0.0.1
  1 10.100.1.5 68 msec 136 msec 28 msec
  2 25.0.0.3 112 msec 76 msec 36 msec
  3 13.0.0.1 180 msec * 204 msec

E chegamos ao final do nosso lab sobre LOCAL_PREF onde aprendemos uma pouco mais e que podemos manipular a LOCAL_PREF se for necessário a utilização de route-map, além do match para validar uma referencia e assim setar uma alteração definida por você.

Nos vemos no proximo Lab.

#BGP #Networking #LocalPreference #Roteamento #TI #Infraestrutura

No Responses

Leave a Reply

Your email address will not be published. Required fields are marked *

About Gradiant

It is a long established fact that reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum