Understanding and experimenting with BGP next hop

Next hop The
router updates the BGP route to the ibgp neighbor. The next hop is unchanged by default. The next-hop-self can be used to modify the
router. The router updates the bgp route to the ebgp neighbor. The next hop is automatically updated to the source address of the router.
Third-party next hop (redirect)

r1 # traceroute 4.4.4.4                        
                                             
Type escape sequence to abort.               
Tracing the route to 4.4.4.4                 
                                             
  1 12.1.1.2 40 msec 40 msec 28 msec         
  2 100.1.1.4 [AS 100] 84 msec * 84 msec (R2 redirects the path)

r2#show ip bgp                                                                 
BGP table version is 10, local router ID is 2.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
r> 1.1.1.1/32 1.1.1.1 0 0 1 i 
*> 2.2.2.2/32 0.0.0.0 0 32768 i   
r> i3.3.3.3 / 32 3.3.3.3 0 100 0 i   
r> i4.4.4.4 / 32 3.3.3.3 0 100 0 4 i (However, it is still displayed as the 3.3.3.3 neighbor address in the BGP table)
*> 12.1.1.0/24 0.0.0.0 0 32768 i   
* i100.1.1. 0/24 3.3.3.3 0 100 0 i   
*> 0.0.0.0 0 32768 i   
router uses redirection to automatically define the next hop to R4 as the red interface of R2

The Next-Hop
attribute defines the IP address of the next hop of a certain prefix,
so the next hop must be a certain prefix in the routing table (including the default route 0.0.0.0/0)! The next hop attribute is usually set in 3 places. When the
prefix is ​​first injected into BGP, the next hop depends on the injection method
aggregate-address--0.0.0.0 (this router)
network / redistribute-the next hop address of the original route If the next hop address of the original route does not exist (pointing to null), this router will become the next hop of the BGP route! 0.0.0.0

This is a recognized mandatory attribute and describes the IP address of the next-hop router in the path to the published destination. The IP address described by the BGP NEXT_HOP attribute is not often the IP address of the neighbor router, and the following rules should be followed:
If the router that is performing route announcement and the receiving router are in different autonomous systems, NEXT_HOP is the IP of the router interface that is being announced Address, as shown in the figure below.

If the router that is performing route announcement and the receiving router are in the same AS, and the destination specified by the NLRI of the update message is also in the same AS, then NExT_HOP is the IP address of the neighbor who announced the route. As shown below.

If the advertising router and the receiving router are internal peers, and the NLRI of the update message indicates that the destination is in a different AS, NEXT_HOP is the IP address of the external peer entity that learned the route. As shown below.

It can be seen from the above figure that the path to the 192.168.5.0 network segment will be unreachable. The solution to this problem is to ensure that the internal router knows the external network connected to the two autonomous systems and can use static routing , But the actual approach is to run IGP in passive mode on the external port. But in some cases, this method is not ideal.
The second method is to use configuration options, this configuration option is called next-hop-self.
The following is a detailed description of the next hop unreachable solution: the
next hop unreachable solution:
1, static route
2, announced in the IGP where the IBGP neighbor is located
3, and redistribute the network directly connected with EBGP Enter IGP
4, neighbor xxxx next-hop-self (change the address pointing to the EBGP neighbor update source to its own update source address) (some versions of RR will change the next hop)
. Under normal circumstances, this router will directly The connected network introduces BGP, and the next hop is 0.0.0.0. The next hop of the route aggregated by this router is also 0.0.0.0.
When the route learned from IGP is imported into BGP on this router, look at the BGP forwarding table on this router, and the next hop is the next hop of the IGP route. In a multi-access network environment, establishing a neighbor relationship with a direct connection port will generate a third-party next hop.
Example description: as shown in the figure below,

R2 and R1 are IBGP neighbors, and R1 and R3 are EBGP neighbors. When a neighbor is established with a direct connection port, R2 introduces the BGP prefix 172.16.2.0/24. In the bgp forwarding table of R3, it will appear as R2's multi-access network Interface address (eg 10.1.1.2). The phenomenon of third-party next hop occurs.
-If R1, R2, and R3 all use direct connection ports to build neighbors, a third-party next hop will occur.
-If R1 and R2 use a loopback port and R1 and R3 use a direct connection to establish a neighbor, a third-party next hop will be generated.
-If R1 and R2 use direct connection and R1 and R3 use loopback ports, no third-party next hop will be generated, as shown in the following configuration.
-If R1, R2, and R3 all use the loopback port to establish neighbors, no third-party next hop will be generated, as shown in the following configuration.
R3 # show ip bgp
BGP table version is 4, local router ID is 172.16.3.1
Status codes: s suppressed, d damped, h history, * valid, & gt; best, i-internal,
r RIB-failure, S Stale
Origin codes : i-IGP, e-EGP,?-incomplete
Network Next Hop Metric LocPrf Weight Path
* & gt; 172.16.1.0/24 10.1.1.1 0 0 100 i
* & gt; 172.16.2.0/24 10.1.1.2 0 100 i
* & gt ; 172.16.3.0/24 0.0.0.0 0 32768 i

R1
router bgp 100
no synchronization
bgp log-neighbor-changes
network 172.16.1.0 mask 255.255.255.0
neighbor 3.3.3.3 remote-as 200
neighbor 3.3.3.3 ebgp-multihop 2
neighbor 3.3.3.3 update-source Loopback1
neighbor 10.1.1.2 remote-as 100
no auto-summary
R3
router bgp 200
no synchronization
bgp log-neighbor-changes
network 172.16.3.0 mask 255.255.255.0
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 ebgp-multihop 2
neighbor 1.1.1.1 update-source Loopback1
no auto-summary
R3#sh ip bgp
BGP table version is 8, local router ID is 172.16.3.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
*> 172.16.1.0/24 1.1.1.1 0 0 100 i
*> 172.16.2.0/24 1.1.1.1 0 100 i
*> 172.16.3.0/24 0.0.0.0 0 32768 i

R1
router bgp 100
no synchronization
bgp log-neighbor-changes
network 172.16.1.0 mask 255.255.255.0
neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 update-source Loopback1
neighbor 3.3.3.3 remote-as 200
neighbor 3.3.3.3 ebgp-multihop 2
neighbor 3.3.3.3 update-source Loopback1
no auto-summary
R2
router bgp 100
no synchronization
bgp log-neighbor-changes
network 172.16.2.0 mask 255.255.255.0
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 update-source Loopback1
no auto-summary
R3
router bgp 200
no synchronization
bgp log-neighbor-changes
network 172.16.3.0 mask 255.255.255.0
neighbor 1.1.1.1 remote-as 100
neighbor 1.1.1.1 ebgp-multihop 2
neighbor 1.1.1.1 update-source Loopback1
no auto-summary
R3 # sh ip bgp
BGP table version is 10, local router ID is 172.16.3.1
Status codes: s suppressed, d damped, h history, * valid, & gt; best, i-internal,
r RIB-failure, S Stale
Origin codes: i-IGP, e-EGP,?-incomplete
Network Next the Metric Weight LocPrf the Path Hop
* & gt; 172.16.1.0/24 1.1.1.1 0 0 100 I
* & gt; 0 100 I 172.16.2.0/24 1.1.1.1
* & gt; 0 32768 I 172.16.3.0/24 0.0.0.0
third party Next hop: When the source address of the received routing update and the interface address to be sent are on the same network segment, the next hop of the route does not change and is the source address of the original routing update.
Sometimes, although the next hop of the route is reachable, there may be a loop in the access network.
Example description:

R5-R3 and R1-R2 are EBGP neighbor relationships, and R1-R3 are IBGP neighbor relationships. Then R5 transmits the route to R3 through BGP (such as 10.1.1.0/24), R3 transmits it to R1 through IBGP, and R1 transmits it to R2 through EBGP. At this time, the next hop for R2 to access the network 10.1.1.0/24 is R1 on. At this time, when R2 visits R5, a loop will occur.
Then R2 (going to the next hop)-R1 (going to the physical link)-R2, so the loop is generated.
Solution:
neighbor xxxx next-hop-unchanged? (This command can only be used in an EBGP multi-hop environment to change the next hop of the route from its own updated source address to the next hop address learned from IBGP) (The next hop of the route will change in the routing table at this time.)
Neighbor xxxx route-map XX {in | out} Then set ip next-hop in the route-map to change the next hop of the prefix. (The next hop will change in the routing table.)
Policy routing PBR, forcing R2 to 10.1.1.0/24 to go to R3. (The next hop in the routing table will not change)

Published 220 original articles · won praise 2 · Views 4463

Guess you like

Origin blog.csdn.net/qq_43207781/article/details/105503722
BGP