Pages

Tuesday, August 9, 2011

Configuring BGP - Single Multihomed Design

This blogtorial is a continuation from my previous "Configuring BGP - Single Homed". The topology now has a new ISP (ISP B) connected to R1. So R1 now has 2 internet connections. Keep in mind that load balancing is not possible in a Single Multihomed configuration because BGP will install only the best route. However load sharing and failover is possible. Load-sharing in this context means you take in a full BGP routing table and set metrics appropriately.


Objectives:
  • 5.5.5.0/24 and 6.6.6.0/24 will be advertised by both ISP A and ISP B
  • Configure R1 to load share between the 2 ISPs
    • R1 will prefer ISP A for 5.5.5.0/24
    • R1 will prefer ISP B for 6.6.6.0/24. 
  • Advertise 22.22.22.0/24 to both the ISPs so when one of the ISP goes down incoming traffic to 22.22.22.0/24 is not affected. 

Relevant configurations are posted below so let's get started.

First let's get R1 interfaces, static routes and BGP configured. Below are the commands needed.

R1#sh run | sec ip route
ip route 22.22.22.0 255.255.255.0 Null0

R1#sh run int gig2/0
interface GigabitEthernet2/0
 description connected to ISP-A
 ip address 10.0.0.1 255.255.255.0
 negotiation auto
end

R1#sh run int gig3/0
interface GigabitEthernet3/0
 description connected to ISP-B
 ip address 10.2.2.1 255.255.255.0
 negotiation auto
end

R1#sh run | sec bgp
router bgp 22222
 no synchronization
 bgp log-neighbor-changes
 network 22.22.22.0 mask 255.255.255.0
 neighbor 10.0.0.2 remote-as 11111
 neighbor 10.2.2.4 remote-as 44444
 no auto-summary

Now let's get R4 (ISP B) interfaces, some static routes, BGP configured. 

R4#sh run | incl ip route
ip route 0.0.0.0 0.0.0.0 Null0
ip route 5.5.5.0 255.255.255.0 Null0
ip route 6.6.6.0 255.255.255.0 Null0

R4#sh run int gig1/0
interface GigabitEthernet1/0
 description connected to R1
 ip address 10.2.2.4 255.255.255.0
 negotiation auto
end

R4#sh run | sec bgp
router bgp 44444
 no synchronization
 bgp log-neighbor-changes
 network 5.5.5.0 mask 255.255.255.0
 network 6.6.6.0 mask 255.255.255.0
 neighbor 10.2.2.1 remote-as 22222
 neighbor 10.2.2.1 default-originate
 no auto-summary

Now let's get R2 (ISP A) configured. 

R2#sh run | incl ip route 
ip route 0.0.0.0 0.0.0.0 Null0
ip route 5.5.5.0 255.255.255.0 Null0
ip route 6.6.6.0 255.255.255.0 Null0

R2#sh run int gi1/0
interface GigabitEthernet1/0
 description connected to R1
 ip address 10.0.0.2 255.255.255.0
 negotiation auto
end

R2#sh run | sec bgp
router bgp 11111
 no synchronization
 bgp log-neighbor-changes
 network 5.5.5.0 mask 255.255.255.0
 network 6.6.6.0 mask 255.255.255.0
 neighbor 10.0.0.1 remote-as 22222
 neighbor 10.0.0.1 default-originate
 no auto-summary

If you get R1, R2, and R4 configured as above you should have BGP connectivity between R1 and R2 and R1 and R4. Let's verify. Please read this Cisco article to get a better understanding of BGP path selection. Then you can understand why 10.0.0.2 (R2 / ISP A) is chosen as the best route for all routes (5.5.5.0/24, 6.6.6.0/24, 0.0.0.0/24)

Notice all the routes are from 10.0.0.2 
Notice that I do have routes from 10.2.2.4 but those routes do not get installed in the R1 routing table. BGP  only selects the best path. 

BGP relationship between R1 and R2 and R1 and R4 is in place. 
As you can see R1 is BGP peered with 2 ISPs and is now pushing 22.22.22.0/24 to both ISPs. Notice the default route is R2. At this point if R2 (ISP A) goes down then R4 (ISP B) default route will be put into the routing table (failover). BGP selects only the best path. 

Alright now let's get R1 configuration modified to where it will prefer R2 (ISP A) for 5.5.5.0/24 and R4 (ISP B) for 6.6.6.0/24. We can achieve load-sharing in numerous ways but I am going to do this with route-maps, prefix-list and setting the local preference.  

R1#conf t
** Create the prefix-lists to match the subnets ** 
R1(config)#ip prefix-list ISPA seq 10 permit 5.5.5.0/24
R1(config)#ip prefix-list ISPB seq 10 permit 6.6.6.0/24
** Create route-maps -- match prefix-list and set local-preference **
R1(config)#route-map FROMISPA permit 10
R1(config-route-map)# match ip address prefix-list ISPA
R1(config-route-map)# set local-preference 100
R1(config-route-map)#route-map FROMISPA permit 20
R1(config-route-map)# set local-preference 0
R1(config-route-map)#route-map FROMISPB permit 10
R1(config-route-map)# match ip address prefix-list ISPB
R1(config-route-map)# set local-preference 100
R1(config-route-map)#route-map FROMISPB permit 20
R1(config-route-map)# set local-preference 0
R1(config-route-map)#exit
** Apply the route-maps created to the appropriate neighbors ** 
R1(config)#router bgp 22222
R1(config-router)#neighbor 10.0.0.2 route-map FROMISPA in
R1(config-router)#neighbor 10.2.2.4 route-map FROMISPB in
R1(config-router)#exit
** Clear bgp process so the route-maps can take effect ** 
R1#clear ip bgp  * 

Now let's see R1's output to verify. 

Notice R1 now prefers R2 (ISP A) for 5.5.5.0/24 and R4 (ISP B) for 6.6.6.0/24 

Notice the local preference 100 on 5.5.5.0/24 and 6.6.6.0/24 and this why those routes gets installed in R1 routing table.

This is how you implement a Single Multihomed BGP design / load sharing between 2 ISPs. 


NOTE:


When peering with 2 or more ISPs you should implement filtering. So you wont end up being a transit AS between the ISPs. One way to implement this would be to use filter-list. 


On the router where the 2 ISPs terminate (edge router). 

ip as-path access-list 1 permit ^$ #This will permit only routes originating from your AS


Under the bgp configuration on the edge router. 

neighbor <1st ISP> filter-list 1 out #This will only advertise routes originating from your AS
neighbor <2nd ISP> filter-list 1 out #This will only advertise routes originating from your AS


Thanks to Zoltan Lajko for pointing this out to me. I should have added the config below but since this was a basic LAB, I opt'ed not to do so. 

Many more articles to come so stay tuned!! As always, if you like my posts please subscribe by clicking "Join this site".

No comments:

Post a Comment