When to Use BGP Next-Hop-Self

When beginning their CCIE studies, some people, including myself, wonder exactly when the next-hop-self option of BGP should be used. For this example we will use the topology above. Routers 1 and 2 have an iBGP connection established. Routers 2 and 3 have an eBGP connection established. We will imagine that there is a network connected to R3 that R1 wants to connect to. When the middleman router, R2, learns about this remote network connected to R3, the next hop for traffic would be the interface e0/3 of R3. When R2 shares this network advertisement with R1, it will keep the same next hop by default. The issue there is that R1 probably does not have a route to this next hop address, cannot mark it as best, and therefore will not install it in the routing table.

Using Next-Hop-Self

In this case, the network that R1 wants to get to, is the loopback of R3, 3.3.3.3. If I do a “show ip bgp” on R1 I would get some results that look like this:

R1#sh ip bgp
BGP table version is 1, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
 
     Network          Next Hop            Metric LocPrf Weight Path
 * i 3.3.3.3/32       192.168.1.2              0    100      0 234 ?
 * i 192.168.1.0      192.168.1.2              0    100      0 234 ?
R1#

If I turned around and checked the routing table, I would notice that I have nothing in the routing table for 3.3.3.3 (or the 192.168.1.0 network for that matter):

R1#sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override
 
Gateway of last resort is not set
 
      1.0.0.0/32 is subnetted, 1 subnets
C        1.1.1.1 is directly connected, Loopback0
      2.0.0.0/32 is subnetted, 1 subnets
S        2.2.2.2 [1/0] via 10.0.0.2
      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.0.0.0/24 is directly connected, Ethernet0/0
L        10.0.0.1/32 is directly connected, Ethernet0/0
R1#

The reason that the 3.3.3.3 network is not showing on the routing table is because of the next hop in the “show ip bgp” output. The next hop is listed as 192.168.1.2 and per my routing table output, I have no route to that address.

To overcome this issue, there is a simple, yet powerful command. On R2, we will add an additional neighbor statement for the iBGP neighbor, R1. That statement will look like this:

neighbor 1.1.1.1 next-hop-self

With that statement, the next-hop address is changes from the interface e0/1 address of R3 to our i BGP neighbor address of R2, 2.2.2.2. Our routing table DOES have a route to 2.2.2.2, so it will now add those networks to the routing table:

R1#show ip bgp
BGP table version is 3, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
              x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
 
     Network          Next Hop            Metric LocPrf Weight Path
 *>i 3.3.3.3/32       2.2.2.2                  0    100      0 234 ?
 *>i 192.168.1.0      2.2.2.2                  0    100      0 234 ?
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override
 
Gateway of last resort is not set
 
      1.0.0.0/32 is subnetted, 1 subnets
C        1.1.1.1 is directly connected, Loopback0
      2.0.0.0/32 is subnetted, 1 subnets
S        2.2.2.2 [1/0] via 10.0.0.2
      3.0.0.0/32 is subnetted, 1 subnets
B        3.3.3.3 [200/0] via 2.2.2.2, 00:00:29
      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.0.0.0/24 is directly connected, Ethernet0/0
L        10.0.0.1/32 is directly connected, Ethernet0/0
B     192.168.1.0/24 [200/0] via 2.2.2.2, 00:00:29
R1#

That is the most simple way that I have come to know the next-hop-self command in my studies. Basically if you have an eBGP route that is being introduced to an iBGP network, you must make sure that the next hop address is reachable in the routing table. If it is not, you would need to do something such as the configuring BGP next-hop-self to make sure that network gets added to the routing table.

 

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmail
Kevin

Kevin

Cisco CCNP, Senior Network Engineer in the Healthcare Industry. Currently working on my CCIE R&S which is the focus of most of my latest blog posts. #NFD15 Delegate.

Leave a Reply

Your email address will not be published. Required fields are marked *