Thursday, January 15, 2026

Re: bgpd: set nexthop self only for ebgp routes

On Mon Jan 12, 2026 at 12:17 PM CET, Stuart Henderson wrote:
> On 2026-01-11, Remi Locherer <remi.locherer@relo.ch> wrote:
>> Hi,
>>
>> For a BGP route reflector setup I want to set next hop self
>> towards iBGP peers. But only for routes learnt through eBGP.
>>
>> In the RIB I can see this:
>>
>> dut# bgpctl sh rib det 172.0.42.0/24
>>
>> BGP routing table entry for 172.0.42.0/24
>> Nexthop 10.100.0.10 (via 10.1.0.2) Neighbor r1 (10.100.0.10)
>> Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, avs unknown, internal, valid, best
>> ^^^^^^^^
>> Last update: 00:58:22 ago
>> Originator Id: 10.100.0.10
>> Cluster Id List: 10.0.0.42
>>
>> BGP routing table entry for 172.0.42.0/24
>> Nexthop 10.100.0.10 (via 10.1.0.2) Neighbor rr2 (10.100.0.2)
>> Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, avs unknown, internal, valid, ecmp
>> ^^^^^^^^
>> Last update: 00:58:24 ago
>> Originator Id: 10.100.0.10
>> Cluster Id List: 10.0.0.42 10.0.0.43
>>
>> BGP routing table entry for 172.0.42.0/24
>> 65101 65000
>> Nexthop 10.1.0.14 (via 10.1.0.14) Neighbor x1 (172.42.42.1)
>> Origin IGP, metric 0, localpref 100, weight 0, ovs not-found, avs unknown, external
>> ^^^^^^^^
>> Last update: 00:58:24 ago
>> Originator Id: 10.100.0.1
>> Cluster Id List: 10.0.0.42
>> dut#
>>
>> With "set nexthop self" for a given neighbor the nexthop is changed
>> unconditinally for this neighbor. How can I match only on external
>> routes?
>
> I have this, is that what you're after? (obviously skip the community
> setting if you don't want it).
>
> match from ebgp set { community $ASN:neighbor-as, nexthop self }

I was looking for a way to define it per peer. But actually it works fine
with "match from ebgp ...".

Thank you!

No comments:

Post a Comment