This blog article describes how to modify the next hop attribute value of NEXT_HOP through BGP, including modifying the next-hop attribute through next-hop-self, use route-map to modify the NEXT_HOP attribute values of BGP routes.
1. You can change the next-hop attribute through next-hop-self.
When R5 is updated to the EBGP neighbor R2 BGP Route 5.5.5.0, NEXT_HOP = 192.168.25.5, this attribute will always follow this BGP Route in AS234, then for R4 and R3, you do not know how to go to 192.168.25.5. Therefore, the route table of 5.5.5.0 cannot be loaded normally. One solution is that R2 injects the 25.0 external route into the IGP route, and the other method is that R2 uses next-hop-self for its IBGP neighbor to modify the NEXT_HOP attribute of the prefix.
NEXT_HOP on shared Media (operations on shared Media)
RouterB transmits route 100.100.100.0/24 to A, and NEXT_HOP is 10.1.123.2;
Route 100.100.100.0/24 to C. At this time, NEXT_HOP remains unchanged;
If the router receives a BGP Route, The NEXT_HOP address value of the route belongs to the same network segment as the interface IP address (update source) of the router, the NEXT_HOP address of the route will remain unchanged and be passed to it (the BGP peers in the same network segment). This is actually an optimization mechanism, but is there a problem with this mechanism in the NBMA environment?
NEXT_HOP on NMBA network
Still, if the intermediate network is not a Broadcasting Multi-channel access network, but a frame relay network, you should note that the route received by C, NEXT_HOP is 10.1.123.2, if the PVC of the IP address is not found on the C router, a problem may occur, so this should be taken into consideration.
2. Use route-map to modify the NEXT_HOP attribute value of a BGP route
The R1-R2 establishes the iBGP Neighbor Relationship Based on Loopback. The R2-R3 establishes the eBGP neighbor relationship based on the direct connection interface. By default, the next hop attribute value of Route 11.0/24 advertised by R1 to R2 is 1.1.1.1, that is, the update source IP address of R1. When R2 updates the route to the eBGP neighbor R3, the NH of the route is changed to 10.1.23.2,
Add configuration on R2
Access-list 1 permit 11.11.11.0
Route-map test permit 10
Match ip address 1
Set ip next-hop 10.1.23.99
Router bgp 12
Neighbor 10.1.23.3 route-map test out
By deploying route-map in the out direction on R2, you can modify the NEXT_HOP attribute value of the BGP route passed to R3. Of course, the above example sets 10.1.23.99 without any meaning, it's just a test.
3. About the BGP next-hop-unchanged feature
Another feature that can affect the value of the BGP NEXT_HOP attribute is the BGP next-hop-unchanged feature.
First, this command can only be configured for multi-hop eBGP peer. Therefore, R2 and R3 need to establish Loopback-based eBGP neighbor relationships to form multihop eBGP peer.
When R2 receives the route 11.0/24 from the iBGP peer, its NEXT_HOP attribute value is 1.1.1.1. For example, R2 uses the neighbor 3.3.3.3 next-hop-unchanged configuration in the BGP process, when R2 passes the BGP Route to the eBGP neighbor R3, The NEXT_HOP attribute value of the route will not change.
Perform another test to change the topology environment:
The R1-R2 is transformed into the eBGP neighbor, and the eBGP neighbor relationship is established based on the direct connection interface;
The multi-hop eBGP Neighbor Relationship Between R2-R3 is still established based on Loopback;
Now, when the value of NEXT_HOP transmitted from R1 is 10.1.12.1 on R2 and R2 passes the route to R3 by default, the NEXT_HOP attribute value of the route is changed to 2.2.2.2, that is, the update source IP address of R2.
If neighbor 3.3.3.3 next-hop-unchanged is configured on R2 at the moment, we find that the command is invalid. The NEXT_HOP attribute value advertised by R2 to R3 will change and 10.1.12.1 will not be retained.
Therefore, I come to the conclusion that the BGP neighbor next-hop-unchanged command can only be configured for multi-hop eBGP neighbors, and secondly, it takes effect only when the local iBGP route is passed to its eBGP multi-hop neighbor.