09-16-2019 09:36 AM
Hey Guys
In the below diagram, I have path prepending between R2 and R3. But still, R2 for reaching the 8.8.8.8/32 chooses R3 as it is eBGP.
But when I add next-hop-self on R1 and R2, R2 choose R1 to reach 8.8.8.8. Why?
R1#sh run | sec bg
router bgp 100
bgp log-neighbor-changes
neighbor 10.10.10.2 remote-as 200
neighbor 10.50.50.2 remote-as 100
----------------------
router bgp 100
bgp log-neighbor-changes
neighbor 10.50.50.1 remote-as 100
neighbor 20.20.20.2 remote-as 200
----------------------
R3#sh run | sec bg
router bgp 200
bgp log-neighbor-changes
network 8.8.8.8 mask 255.255.255.255
neighbor 10.10.10.1 remote-as 100
neighbor 20.20.20.1 remote-as 100
neighbor 20.20.20.1 route-map a out
----
route-map a permit 10
match ip address prefix-list a
set as-path prepend 200 200 200
Here is the output:
After adding next-hop-self:
Solved! Go to Solution.
09-16-2019 10:54 AM
Hi Hamed,
On BGP best path selection criteria, Weight > Local Preference > Locally originated path > AS Path > Origin Type > MED > eBGP over iBGP > ... In you case, R2 learned about 8.8.8.8/32 from both R1 (iBGP) and R3 (eBGP). When you prepend as-path, the iBGP route is preferred (as far as the next-hop is reachable from R2 -- which is resolved by adding "next-hop-self" command) over the eBGP route.
Please look at the following link for BGP Best Path Selection: https://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/13753-25.html
HTH,
Meheretab
09-16-2019 09:48 AM - edited 09-16-2019 10:32 AM
The route to 8.8.8.8 through router 1 is not accessible to router 2 until you place the next-hop-self command on the neighbor statements between 1 and 2. This is because router 1 does not have a route to 20.20.20.2 and router 2 does not have a route to 10.10.10.2.
Router 3 is sending a route to router 1 with the next-hop of 10.10.10.2.
Router 3 is sending a router to router 2 with the next-hop of 20.20.20.2.
Router 2 has a route for 20.20.20.2 and it is therefore the best.
When you add next-hop-self, router 1 sends update to router 2 saying to get to 8.8.8.8, go to 10.50.50.1. Router 2 can get there now, and it updates the routing table.
Hope this explanation helps.
Thanks,
Alex
09-16-2019 10:26 AM - edited 09-16-2019 10:43 AM
Hello
@Hamed Karimi wrote:
Hey Guys
In the below diagram, I have path prepending between R2 and R3. But still, R2 for reaching the 8.8.8.8/32 chooses R3 as it is eBGP.
But when I add next-hop-self on R1 and R2, R2 choose R1 to reach 8.8.8.8. Why?
The reason looks like being the next-hop to that prefix, As before you added the next-hop self command it was R1's external subnet being advertised and R2 didn't have a valid reachable next-hop for that subnet but it did after next-hop self was added as it then used the connected subnet between R1-R2.
As a valid reachable next-hop is required for a route to be included in the rib this will take precedence of weight in path selection
R2
show ip route
09-16-2019 10:34 AM
After adding next-hop-self, if I remove AS prepending on R3, R2 will choose R3.
So in brief, With having AS prepending on R3 and next-hop-self on R2 and R1, R2 will choose R1, but if I remove prepending or next-hop-self, it will choose R3. I was expecting to always choose R3 as it is eBGP over iBGP.
09-16-2019 10:54 AM
Hi Hamed,
On BGP best path selection criteria, Weight > Local Preference > Locally originated path > AS Path > Origin Type > MED > eBGP over iBGP > ... In you case, R2 learned about 8.8.8.8/32 from both R1 (iBGP) and R3 (eBGP). When you prepend as-path, the iBGP route is preferred (as far as the next-hop is reachable from R2 -- which is resolved by adding "next-hop-self" command) over the eBGP route.
Please look at the following link for BGP Best Path Selection: https://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/13753-25.html
HTH,
Meheretab
09-16-2019 11:03 AM - edited 09-16-2019 11:39 AM
Hello
@Hamed Karimi wrote:After adding next-hop-self, if I remove AS prepending on R3, R2 will choose R3.
So in brief, With having AS prepending on R3 and next-hop-self on R2 and R1, R2 will choose R1, but if I remove prepending or next-hop-self, it will choose R3. I was expecting to always choose R3 as it is eBGP over iBGP.
Neighbor type is quite far down the path selection of bgp if that what your asking but it was selected before you added the next-hop-self command because the as-path didn't come into play until then due to a non valid reachable next-hop?
1) removing prepending and no next-hop-self - and all things equal the result will be R2-R3 neighbor type
2) Adding just pre-pending = R2-R3 neighbor type due to unreachable next-hop
3) Adding just next-hop self = R2-R3 neighbor type
4) Adding pre-pending and next-hop-self =R2-R1 shortest as-path (as seq) next-hop now reachable
Next hop (reachable)
weight (highest)
local pref (highest)
locally originated routes
as-path
origin
med (lowest)
neighbor type
igp metric (lowest)
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide