Saturday, 1 February 2020

BGP NLRI Advertisements


Here we are going to learn and understand about the Network Statement.

R1#sh ip route ospf
     150.2.0.0/32 is subnetted, 1 subnets
O       150.2.2.2 [110/2] via 155.1.123.2, 01:08:54, FastEthernet2/0
     150.3.0.0/32 is subnetted, 1 subnets
O       150.3.3.3 [110/2] via 155.1.123.3, 01:08:54, FastEthernet2/0

R1#sh ip route connected
     155.1.0.0/24 is subnetted, 2 subnets
C       155.1.16.0 is directly connected, Serial1/0
C       155.1.123.0 is directly connected, FastEthernet2/0
     150.1.0.0/24 is subnetted, 1 subnets
C       150.1.1.0 is directly connected, Loopback0

Here am going to publish this 150.1.1.0/24, 150.2.2.0/24 and 150.3.3.0/24 network in  BGP. So lets do it.

R1#sh ip bgp regexp ^$
BGP table version is 19, local router ID is 150.1.1.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
*> 150.1.1.0/24     0.0.0.0                  0         32768 i

Amazed only 150.1.1.0/24 network is advertising to others peers but not the other network but why??
Because the bgp network statement mask should match the network in the routing table.
Lets have a look on network statement under the bgp section.
R1#sh run | s router bgp
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 150.1.1.0 mask 255.255.255.0
 network 150.2.2.0 mask 255.255.255.0
 network 150.3.3.0 mask 255.255.255.0
 neighbor iBGP_Peer peer-group
 neighbor iBGP_Peer remote-as 100
 neighbor iBGP_Peer update-source Loopback0
 neighbor 150.2.2.2 peer-group iBGP_Peer
 neighbor 150.3.3.3 peer-group iBGP_Peer
 neighbor 155.1.16.6 remote-as 600
 no auto-summary

And now cross check with our routing table. You will now understand 150.1.1.0/24 is listed but 150.2.2.2/32 and 150.3.3.3/32 network is listed
To overcome this we can do two different things. Whether change the network statement or publish the correct network statement into the ospf domain.

Here am going to change the ip ospf network.
R2(config)#int lo 0
R2(config-if)#ip ospf network point-to-point

R3(config)#int lo 0
R3(config-if)#ip ospf network point-to-point

Now lets look into BGP routing table.
R1#sh ip bgp regexp ^$
BGP table version is 24, local router ID is 150.1.1.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
*> 150.1.1.0/24          0.0.0.0                  0            32768 i
*> 150.2.2.0/24     155.1.123.2              2            32768 i
*> 150.3.3.0/24     155.1.123.3              2            32768 I

See we got all the network which we published in BGP. But if u take a deep look in the above network  you are getting metric value as non zero.
But how bgp got metric value as we knew we didn't configure any metric.
The answer is we got the metric from the IGP.

R1#sh ip route 150.2.2.2
Routing entry for 150.2.2.0/24
  Known via "ospf 1", distance 110, metric 2, type intra area
  Advertised by bgp 100
  Last update from 155.1.123.2 on FastEthernet2/0, 00:15:35 ago
  Routing Descriptor Blocks:
  * 155.1.123.2, from 150.2.2.2, 00:15:35 ago, via FastEthernet2/0
      Route metric is 2, traffic share count is 1

R1#sh ip route 150.3.3.3
Routing entry for 150.3.3.0/24
  Known via "ospf 1", distance 110, metric 2, type intra area
  Advertised by bgp 100
  Last update from 155.1.123.3 on FastEthernet2/0, 00:15:48 ago
  Routing Descriptor Blocks:
  * 155.1.123.3, from 150.3.3.3, 00:15:48 ago, via FastEthernet2/0
      Route metric is 2, traffic share count is 1

The metric(MED) field is copied with the IGP metric value.

Redistribute Statement
Now we are going to redistribute the eigrp route into bgp network o R4.

R4(config)#router bgp 400
R4(config-router)#redistribute eigrp 1

R4(config-router)#do sh ip bgp regex ^$
BGP table version is 48, local router ID is 150.4.4.4
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
*> 4.1.0.0/24       0.0.0.0                  0         32768 i
*> 4.2.0.0/24       0.0.0.0                  0         32768 i
*> 4.3.0.0/24       0.0.0.0                  0         32768 i
*> 44.4.4.0/24      0.0.0.0                  0         32768 ?
*> 44.5.4.0/24      0.0.0.0                  0         32768 ?
*> 44.6.4.0/24      0.0.0.0                  0         32768 ?
*> 150.4.4.0/24     0.0.0.0                  0         32768 ?
*> 150.5.5.0/24     155.1.45.5         2297856         32768 ?
*> 155.1.45.0/24    0.0.0.0                  0         32768 ?

See if we just redistribute the eigrp it will redistribute all the prefixes learned via eigrp and plus the eigrp enabled interface. To over come this am going to create route map and going to advertise only the 44.x.x.x/24 network.

R4(config)#ip prefix-list 44 permit 44.4.4.0/24
R4(config)#ip prefix-list 44 permit 44.5.4.0/24
R4(config)#ip prefix-list 44 permit 44.6.4.0/24

R4(config)#route-map 44_network
R4(config-route-map)#match ip address prefix-list 44

R4(config)#router bgp 400
R4(config-router)#redistribute eigrp 1 route-map 44_network

Now lets check the router R4 what all route they are generating.
R4#sh ip bgp regexp ^$
BGP table version is 33, local router ID is 150.4.4.4
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
*> 4.1.0.0/24       0.0.0.0                  0         32768 i
*> 4.2.0.0/24       0.0.0.0                  0         32768 i
*> 4.3.0.0/24       0.0.0.0                  0         32768 i
*> 44.4.4.0/24      0.0.0.0                  0         32768 ?
*> 44.5.4.0/24      0.0.0.0                  0         32768 ?
*> 44.6.4.0/24      0.0.0.0                  0         32768 ?

R4#sh ip bgp | in \?
Origin codes: i - IGP, e - EGP, ? - incomplete
*> 44.4.4.0/24      0.0.0.0                  0         32768 ?
*> 44.5.4.0/24      0.0.0.0                  0         32768 ?
*> 44.6.4.0/24      0.0.0.0                  0         32768 ?


? Symbol denotes that the network is redistributed into bgp.

BGP Confederation


Here am going to create sub AS this will eliminate the need of full mesh iBGP peer within the AS.

R1#sh run | s router bgp
router bgp 6500
 no synchronization
 bgp log-neighbor-changes
 bgp confederation identifier 100
 bgp confederation peers 65412
 neighbor 150.2.2.2 remote-as 65412
 neighbor 150.2.2.2 ebgp-multihop 2
 neighbor 150.2.2.2 update-source Loopback0
 neighbor 155.1.16.6 remote-as 600
 no auto-summary

R2#sh run | s router bgp
router bgp 65412
 no synchronization
 bgp log-neighbor-changes
 bgp confederation identifier 100
 bgp confederation peers 6500
 neighbor 150.1.1.1 remote-as 6500
 neighbor 150.1.1.1 ebgp-multihop 2
 neighbor 150.1.1.1 update-source Loopback0
 neighbor 150.3.3.3 remote-as 65412
 neighbor 150.3.3.3 update-source Loopback0
 no auto-summary

R3#sh run | s router bgp
router bgp 65412
 no synchronization
 bgp log-neighbor-changes
 bgp confederation identifier 100
 neighbor 150.2.2.2 remote-as 65412
 neighbor 150.2.2.2 update-source Loopback0
 neighbor 155.1.34.4 remote-as 400
 neighbor 155.1.35.5 remote-as 500
 no auto-summary

What's the use of confederation?? Lets look at prefixes advertisement.
As we knew R5 advertising the  prefixes to R3 and R3 will be advertise to R2 , and since R2 and R1 is eBGP peer we don’t need to modify the  Route reflector. R2 will automatically advertise to R1. So lets have a look on R2 bgp updates.


R3#sh ip bgp
BGP table version is 10, local router ID is 150.3.3.3
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
*> 4.1.0.0/24       155.1.34.4               0             0 400 i
*> 4.2.0.0/24       155.1.34.4               0             0 400 i
*> 4.3.0.0/24       155.1.34.4               0             0 400 i
*> 5.1.0.0/24       155.1.35.5               0             0 500 i
*> 5.2.0.0/24       155.1.35.5               0             0 500 i
*> 5.3.0.0/24       155.1.35.5               0             0 500 i
*>i6.1.0.0/16       155.1.16.6               0    100      0 (6500) 600 i
*>i6.2.0.0/16       155.1.16.6               0    100      0 (6500) 600 i
*>i6.3.0.0/16       155.1.16.6               0    100      0 (6500) 600 i

R3 getting the prefixes from R5 with a next hop 155.1.35.5. Since R3 and R2 is an iBGP peer R3 will send the update to R2 but R3 will not change the next hop.

R2#sh ip bgp
BGP table version is 4, local router ID is 150.2.2.2
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
* i4.1.0.0/24       155.1.34.4               0    100      0 400 i
* i4.2.0.0/24       155.1.34.4               0    100      0 400 i
* i4.3.0.0/24       155.1.34.4               0    100      0 400 i
* i5.1.0.0/24       155.1.35.5               0    100      0 500 i
* i5.2.0.0/24       155.1.35.5               0    100      0 500 i
* i5.3.0.0/24       155.1.35.5               0    100      0 500 i
*> 6.1.0.0/16       155.1.16.6               0    100      0 (6500) 600 i
*> 6.2.0.0/16       155.1.16.6               0    100      0 (6500) 600 i
*> 6.3.0.0/16       155.1.16.6               0    100      0 (6500) 600 i

R2 didn’t mark this prefixes as the best and valid routes. Since we don’t have the reachability to the next hop. Lets simply tell the R3 to do next hop modification.

R3(config)#router bgp 65412
R3(config-router)#neighbor 150.2.2.2 next-hop-self

R2#sh ip bgp
BGP table version is 10, local router ID is 150.2.2.2
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
*>i4.1.0.0/24       150.3.3.3                0    100      0 400 i
*>i4.2.0.0/24       150.3.3.3                0    100      0 400 i
*>i4.3.0.0/24       150.3.3.3                0    100      0 400 i
*>i5.1.0.0/24       150.3.3.3                0    100      0 500 i
*>i5.2.0.0/24       150.3.3.3                0    100      0 500 i
*>i5.3.0.0/24       150.3.3.3                0    100      0 500 i
*> 6.1.0.0/16       155.1.16.6               0    100      0 (6500) 600 i
*> 6.2.0.0/16       155.1.16.6               0    100      0 (6500) 600 i
*> 6.3.0.0/16       155.1.16.6               0    100      0 (6500) 600 i

See all the prefixes marked as best and valid routes.  Now R2 will update these prefixes to R1 because they are in eBGP peer. So lets have a look on R1 .
R1#sh ip bgp
BGP table version is 10, local router ID is 150.1.1.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
*> 4.1.0.0/24       150.3.3.3                0    100      0 (65412) 400 i
*> 4.2.0.0/24       150.3.3.3                0    100      0 (65412) 400 i
*> 4.3.0.0/24       150.3.3.3                0    100      0 (65412) 400 i
*> 5.1.0.0/24       150.3.3.3                0    100      0 (65412) 500 i
*> 5.2.0.0/24       150.3.3.3                0    100      0 (65412) 500 i
*> 5.3.0.0/24       150.3.3.3                0    100      0 (65412) 500 i
*> 6.1.0.0/16       155.1.16.6               0             0 600 i
*> 6.2.0.0/16       155.1.16.6               0             0 600 i
*> 6.3.0.0/16       155.1.16.6               0             0 600 i

Note R1 getting the prefixes but have a deep look on the prefixes, the prefixes comes with the sub AS value  prepended. The Sub AS will be denoted in bracket (65412).  So let have look on the last router R6.

R6#sh ip bgp
BGP table version is 36, local router ID is 150.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
*> 4.1.0.0/24       155.1.16.1                             0 100 400 i
*> 4.2.0.0/24       155.1.16.1                             0 100 400 i
*> 4.3.0.0/24       155.1.16.1                             0 100 400 i
*> 5.1.0.0/24       155.1.16.1                             0 100 500 i
*> 5.2.0.0/24       155.1.16.1                             0 100 500 i
*> 5.3.0.0/24       155.1.16.1                             0 100 500 i
*> 6.1.0.0/16       0.0.0.0                  0         32768 i
*> 6.2.0.0/16       0.0.0.0                  0         32768 i
*> 6.3.0.0/16       0.0.0.0                  0         32768 i

Did u noted one interesting thing the Sub AS is removed as it come out the sub AS into normal/main AS.


BGP Cluster ID

Cluster ID is used to prevent the routing loop between the RR router. Lets take an example



Here R2 is an RR and its clients are R3 and R1 but suppose if R1 is also an RR and its client is R3.
Now if R3 send an update to R2 as R2 is RR it will pass those prefixes to R1 and being R1 as RR it will send that same update to R3 which cause loop in routing.

To avoid this RR have an in built feature Cluster ID and  originator id.
Lets check on R1.

R1#sh ip bgp 4.1.0.1
BGP routing table entry for 4.1.0.0/24, version 26
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Advertised to update-groups:
     2
  400
    155.1.123.3 from 150.2.2.2 (150.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal, best
      Originator: 150.3.3.3, Cluster list: 150.2.2.2

See R1 getting an update from RR (R2) but the prefixes  included the originator and cluster id.
Cluster id is the RR router id and originator id is originator of the prefix who send it to RR(R2). If suppose R1 also became RR and it clients to R3, R1 will send the update to R3
When R3 receives this update it will check the originator and cluster id if its originator id is same it will drop those updates. But Is assume that R3 is not the originator of this prefix then R3 will accept and R3 send back the prefix to R2  now R2 check the cluster id it was the same then it will drop the update. This mechanism is used  to prevent the loop by having 2 or more Route reflector.

Cluster id and router id can be changed

R2(config)#router bgp 100
R2(config-router)#bgp cluster-id 1.2.3.4


R1#sh ip bgp 4.1.0.1
BGP routing table entry for 4.1.0.0/24, version 32
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x800
  Advertised to update-groups:
     2
  400
    155.1.123.3 from 150.2.2.2 (150.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal, best
      Originator: 150.3.3.3, Cluster list: 1.2.3.4

Note : Router Id and Cluster Id are different. 

BGP Route Reflection


Yellow indicate the iBGP peer now lets form the iBGP peer.

R2#sh ip bgp su
BGP router identifier 150.2.2.2, local AS number 100
BGP table version is 16, main routing table version 16
9 network entries using 1053 bytes of memory
9 path entries using 468 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 bytes of memory
3 BGP AS-PATH entries using 72 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 2089 total bytes of memory
BGP activity 10/1 prefixes, 10/1 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
150.1.1.1       4   100     338     334       16    0    0 05:31:06        3
150.3.3.3       4   100     343     333       16    0    0 05:30:41        6

So we formed the iBGP peer as given above. Now lets check the router propagation

R3#sh ip bgp ne 150.2.2.2 advertised-routes
BGP table version is 13, local router ID is 150.3.3.3
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
*> 4.1.0.0/24       155.1.34.4               0             0 400 i
*> 4.2.0.0/24       155.1.34.4               0             0 400 i
*> 4.3.0.0/24       155.1.34.4               0             0 400 i
*> 5.1.0.0/24       155.1.35.5               0             0 500 i
*> 5.2.0.0/24       155.1.35.5               0             0 500 i
*> 5.3.0.0/24       155.1.35.5               0             0 500 i

Total number of prefixes 6

R3 advertising totally 6 prefixes to R2 as its having iBGP peer with R2. Now check whether  R1 getting these prefixes from R2.

R2#sh ip bgp ne 150.1.1.1 advertised-routes

Total number of prefixes 0

See R2 not advertising any prefixes to R1 This is because of  BGP SPLIT HORIZON

We can use Route Reflection to over come form this split horizon rule. Lets configure the R2 as Route reflection.

R2#sh run | se router bgp
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor iBGP_Peer peer-group
 neighbor iBGP_Peer remote-as 100
 neighbor iBGP_Peer update-source Loopback0
 neighbor iBGP_Peer route-reflector-client
 neighbor 150.1.1.1 peer-group iBGP_Peer
 neighbor 150.3.3.3 peer-group iBGP_Peer
 no auto-summary

Now lets check whether R1 getting updates from R2.

R2#sh ip bgp ne 150.1.1.1 ad
R2#sh ip bgp ne 150.1.1.1 advertised-routes
BGP table version is 34, local router ID is 150.2.2.2
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
*>i4.1.0.0/24       155.1.123.3              0    100      0 400 i
*>i4.2.0.0/24       155.1.123.3              0    100      0 400 i
*>i4.3.0.0/24       155.1.123.3              0    100      0 400 i
*>i5.1.0.0/24       155.1.123.3              0    100      0 500 i
*>i5.2.0.0/24       155.1.123.3              0    100      0 500 i
*>i5.3.0.0/24       155.1.123.3              0    100      0 500 i
*>i6.1.0.0/16       155.1.16.6               0    100      0 600 i
*>i6.2.0.0/16       155.1.16.6               0    100      0 600 i
*>i6.3.0.0/16       155.1.16.6               0    100      0 600 i

Total number of prefixes 9

See we are advertising the prefixes to R1 .

R1#sh ip bgp
BGP table version is 31, local router ID is 150.1.1.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
*>i4.1.0.0/24       155.1.123.3              0    100      0 400 i
*>i4.2.0.0/24       155.1.123.3              0    100      0 400 i
*>i4.3.0.0/24       155.1.123.3              0    100      0 400 i
*>i5.1.0.0/24       155.1.123.3              0    100      0 500 i
*>i5.2.0.0/24       155.1.123.3              0    100      0 500 i
*>i5.3.0.0/24       155.1.123.3              0    100      0 500 i
*> 6.1.0.0/16       155.1.16.6               0             0 600 i
*> 6.2.0.0/16       155.1.16.6               0             0 600 i
*> 6.3.0.0/16       155.1.16.6               0             0 600 i

R1#sh ip bgp su
BGP router identifier 150.1.1.1, local AS number 100
BGP table version is 31, main routing table version 31
9 network entries using 1053 bytes of memory
9 path entries using 468 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 bytes of memory
1 BGP rrinfo entries using 24 bytes of memory
3 BGP AS-PATH entries using 72 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 2113 total bytes of memory
BGP activity 16/7 prefixes, 16/7 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
150.2.2.2       4   100     416     418       31    0    0 00:54:21        6
155.1.16.6      4   600     414     418       31    0    0 06:46:01        3

We are getting totally  6 BGP prefixes form R2.