BGP Path Attributes II

Next_Hop

Category: well-known mandatory
Preference: shortest path or IGP metric

This attribute defines the next hop in the BGP path which a router has to use. But this does not have to be the direct neighbours address. The following rules apply:

  1. If the advertising and receiving router are in the same AS (iBGP Peers) and the route belongs to the same AS, the Next_Hop address is set to the originating routers interface.
  2. If the advertising and receiving router are not in the same AS (eBGP Peers), the Next_Hop address is set to the eBGP Peers interface.
  3. If the advertising and receiving router are in the same AS, but the route belongs to a different AS, the Next_Hop address is set to the external Routers IP over which the route originally has been advertised into the AS.

If two iBGP peers are no direct neighbors, they will have to do a recursive lookup for every routing update to find their own next hop towards the neighbor router. To do this, the routers have to consult their IGP table. The same happens with external routes, because the external routes Next_Hop is set to the external routers interface over which the AS has learned the route. The recursive lookup will fail if this Next_Hop address is not known by the IGP. To solve this problem you could either expand the IGP so it knows the interface (e.g. passive interface towards that connection), create static routes, redistribute or use the BGP neighbor command next-hop-self.

Next_Hop configuration

Based on the above network diagram the configuration for the routers is straight forward, except that R1 is the route-reflector for R4 to not have to create a full meshed iBGP:

R1#sh run | sec router bgp
 router bgp 124
 no synchronization
 bgp log-neighbor-changes
 network 99.99.1.0 mask 255.255.255.0
 neighbor 116.1.12.2 remote-as 124
 neighbor 116.1.14.4 remote-as 124
 neighbor 116.1.14.4 route-reflector-client
 no auto-summary

R2#sh run | sec router bgp
 router bgp 124
 no synchronization
 bgp log-neighbor-changes
 network 99.99.2.0 mask 255.255.255.0
 neighbor 116.1.12.1 remote-as 124
 neighbor 116.1.23.3 remote-as 3
 no auto-summary

R3#sh run | sec router bgp
 router bgp 3
 no synchronization
 bgp log-neighbor-changes
 network 99.99.3.0 mask 255.255.255.0
 neighbor 116.1.23.2 remote-as 124
 no auto-summary

R4#sh run | sec router bgp
 router bgp 124
 no synchronization
 bgp log-neighbor-changes
 network 99.99.4.0 mask 255.255.255.0
 neighbor 116.1.14.1 remote-as 124
 no auto-summary

Rule 1 applies for all AS124 based loopback addresses and routers. The Next_Hop address for routes and routers in the same AS is set to the originating routers interface:

R1#sh ip bgp | e 99.99.3.0
BGP table version is 4, local router ID is 99.99.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
*> 99.99.1.0/24     0.0.0.0                  0         32768 i
*>i99.99.2.0/24     116.1.12.2               0    100      0 i
*>i99.99.4.0/24     116.1.14.4               0    100      0 i

R2#sh ip bgp | e 99.99.3.0
BGP table version is 5, local router ID is 99.99.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
*>i99.99.1.0/24     116.1.12.1               0    100      0 i
*> 99.99.2.0/24     0.0.0.0                  0         32768 i
*>i99.99.4.0/24     116.1.14.4               0    100      0 i

R4#sh ip bgp | e 99.99.3.0
BGP table version is 4, local router ID is 99.99.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
*>i99.99.1.0/24     116.1.14.1               0    100      0 i
*>i99.99.2.0/24     116.1.12.2               0    100      0 i
*> 99.99.4.0/24     0.0.0.0                  0         32768 i

Rule 2 says that the Next_Hop address of eBGP Peers has to be the eBP Peers address:

R2#sh ip bgp
BGP table version is 5, local router ID is 99.99.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
*>i99.99.1.0/24     116.1.12.1               0    100      0 i
*> 99.99.2.0/24     0.0.0.0                  0         32768 i
*> 99.99.3.0/24     116.1.23.3             0             0 3 i
*>i99.99.4.0/24     116.1.14.4               0    100      0 i

R3#sh ip bgp
BGP table version is 5, local router ID is 99.99.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
*> 99.99.1.0/24     116.1.23.2                           0 124 i
*> 99.99.2.0/24     116.1.23.2               0             0 124 i
*> 99.99.3.0/24     0.0.0.0                  0         32768 i
*> 99.99.4.0/24     116.1.23.2                             0 124 i

R2 has R3’s address set as Next_Hop for R3’s loopback interface, while R3 uses R2’s address for every route from AS124. R3 validates (valid > ) all routes from R2 because R3 knows the way to its Next_Hop address over the IGP table. The same applies for R3’s loopback interface on R2, but R1 does not have an entry in its IGP table to find a way to R3’s address 116.1.23.3:

R1#sh ip bgp
BGP table version is 4, local router ID is 99.99.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
*> 99.99.1.0/24     0.0.0.0                  0         32768 i
*>i99.99.2.0/24     116.1.12.2               0    100      0 i
>* i99.99.3.0/24     116.1.23.3              0    100      0 3 i
*>i99.99.4.0/24     116.1.14.4               0    100      0 i

R1#sh ip bgp 99.99.3.0
BGP routing table entry for 99.99.3.0/24, version 0
Paths: (1 available, no best path)
  Not advertised to any peer
  3
    116.1.23.3 (inaccessible) from 116.1.12.2 (99.99.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal

R1#sh ip route
Codes: 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

Gateway of last resort is not set

     116.0.0.0/24 is subnetted, 2 subnets
C       116.1.12.0 is directly connected, FastEthernet0/0
C       116.1.14.0 is directly connected, FastEthernet1/0
     99.0.0.0/24 is subnetted, 3 subnets
C       99.99.1.0 is directly connected, Loopback0
B       99.99.2.0 [200/0] via 116.1.12.2, 00:30:23
B       99.99.4.0 [200/0] via 116.1.14.4, 00:30:28

R1 does not advertise R3’s loopback interface to R4 since it does not have a valid path to R3’s loopback interface:

R4#sh ip bgp
BGP table version is 4, local router ID is 99.99.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
*>i99.99.1.0/24     116.1.14.1               0    100      0 i
*>i99.99.2.0/24     116.1.12.2               0    100      0 i
*> 99.99.4.0/24     0.0.0.0                  0         32768 i

To solve this problem, we configure the next-hop-self command on R2 so that every route R2 advertises into AS124 will have its address set as Next_Hop address:

R2#sh run | sec router bgp
 router bgp 124
 no synchronization
 bgp log-neighbor-changes
 network 99.99.2.0 mask 255.255.255.0
 neighbor 116.1.12.1 remote-as 124
neighbor 116.1.12.1 next-hop-self
 neighbor 116.1.23.3 remote-as 3
 no auto-summary

R2 now is the default Next_Hop for its and R3’s loopback interface. R1 and R4 do now have a valid path to the Next_Hop address of R2 and will validate the route to 99.99.3.0 in their BGP tables:

R1#sh ip bgp
BGP table version is 5, local router ID is 99.99.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
*> 99.99.1.0/24     0.0.0.0                  0         32768 i
*>i99.99.2.0/24     116.1.12.2               0    100      0 i
*>i99.99.3.0/24     116.1.12.2               0    100      0 3 i
*>i99.99.4.0/24     116.1.14.4               0    100      0 i

R4#sh ip bgp
BGP table version is 5, local router ID is 99.99.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
*>i99.99.1.0/24     116.1.14.1               0    100      0 i
*>i99.99.2.0/24     116.1.12.2               0    100      0 i
*>i99.99.3.0/24     116.1.12.2               0    100      0 3 i
*> 99.99.4.0/24     0.0.0.0                  0         32768 i

After that configuration R1 and R4 are also able to ping R3’s loopback interface, as long as the ping’s source address is one of their loopback addresses, because R3 only knows the loopback routes out of AS124:

R4#ping 99.99.3.3 source loopback 0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 99.99.3.3, timeout is 2 seconds:
Packet sent with a source address of 99.99.4.4
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 40/76/124 ms

Advertisements

4 comments

  1. Joe A

    Hey, very nice article. I was sort of struggling with this concept in my studies, and this really solidified some things for me. Thank You!

  2. David M

    This information was very easy to understand with the way you have it laid out. I appreciate the effort you put into the article. Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s