Useful Articles

25/recent/ticker-posts

BGP NEXT HOP ATTRIBUTE and RULES

BGP NEXT HOP ATTRIBUTE and RULES

This Blog explains BGP Next-Hop Attribute and Rules in detail. The BGP next-hop attribute is a well-known mandatory attribute that indicates the next-hop IP address that is to be used to reach a destination. BGP, like IGPs, is a hop-by-hop routing protocol. However, unlike IGPs, BGP routes AS-by-AS, not router-by-router, and the default next-hop is the next AS. The next-hop address for a network from another AS is an IP address of the entry point of the next AS along the path to that destination network. Next hop changes when AS changes.

Consider the below diagram:

BGP NEXT-HOP ATTRIBUTE and RULES

BGP NEXT-HOP ATTRIBUTE - Rule 1


Next-Hop for locally originated routes is 0.0.0.0 in an AS. For example, Next-Hop for R2’s local prefix 9.9.0.2/32 is 0.0.0.0

R2#show ip bgp | i 9.9.0.2
BGP table version is 8, local router ID is 9.9.0.2
*> 9.9.0.2/32    0.0.0.0    0   32768     i


BGP NEXT-HOP ATTRIBUTE - Rule 2

BGP next hop doesn't change for iBGP peers. For example, in AS 200, for prefix 9.9.0.1/32 BGP next-hop points to external BGP peer address 9.9.12.1(default behavior) and BGP next-hop doesn’t change for all iBGP peers in that AS. We have created full mesh peering in AS 200 (.i.e. Neighborship b/w R2-R3 and R2-R4 on loopback address).

For example, Next-Hop for 9.9.0.1/32 on R1 shows to be 9.9.12.1 (R1’s eBGP Peer IP address).
The Next-Hop will remain same on R4.

R1#show ip bgp | i 9.9.0.1
*> 9.9.0.1/32    9.9.12.1    0   0    100  i

R4#show ip bgp | i 9.9.0.1
*> 9.9.0.1/32    9.9.12.1    0   0    100  i


BGP NEXT-HOP ATTRIBUTE - Rule 3

If we don’t advertise 9.9.12.0/24 in BGP on R1 and R2, the prefix 9.9.0.1/32 will become unreachable on R3 and R4 as the next-hop 9.9.12.1 becomes unreachable. Output from R4:

R4#show ip bgp | i 9.9.0.1
* i 9.9.0.1/32    9.9.12.1     0   100   0    100 i

R4#ping 9.9.12.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 9.9.12.1, timeout is 2 seconds:
…..
Success rate is 0 percent (0/5)



BGP NEXT-HOP ATTRIBUTE - Rule 4


Solution to this problem is “Next-Hop-Self”.

Configure neighbors R3 and R4 with “next-hop-self” command.  With this, R2 will not advertise 9.9.12.1 as next-hop for prefix 9.9.0.1/32 to R3 and R4,  but will advertise its own loopback address 9.9.0.2.

R2(config)#router bgp 100
R2(config-router)#neighbor 9.9.0.3 next-hop-self
R2(config-router)#neighbor 9.9.0.4 next-hop-self

Now the prefix 9.9.0.1/32 becomes reachable. See the difference in Next-Hops for prefix 9.9.0.1/32 given in scenario 3 and  next-hop given below from R4.


R4#sh ip bgp | i 9.9.0.1
*>i 9.9.0.1/32   9.9.0.2    0    100   0    100    i


BGP NEXT-HOP ATTRIBUTE - Rule 5

For iBGP neighborships formed on Loopback IPs, BGP next-hop points to loopback interface of IBGP peer if next-hop-self feature is configured with the peering.


BGP NEXT-HOP ATTRIBUTE - Rule 6

Route Reflectors doesn’t change the next-hop of the advertised prefix. They only act as the router copiers.


BGP NEXT-HOP ATTRIBUTE - Rule 7

Next-Hop only changes at eBGP peering. Next Hop will change when prefix is advertised from AS 200 (R4) to AS500 (R5). Please see the output from R5 for prefix 9.9.0.1/32.

For example:

R5#show ip bgp | i 9.9.0.1
*> 9.9.0.1/32    9.9.45.4    0     200  100     i