lunes, 3 de septiembre de 2012

BGP Communities: Filtrando por una community

En el último artículo vimos como podíamos asignar communities a prefijos de BGP, en este lo que vamos a hacer es filtrar el tráfico en base a la community que traiga asignado. Si le echas un un poco de imaginación se te ocurrirá cuantas cosas puedes hacer con route-maps y communities, de cara a redistribuciones...etc.

Configuración:

router bgp x
neighbor x.x.x.x route-map <nombre_route_map> in
route-map <nombre_route_map> deny 10
 match community <nombre_comunity_list>


route-map <nombre_route_map> permit 20 <---si no lo pones te cepillas también el resto de prefijos :-D

ip community-list standard <nombre_comunity_list> permit <community_a_filtrar>



Ejemplo:

El mismo ejemplo de la otra vez, pero en esta ocasión filtrando en R2.

R3(Anunciador):

router bgp 6
 no synchronization
 bgp log-neighbor-changes
 network 22.22.22.22 mask 255.255.255.255
 neighbor 2.2.2.2 remote-as 5
 neighbor 2.2.2.2 ebgp-multihop 2
 neighbor 2.2.2.2 update-source Loopback0
 neighbor 2.2.2.2 send-community
 neighbor 2.2.2.2 route-map COMMOUT out
 no auto-summary

interface Loopback0
 ip address 3.3.3.3 255.255.255.255
!
interface Loopback22
 ip address 22.22.22.22 255.255.255.255

interface Loopback33
 ip address 33.33.33.33 255.255.255.255

interface FastEthernet0/0
!
interface FastEthernet0/1
 no switchport
 ip address 192.168.2.3 255.255.255.0
ip route 1.1.1.1 255.255.255.255 192.168.2.2
ip route 2.2.2.2 255.255.255.255 192.168.2.2

route-map COMMOUT permit 10
 match ip address 23
 set community 3 33 333
!
route-map COMMOUT permit 20
 set community 2 22 222
access-list 23 permit 33.33.33.33

R2(El que filtra):

router bgp 5
 no synchronization
 bgp log-neighbor-changes
 neighbor 1.1.1.1 remote-as 5
 neighbor 1.1.1.1 update-source Loopback0
 neighbor 3.3.3.3 remote-as 6
 neighbor 3.3.3.3 ebgp-multihop 2
 neighbor 3.3.3.3 route-map PRUEBA in
neighbor 3.3.3.3 update-source Loopback0
 no auto-summary
interface Loopback0
 ip address 2.2.2.2 255.255.255.255
!
interface FastEthernet0/0
 no switchport
 ip address 192.168.1.2 255.255.255.0
!
interface FastEthernet0/1
 no switchport
 ip address 192.168.2.2 255.255.255.0

ip route 1.1.1.1 255.255.255.255 192.168.1.1
ip route 3.3.3.3 255.255.255.255 192.168.2.3

ip community-list standard SIN_333 permit 333
!
!
route-map PRUEBA deny 10
 match community SIN_333
!
route-map PRUEBA permit 20


R1:


router bgp 5
 no synchronization
 bgp log-neighbor-changes
 neighbor 2.2.2.2 remote-as 5
 neighbor 2.2.2.2 update-source Loopback0
 no auto-summary

interface Loopback0
 ip address 1.1.1.1 255.255.255.255
!
interface FastEthernet0/0
 no switchport
 ip address 192.168.1.1 255.255.255.0

Verificación:

R2#show ip bgp 22.22.22.22
BGP routing table entry for 22.22.22.22/32, version 8
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Advertised to update-groups:
     1
  6
    3.3.3.3 from 3.3.3.3 (22.22.22.22)
      Origin IGP, metric 0, localpref 100, valid, external, best
      Community: 2 22 222
R2#show ip bgp 33.33.33.33
% Network not in table
R2#