Friday, 15 June 2012

BGP: Understanding Next-hop address

BGP: Understanding Next-hop address
R1------------iBGP---------------R2----------------eBGP----------------R3
R1: S1/0:10.1.1.1  ------------- R2: S1/0:10.1.1.2
R2: S1/1:20.1.1.2  -------------R3: S1/1:20.1.1.3

AS 100: R1, R2
AS 200: R3
·        I  have iBGP between R1 and R2
·         eBGP between R2 and R3
·         R3 is advertising its loopback 3.3.3.3/32 into BGP
·         R1 is advertising its loopback11 11.11.11.11/32 into BGP

Let’s see how Next-hop value is changed between iBGP and eBGP:

BGP Configs:

R2(config-router)#do show run | begin router bgp 100
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor 10.1.1.1 remote-as 100
 neighbor 20.1.1.3 remote-as 200
 no auto-summary
!

R1(config-router)#do show run | begin router bgp 100
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 11.11.11.11 mask 255.255.255.255
 neighbor 10.1.1.2 remote-as 100
 no auto-summary
!

R3(config)#do show run | begin router bgp 200
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 network 3.3.3.3 mask 255.255.255.255
 neighbor 20.1.1.2 remote-as 100
 no auto-summary
!

Verifying the BGP Neighbor relationship:

R2#show ip bgp sum
BGP router identifier 22.22.22.22, local AS number 100
BGP table version is 9, main routing table version 9
2 network entries using 234 bytes of memory
2 path entries using 104 bytes of memory
3/2 BGP path/bestpath attribute entries using 372 bytes of memory
1 BGP AS-PATH entries using 24 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 734 total bytes of memory
BGP activity 3/1 prefixes, 3/1 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.1.1.1        4   100      27      27        9    0    0 00:21:40        1
20.1.1.3        4   200      25      29        9    0    0 00:21:08        1
R2#

Observations:

·         R2 is part of AS 100
·         R2 has one iBGP neighbor
·         R2 has one eBGP neighbor, which is in AS200
·         Both the neighbors are Up.
·         R2 is learning one Prefix from each neighbor.

R1#show ip bg
*Jun 15 16:32:31.747: %SYS-5-CONFIG_I: Configured from console by console
R1#show ip bgp sum
BGP router identifier 111.111.111.111, local AS number 100
BGP table version is 6, main routing table version 6
2 network entries using 234 bytes of memory
2 path entries using 104 bytes of memory
3/2 BGP path/bestpath attribute entries using 372 bytes of memory
1 BGP AS-PATH entries using 24 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 734 total bytes of memory
BGP activity 3/1 prefixes, 3/1 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.1.1.2        4   100      27      27        6    0    0 00:21:58        1
R1#

Observations:
·         R1 is part of AS 100
·         R1 has one iBGP neighbor
·         Neighbor is UP.
·         R1 is learning one Prefix from its neighbor

R3#show ip bgp sum
BGP router identifier 133.133.133.133, local AS number 200
BGP table version is 5, main routing table version 5
2 network entries using 234 bytes of memory
2 path entries using 104 bytes of memory
3/2 BGP path/bestpath attribute entries using 372 bytes of memory
1 BGP AS-PATH entries using 24 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 734 total bytes of memory
BGP activity 3/1 prefixes, 3/1 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
20.1.1.2        4   100      29      25        5    0    0 00:21:43        1
R3#

Observations:

·         R3 is in AS 200.
·         R3 has one eBGP neighbor, which is in AS100
·         Neighbor is UP
·         R3 is learning one Prefix from the neighbor.

Now, let’s see the BGP Routing table on the routers.

R3#show ip bgp
BGP table version is 5, local router ID is 133.133.133.133
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
*> 3.3.3.3/32       0.0.0.0                  0         32768 i
*> 11.11.11.11/32   20.1.1.2                               0 100 i
R3#
Observations:

·         R3 has two prefixes in the BGP table
·         Prefix 3.3.3.3/32 is locally generated, (Next Hop 0.0.0.0 means locally generated)
·         Prefix 11.11.11.11/32 is learnt from eBGP neighbor and it has Next-hop address as 20.1.1.1
·         Both the routes are the Best routes, observe the symbol “>” for the prefixes.

R2#show ip bgp
BGP table version is 9, local router ID is 22.22.22.22
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
*> 3.3.3.3/32       20.1.1.3                 0             0 200 i
*>i11.11.11.11/32   10.1.1.1                 0    100      0 i
R2#

Observations:

·         R2 has 2 prefixes in the BGP table
·         Prefix 3.3.3.3/32 is learnt from the eBGP neighbor and has Next-hop address 20.1.1.3
·         Prefix 11.11.11.11/32 is iBGP learned route, hence the “I” symbol for the prefix.
·         Prefix 11.11.11.11/32 has Next-hop value 10.1.1.1
·         Both the routes are the Best routes, observe the symbol “>” for the prefixes.

R1#show ip bgp
BGP table version is 6, local router ID is 111.111.111.111
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
* i3.3.3.3/32       20.1.1.3                 0    100      0 200 i
*> 11.11.11.11/32   0.0.0.0                  0         32768 i
R1#

Observations:

·         R1 has 2 prefixes
·         Prefix 11.11.11.11/32 is locally generated, (Next Hop 0.0.0.0 means locally generated)
·         Prefix 3.3.3.3/32 is an iBGP learned prefix, which has a Next-hop address 20.1.1.3
·         Only 11.11.11.11/32 is the best path in the BGP table


We should conclude the following from the BGP behaviour:

1.  When a BGP Router is passing an iBGP update to an eBGP neighbor, it automatically changes the next-hop to itself.
2.  But, when a BGP router is passing an eBGP update to an iBGP neighbor, next-hop address is not modified.
3.  If next-hop address is not reachable, route will not be installed in the BGP table.

·         Because of the Point-1, when R2 sent an eBGP update to R3 for 11.11.11.11, it changed the next-hop value to its peering address with R3.
·         For this reason, though R2 has 10.1.1.1 as next-hop address for the prefix 11.11.11.11/32, R3 has 20.1.1.2 as next-hop address.
·         And 20.1.1.2 is reachable for R3, as it is a connected interface and thus this prefix 11.11.11.11/32 is marked as the best route in the BGP routing table

·         Because of point-2, when R2 sent an iBGP update for 3.3.3.3/32, it didn’t change the next-hop address.
·         For this reason, both R2 and R1 has next-hop address as 20.1.1.3
·         And 20.1.1.3 is not reachable for R1 and thus the prefix is not selected as the Best route in the BGP routing table.

Solution to this problem:

·         Configure a next-hop-self for the iBGP neighbor on R2
·         Once we configure this command on R2 towards R1, R2 will change the next-hop address to its peering address when it is sending the eBGP update towards R1.

·         Advertise the link between R2-R3 into IGP (ospf etc), so that R1 can reach 20.1.1.3

·         Advertise the link between R2-R3 into BGP, so that R1 can reach 20.1.1.3


Let’s configure Next-hop-self command on R2 and see what happens:

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



R1#show ip bgp
BGP table version is 7, local router ID is 111.111.111.111
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
*>i3.3.3.3/32       10.1.1.2                 0    100      0 200 i
*> 11.11.11.11/32   0.0.0.0                  0         32768 i
R1#

Observations:

·         Next-hop address for 3.3.3.3/32 is changed to 10.1.1.2 (peering addrees for R2)
·         Since the next-hop address is reachable, the route became Bext route in the BGP table.

R1#ping 3.3.3.3 source 11.11.11.11

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
Packet sent with a source address of 11.11.11.11
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 44/65/80 ms
R1#

R3#ping 11.11.11.11 source 3.3.3.3

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 11.11.11.11, timeout is 2 seconds:
Packet sent with a source address of 3.3.3.3
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 64/72/108 ms
R3#


Let’s see the IP Routing table on R1:

R1#show 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

     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
O       2.2.2.2 [110/65] via 10.1.1.2, 01:03:57, Serial1/0
     3.0.0.0/32 is subnetted, 1 subnets
B       3.3.3.3 [200/0] via 10.1.1.2, 00:04:11
     111.0.0.0/32 is subnetted, 1 subnets
C       111.111.111.111 is directly connected, Loopback111
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Serial1/0
     11.0.0.0/32 is subnetted, 1 subnets
C       11.11.11.11 is directly connected, Loopback11
R1#

Observations:

·         All IGP learned routes are automatically recursed to the interface in the IP Routing table
·         But, BGP route 3.3.3.3 is not automatically recursed to the interface, this is because BGP is a logical TCP connection between the neighbors which runs over IGP.

No comments:

Post a Comment