Thursday, March 22, 2012

BGP Route Reflector

BGP has a loop prevention mechanism to prevent routing loop in the network, but there is different implementation this mechanism in eBGP and iBGP. eBGP using AS path attribute to do loop prevention. while iBGP using split horizon mechanism(in iBGP, all of routers will use the same AS, so it can't use AS path to prevent routing). By using split horizon mechanism, a route received from iBGP neighbor won't be advertised to any other iBGP neighbor. So we need a full-mesh network in iBGP.


Full-mesh network need a direct connection to all routers in the network, and of course it's not easy to maintain if your network consist of many routers. If we have 20 routers, we'll need a n(n-1)/2 connections or 190 connections for only 20 routers!. what if we have 100 routers? 1000 routers? Having so many connections or peers in your network would be a problem, your routers will take more resources, cost, etc. So full-mesh is not a scalable solution. This why we need a route reflector or bgp confederation (I'll make some notes about bgp confederation on the next articles). Route reflector allow to propagate iBGP routes to other iBGP neighbors and reduce BGP peers connections within an AS. Here is our simple network that implement route reflector. R2 will be a route reflector (RR). R2 will propagate BGP routes from R1 to R3 and vice versa.

To enable router as route reflector, use command "neighbor <peer ip address> route-reflector-client".

Here is the configuration on all routers:
R1:
1:  interface Loopback0  
2:   ip address 1.1.1.1 255.255.255.255  
3:  !  
4:  interface FastEthernet0/0  
5:   ip address 172.16.1.2 255.255.255.252  
6:   duplex auto  
7:   speed auto  
8:  !  
9:  router bgp 100  
10:   no synchronization  
11:   bgp router-id 1.1.1.1  
12:   bgp log-neighbor-changes  
13:   network 1.1.1.1 mask 255.255.255.255  
14:   neighbor 172.16.1.1 remote-as 100  
15:   no auto-summary  
16:  !  

R2:
1:   !  
2:  interface Loopback0  
3:   ip address 2.2.2.2 255.255.255.255  
4:  !  
5:  interface FastEthernet0/0  
6:   ip address 172.16.1.1 255.255.255.252  
7:   duplex auto  
8:   speed auto  
9:  !  
10:  interface FastEthernet0/1  
11:   ip address 172.16.2.1 255.255.255.252  
12:   duplex auto  
13:   speed auto  
14:  !  
15:  router bgp 100  
16:   no synchronization  
17:   bgp router-id 2.2.2.2  
18:   bgp log-neighbor-changes  
19:   network 2.2.2.2 mask 255.255.255.255  
20:   neighbor 172.16.1.2 remote-as 100  
21:   neighbor 172.16.1.2 route-reflector-client  
22:   neighbor 172.16.2.2 remote-as 100  
23:   neighbor 172.16.2.2 route-reflector-client  
24:   no auto-summary  
25:  !  

R3:
1:  !  
2:  interface Loopback0  
3:   ip address 3.3.3.3 255.255.255.255  
4:  !  
5:  interface FastEthernet0/0  
6:   ip address 172.16.2.2 255.255.255.252  
7:   duplex auto  
8:   speed auto  
9:  !  
10:  router bgp 100  
11:   no synchronization  
12:   bgp router-id 3.3.3.3  
13:   bgp log-neighbor-changes  
14:   network 3.3.3.3 mask 255.255.255.255  
15:   neighbor 172.16.2.1 remote-as 100  
16:   no auto-summary  
17:  !  

Note that, you need to configure the static route / IGP(ospf, rip, eigrp, etc) on your routers to carry a local routes and next hop addresses. If want to use static route. Here is the configuration on R1 and R3:

 R1: ip route 172.16.2.0 255.255.255.252 172.16.1.1  
 R2: ip route 172.16.1.0 255.255.255.252 172.16.2.1  

Verify bgp connection using "sh ip bgp summary".

1:  R1 #sh ip bgp sum | beg Nei  
2:  Neighbor    V  AS MsgRcvd MsgSent  TblVer InQ OutQ Up/Down State/PfxRcd  
3:  172.16.1.1    4  100   87   78    8  0  0 00:54:52    2  

Use 'sh ip bgp' to list all of prefixs received from other router.

1:  R1#sh ip bgp  
2:  BGP table version is 8, local router ID is 1.1.1.1  
3:  Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,  
4:         r RIB-failure, S Stale  
5:  Origin codes: i - IGP, e - EGP, ? - incomplete  
6:    Network     Next Hop      Metric LocPrf Weight Path  
7:  *> 1.1.1.1/32    0.0.0.0         0     32768 i  
8:  *>i2.2.2.2/32    172.16.1.1         0  100   0 i  
9:  *>i3.3.3.3/32    172.16.2.2         0  100   0 i  


10:  R1#sh ip bgp 3.3.3.3 11:  BGP routing table entry for 3.3.3.3/32, version 6  
12:  Paths: (1 available, best #1, table Default-IP-Routing-Table)  
13:   Not advertised to any peer  
14:   Local  
15:    172.16.2.2 (metric 2) from 172.16.1.1 (2.2.2.2)  
16:     Origin IGP, metric 0, localpref 100, valid, internal, best  
17:     Originator: 3.3.3.3, Cluster list: 2.2.2.2  

Use ping to make sure that network from R3 is reachable on R1:

1:  R1#ping 3.3.3.3  
2:  Type escape sequence to abort.  
3:  Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:  
4:  !!!!!  
5:  Success rate is 100 percent (5/5), round-trip min/avg/max = 12/44/84 ms  

No comments: