Saturday 1 February 2020

BGP Next hop self


R6#sh ip bgp
BGP table version is 4, 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
*> 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

 R6 will send the update to its eBGP peer R1 lets check on R1.

R1#sh ip bgp
BGP table version is 4, 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
*> 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

Here we got all the update form R6 note it says best path and valid route.
Then R1 is fully meshed with R2 ad R3 these updates will be updated to R2 and R3.
R2#sh ip bgp
BGP table version is 1, 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
* 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

R3#sh ip bgp
BGP table version is 1, 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
* 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

Note we are getting the update but its not marked as best route. But why ?? Huh the next hop.

What we read in iBGP peer?? BGP rule says the next hop value can only be changed by eBGP by default iBGP peer wont modify the next hop address.

We can solve this using 3 method.

Method 1:  Advertise the transit link  into the ospf.

R6(config)#router ospf 1
R6(config-router)#network 155.1.16.0 0.0.0.255 area 1

R1(config)#router ospf 1
R1(config-router)#network 155.1.16.0 0.0.0.255 area 1

Now lets check on R2 and R3 is the received routes are marked as best route.
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
*>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

R3#sh ip bgp
BGP table version is 4, 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
*>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

R2#sh ip route 6.1.0.1
Routing entry for 6.1.0.0/16
  Known via "bgp 100", distance 200, metric 0
  Tag 600, type internal
  Last update from 155.1.16.6 00:03:54 ago
  Routing Descriptor Blocks:
  * 155.1.16.6, from 150.1.1.1, 00:03:54 ago
      Route metric is 0, traffic share count is 1
      AS Hops 1
      Route tag 600
Its learned via BGP next hop is 155.1.16.6

R2#sh ip route 155.1.16.6
Routing entry for 155.1.16.0/24
  Known via "ospf 1", distance 110, metric 65, type inter area
  Last update from 155.1.123.1 on FastEthernet1/0, 00:04:08 ago
  Routing Descriptor Blocks:
  * 155.1.123.1, from 150.1.1.1, 00:04:08 ago, via FastEthernet1/0
      Route metric is 65, traffic share count is 1

Its learned via OSPF next hop is 155.1.123.1

R2#sh ip route 155.1.123.1
Routing entry for 155.1.123.0/24
  Known via "connected", distance 0, metric 0 (connected, via interface)
  Routing Descriptor Blocks:
  * directly connected, via FastEthernet1/0
      Route metric is 0, traffic share count is 1

R2#sh ip cef 6.1.0.1
6.1.0.0/16, version 26, epoch 0, cached adjacency 155.1.123.1
0 packets, 0 bytes
  via 155.1.16.6, 0 dependencies, recursive
    next hop 155.1.123.1, FastEthernet1/0 via 155.1.16.0/24
    valid cached adjacency



Method 2: Now lets have a look on R5 advertised network.

R5#sh ip bgp  | in 0.0.0.0
*> 5.1.0.0/24       0.0.0.0                  0         32768 i
*> 5.2.0.0/24       0.0.0.0                  0         32768 i
*> 5.3.0.0/24       0.0.0.0                  0         32768 i

R3#sh ip bgp neighbors 150.2.2.2 advertised-routes
BGP table version is 7, 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
*> 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

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
* 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
*>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

Note the route advertised via R3 is not chosen as the best path because the nest hop is not reachable.
Lets modify  the next hop self.

R3#sh run | sec 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 next-hop-self ==> [Since R1 and R2 having peer with R3 using update source lo 0 the next will be changed to the lo 0 address]
 neighbor 150.1.1.1 peer-group iBGP_Peer
 neighbor 150.2.2.2 peer-group iBGP_Peer
 neighbor 155.1.34.4 remote-as 400
 neighbor 155.1.35.5 remote-as 500
 no auto-summary

R2#sh ip bgp
BGP table version is 7, 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
*>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
*>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

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
*>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             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 cef 5.1.0.1
5.1.0.0/24, version 38, epoch 0, cached adjacency 155.1.123.3
0 packets, 0 bytes
  via 150.3.3.3, 0 dependencies, recursive
    next hop 155.1.123.3, FastEthernet2/0 via 150.3.3.3/32
    valid cached adjacency

Method 3: Now lets have a look on R4 advertised network.
R4#sh ip bgp | in 0.0.0.0

*> 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


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 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


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
*>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

Since we have used the 2nd method i.e next-hop-self command
We can change the next hop manually.

R3#sh route-map
route-map nexthop, permit, sequence 10
  Match clauses:
  Set clauses:
    ip next-hop 155.1.123.3
  Policy routing matches: 0 packets, 0 bytes

R3#sh run | s 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 next-hop-self
 neighbor iBGP_Peer route-map nexthop out
 neighbor 150.1.1.1 peer-group iBGP_Peer
 neighbor 150.2.2.2 peer-group iBGP_Peer
 neighbor 155.1.34.4 remote-as 400
 neighbor 155.1.35.5 remote-as 500
 no auto-summary

R2#sh ip bgp
BGP table version is 16, 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


R1#sh ip bgp
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
*>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

No comments:

Post a Comment