BGP when to use next-hop-self
When implementing BGP, the next-hop-self
keyword is added to the neighbor
command to change the next hop IP address for a particular prefix to the router itself.
The next-hop-self command is typically used by an eBGP router when advertising a route it learned from its eBGP neighbor to its iBGP peers.
Why does it do this? Because if it does not, the next-hop IP will be the IP address of the eBGP peer, which is in another AS, and its IP address is unknown within the local AS.
You could advertise the network that contains the IP address of the next hop in BGP with the network
command or replace the next-hop with the next-hop-self
command instead. The next hop will then become the IP address of the eBGP router that connects to the remote AS and which advertises the network to iBGP neighbors.