20 June, 2013

BGP Lab N:2


Basic BGP Configuration has done :

hostname R1
!
interface Serial1/0
 ip address 10.1.12.1 255.255.255.0
 serial restart-delay 0
!
interface Serial1/1
 ip address 10.1.13.1 255.255.255.0
 serial restart-delay 0
!
router bgp 5500
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.12.2 remote-as 5500
 neighbor 10.1.13.3 remote-as 5500
 no auto-summary
!

hostname R2
!
interface Serial1/0
 ip address 10.1.12.2 255.255.255.0
 serial restart-delay 0
!
interface Serial1/2
 ip address 10.1.23.2 255.255.255.0
 serial restart-delay 0
!
interface Serial1/3
 ip address 10.1.24.2 255.255.255.0
 serial restart-delay 0
!
router bgp 5500
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.12.1 remote-as 5500
 neighbor 10.1.12.1 next-hop-self
 neighbor 10.1.23.3 remote-as 5500
 neighbor 10.1.24.4 remote-as 777
 no auto-summary
!

hostname R3
!
interface Serial1/0
 ip address 10.1.13.3 255.255.255.0
 serial restart-delay 0
!
interface Serial1/2
 ip address 10.1.23.3 255.255.255.0
 serial restart-delay 0
!
interface Serial1/3
 ip address 10.1.36.3 255.255.255.0
 serial restart-delay 0
!
router bgp 5500
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.13.1 remote-as 5500
 neighbor 10.1.13.1 next-hop-self
 neighbor 10.1.23.2 remote-as 5500
 neighbor 10.1.36.6 remote-as 777
 no auto-summary
!

hostname R4
!
interface Serial1/0
 ip address 10.1.45.4 255.255.255.0
 serial restart-delay 0
!
interface Serial1/3
 ip address 10.1.24.4 255.255.255.0
 serial restart-delay 0
!
router bgp 777
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.24.2 remote-as 5500
 neighbor 10.1.45.5 remote-as 911
 no auto-summary
!

hostname R5
!
interface Loopback1
 ip address 150.1.50.5 255.255.255.0
!
interface Loopback2
 ip address 150.2.50.5 255.255.255.0
!
interface Serial1/0
 ip address 10.1.45.5 255.255.255.0
 serial restart-delay 0
!
interface Serial1/1
 ip address 10.1.57.5 255.255.255.0
 serial restart-delay 0
!
router bgp 911
 no synchronization
 bgp log-neighbor-changes
redistribute connected route-map FILTER-20
 neighbor 10.1.45.4 remote-as 777
 neighbor 10.1.57.7 remote-as 711
 no auto-summary
!
access-list 20 permit 150.2.50.0 0.0.0.255
access-list 20 permit 150.1.50.0 0.0.0.255
!
route-map FILTER-20 permit 10

 match ip address 20

hostname R6
!
interface Serial1/0
 ip address 10.1.67.6 255.255.255.0
 serial restart-delay 0
!
interface Serial1/3
 ip address 10.1.36.6 255.255.255.0
 serial restart-delay 0
!
router bgp 777
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.36.3 remote-as 5500
 neighbor 10.1.67.7 remote-as 711
 no auto-summary
!

hostname R7
!
interface Loopback50
 ip address 200.50.2.1 255.255.255.0
!
interface Loopback60
 ip address 200.60.2.1 255.255.255.0
!
interface Serial1/0
 ip address 10.1.67.7 255.255.255.0
 serial restart-delay 0
!
interface Serial1/1
 ip address 10.1.57.7 255.255.255.0
 serial restart-delay 0
!
router bgp 711
 no synchronization
 bgp log-neighbor-changes
 network 200.50.2.0
 network 200.60.2.0
 neighbor 10.1.57.5 remote-as 911
 neighbor 10.1.67.6 remote-as 777
 no auto-summary

!
-------------------------------------------------------------------


R1#show ip bgp

BGP table version is 5, local router ID is 10.1.13.1
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
*>i150.1.50.0/24    10.1.12.2                0    100      0 777 911 ?
* i                 10.1.13.3                0    100      0 777 711 911 ?
*>i150.2.50.0/24    10.1.12.2                0    100      0 777 911 ?
* i                 10.1.13.3                0    100      0 777 711 911 ?
* i200.50.2.0       10.1.12.2                0    100      0 777 911 711 i
*>i                 10.1.13.3                0    100      0 777 711 i
* i200.60.2.0       10.1.12.2                0    100      0 777 911 711 i
*>i                 10.1.13.3                0    100      0 777 711 i

BGP Attributes 

How BGP Findes The Best Path ? 

0. Ignore routes with an inaccessible next hop address.

1. Prefer the path with the higest WEIGHT.

2. Prefer the path with the higest LOCAL_PREF.

3. Prefer the path that was locally originate via a network command.

4. Prefer the path with the shortest AS_PATH.

5. Prefer the path with the lowest origin type. (i > E > ?)

6. Prefer the path with the lowest multi-exit discriminator. (MED)

7. Prefer eBGP over iBGP paths.

8. Prefer the path with the lowest IGP metric to the BGP next hop.

9. Determine if multiple paths require installation in the routing table for BGP Multipath.

10. When both paths are external, prefer the path that was recived first. (the oldest one)

11. Prefer the route that comes from the BGP router with the lowest router ID.

12. If originator or router ID is the same for multiple paths, prefer the path with the minimum cluster list length.

13. Prefer the path that comes from the lowest neighbor address.

Now Configure Some Basic Attributes:

Autonomous System Path AS_PATH

With Default Configuration BGP Use AS-PATH Component To Find Best Path 

4. Prefer the path with the shortest AS_PATH. )

Verify PATH



R1#show ip bgp


<Lines Omitted>   Network          Next Hop            Metric LocPrf Weight Path

*>i150.1.50.0/24    10.1.12.2                0    100      0 777 911 ? (Here You Have 2 Hop)
* i                 10.1.13.3                0    100      0 777 711 911(Here You Have 3 Hop)

You have 2 path to reach the network 150.1.50.0/24 but one of them has lower AS hop count, in this case you use path with lower hop count AS 777 than AS 911

Lower is Better

Cisco Proprietary WEIGHT

Configure Local Router 

( 1. Prefer the path with the higest WEIGHT. )


By Default WEIGHT Is Set To 0


R1#show ip bgp
   Network          Next Hop            Metric LocPrf Weight Path
*>i150.1.50.0/24    10.1.12.2                0    100      0 777 911 ?
* i                 10.1.13.3                0    100      0 777 711 911 ?
*>i150.2.50.0/24    10.1.12.2                0    100      0 777 911 ?
* i                 10.1.13.3                0    100      0 777 711 911 ?
* i200.50.2.0       10.1.12.2                0    100      0 777 911 711 i
*>i                 10.1.13.3                0    100      0 777 711 i
* i200.60.2.0       10.1.12.2                0    100      0 777 911 711 i
*>i                 10.1.13.3                0    100      0 777 711 i

R1#configure terminal

R1(config)#router bgp 5500
R1(config-router)#neighbor 10.1.12.2 weight 300
R1(config-router)#do clear ip bgp *

*Mar  1 02:38:55.015: %BGP-5-ADJCHANGE: neighbor 10.1.12.2 Down User reset
*Mar  1 02:38:55.019: %BGP-5-ADJCHANGE: neighbor 10.1.13.3 Down User reset
*Mar  1 02:38:56.771: %BGP-5-ADJCHANGE: neighbor 10.1.12.2 Up
*Mar  1 02:38:57.279: %BGP-5-ADJCHANGE: neighbor 10.1.13.3 Up

R1#show ip bgp

   Network          Next Hop            Metric LocPrf Weight Path
* i150.1.50.0/24    10.1.13.3                0    100      0 777 711 911 ?
*>i                 10.1.12.2                0    100    300 777 911 ?
* i150.2.50.0/24    10.1.13.3                0    100      0 777 711 911 ?
*>i                 10.1.12.2                0    100    300 777 911 ?
* i200.50.2.0       10.1.13.3                0    100      0 777 711 i
*>i                 10.1.12.2                0    100    300 777 911 711 i
* i200.60.2.0       10.1.13.3                0    100      0 777 711 i
*>i                 10.1.12.2                0    100    300 777 911 711 i



We Just Changed weight from 10.1.12.2 



Network 200.50.2.0/24 has more Hops But its have Weight 300 High than 0



Origin Type 

5. Prefer the path with the lowest origin type. (i > E > ?)

R1#show ip bgp
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*>i150.1.50.0/24    10.1.12.2                0    100      0 777 911 ?
* i                 10.1.13.3                0    100      0 777 711 911 ?
*>i150.2.50.0/24    10.1.12.2                0    100      0 777 911 ?
* i                 10.1.13.3                0    100      0 777 711 911 ?
* i200.50.2.0       10.1.12.2                0    100      0 777 911 711 i
*>i                 10.1.13.3                0    100      0 777 711 i
* i200.60.2.0       10.1.12.2                0    100      0 777 911 711 i
*>i                 10.1.13.3                0    100      0 777 711 i


(i > E > ?)

Where i Is The Best

Local Preference (industry standard)

 ( 2. Prefer the path with the higest LOCAL_PREF. )

Weight is Router Local Component (Does not leave Router)

Local Preference is AS Local Component (Does not leave AS)

Two Way To Configure LOCAL_PREF

The Simple Way To Configure R3 As Primarry Router:

R3#configure terminal
R3(config)#router bgp 5500
R3(config-router)#bgp default local-preference 600

R3(config-router)#do clear ip bgp *

Verify R1 

R1#show ip bgp
   Network          Next Hop            Metric LocPrf Weight Path
*>i150.1.50.0/24    10.1.13.3                0    600      0 777 711 911 ?
* i                 10.1.12.2                0    100      0 777 911 ?
*>i150.2.50.0/24    10.1.13.3                0    600      0 777 711 911 ?
* i                 10.1.12.2                0    100      0 777 911 ?
*>i200.50.2.0       10.1.13.3                0    600      0 777 711 i
* i                 10.1.12.2                0    100      0 777 911 711 i
*>i200.60.2.0       10.1.13.3                0    600      0 777 711 i

* i                 10.1.12.2                0    100      0 777 911 711 i

For All Routes Next Hop Address Is 10.1.13.3 (R3)

Second Way To Configure Local Preference: Using Route-Map

R3#configure terminal
R3(config)#ip access-list standard ROUTES-FOR-R3
R3(config-std-nacl)#permit 150.1.50.0 0.0.0.255
R3(config-std-nacl)#permit 150.2.50.0 0.0.0.255
R3(config-std-nacl)#exit

R3(config)#ip access-list standard ROUTES-FOR-R2
R3(config-std-nacl)#permit 200.50.2.0 0.0.0.255

R3(config-std-nacl)#permit 200.60.2.0 0.0.0.255
R3(config-std-nacl)#exit

R3(config)#route-map LOCAL-PREF permit 10
R3(config-route-map)#match ip address ROUTES-FOR-R3
R3(config-route-map)#set local-preference 1000
R3(config-route-map)#exit

R3(config)#route-map LOCAL-PREF permit 20
R3(config-route-map)#match ip address ROUTES-FOR-R2
R3(config-route-map)#set local-preference 10
R3(config-route-map)#exit

R3(config)#route-map LOCAL-PREF permit 30 (Permit Any)
R3(config-route-map)#exit

R3(config)#router bgp 5500
R3(config-router)#neighbor 10.1.36.6 route-map LOCAL-PREF in
R3(config-router)#do clear ip bgp *


Verify R1 

R1#show ip bgp
   Network          Next Hop            Metric LocPrf Weight Path
*>i150.1.50.0/24    10.1.13.3                0   1000      0 777 711 911 ?
* i                 10.1.12.2                0    100      0 777 911 ?
*>i150.2.50.0/24    10.1.13.3                0   1000      0 777 711 911 ?
* i                 10.1.12.2                0    100      0 777 911 ?
* i200.50.2.0       10.1.13.3                0     10      0 777 711 i
*>i                 10.1.12.2                0    100      0 777 911 711 i
* i200.60.2.0       10.1.13.3                0     10      0 777 711 i

*>i                 10.1.12.2                0    100      0 777 911 711 i

Configure Metric

6. Prefer the path with the lowest multi-exit discriminator. (MED) 

R3(config-router)#default-metric 200

In This Case R2 Becomes Primary Router, Because R2 has 0 Metric By Default

##########################################################################################################