Internal BGP (Border Gateway Protocol) explained

Hello Karthick

The next-hop-self command is always used by an eBGP router when advertising a route it learned from its eBGP neighbor to its iBGP peers.

In this case:

  • R2 which is an eBGP neighbor with R1
  • is advertising a route it learned from R1 (eBGP neighbor)
  • with its iBGP peers, that is, R3 and R4

Why does it do this? Because if it does not, the next-hop IP will remain 192.168.12.1, which is the IP address of R1. Because R1 is in a different AS, none of the iBGP routers in AS2 know this next-hop address. It is not found in any of their routing tables. The next-hop must thus be replaced with the IP address of the eBGP router connecting to that AS which is R2.

So the next-hop-self command will only be used by routers that find themselves on the border of the AS. R3 is not at the border.

Why? Well, think about this. R2 is saying to the rest of the routers in AS2, that in order to reach 1.1.1.1, the next hop is me. This makes sense because 1.1.1.1 is in the AS directly connected to R2’s eBGP peering. When R3 receives this information, it has no reason to make itself the next hop for 1.1.1.1, because everyone in the AS can already reach R2 as the next hop.

I hope this has been helpful!

Laz