cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1205
Views
10
Helpful
5
Replies

With Prepending, adding next-hop-self chooses iBGP over eBGP

Hamed Karimi
Level 1
Level 1

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?

 

q.PNG

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:

qq.PNG

 

After adding next-hop-self:

QQQ.PNG

 

1 Accepted Solution

Accepted Solutions

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

HTH,
Meheretab

View solution in original post

5 Replies 5

Alex Pfeil
Level 7
Level 7

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

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


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul

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.

 

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

HTH,
Meheretab

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)


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Review Cisco Networking products for a $25 gift card