Community discussions

MikroTik App
 
jayray
just joined
Topic Author
Posts: 8
Joined: Tue Nov 02, 2021 3:44 pm

BGP outbound metric

Mon Nov 15, 2021 9:00 am

How to add/cost outbound bgp advertisements on v7.rc6? I see in route filters "set bgp-weight " but it doesn't accept any string to the parameter such as "20" or "+20". That is all I could find that would possibly do outbound costing. Thanks for the help.

__
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7053
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: BGP outbound metric

Mon Nov 15, 2021 10:18 am

It doesn't make sense to set bgp-weight in the output, it is local to the router and is never sent out.
 
jayray
just joined
Topic Author
Posts: 8
Joined: Tue Nov 02, 2021 3:44 pm

Re: BGP outbound metric

Mon Nov 15, 2021 5:27 pm

I get that, but some things are labeled differently in routeros.. I'm looking for the equivalent of "set metric +XX" to be applied outbound
 
User avatar
StubArea51
Trainer
Trainer
Posts: 1739
Joined: Fri Aug 10, 2012 6:46 am
Location: stubarea51.net
Contact:

Re: BGP outbound metric

Mon Nov 15, 2021 5:45 pm

If MED is what you're trying to set, this should be the syntax:

routing/filter/rule/add chain=test rule="if (dst==200:7ac0:cafe::/48) {set bgp-med 30;accept}"

As MRZ noted, this metric is used by the peer ASN to determine the best inbound path.

If you're trying to adjust traffic leaving your ASN, then you want to look at attributes like localpref on received routes.
 
jayray
just joined
Topic Author
Posts: 8
Joined: Tue Nov 02, 2021 3:44 pm

Re: BGP outbound metric

Mon Nov 15, 2021 6:22 pm

Does bgp-med increase outbound metric?
 
User avatar
StubArea51
Trainer
Trainer
Posts: 1739
Joined: Fri Aug 10, 2012 6:46 am
Location: stubarea51.net
Contact:

Re: BGP outbound metric

Mon Nov 15, 2021 6:25 pm

What does the term outbound mean to you? outbound traffic or outbound advertised routes?

What result are you trying to achieve?
 
jayray
just joined
Topic Author
Posts: 8
Joined: Tue Nov 02, 2021 3:44 pm

Re: BGP outbound metric

Mon Nov 15, 2021 6:38 pm

Outbound route advertisement. On every implementation of bgp I am using, an outbound filter can attach a cost to the outbound BGP route that is received and applied to the inbound route on the destination peer. This is implemented in zebra/quagga/frr/cisco/junos. I'm sure I'm just not finding the correct config terms... Below is a sample from quagga

route-map MESH2-OUT permit 10
match ip address 19
set metric +80
 
User avatar
StubArea51
Trainer
Trainer
Posts: 1739
Joined: Fri Aug 10, 2012 6:46 am
Location: stubarea51.net
Contact:

Re: BGP outbound metric

Mon Nov 15, 2021 11:43 pm

Then we are talking about the same BGP attribute which is BGP MED. The config I posted above when applied to an outbound peering should work.

From the Quagga Docs....

Image
 
jayray
just joined
Topic Author
Posts: 8
Joined: Tue Nov 02, 2021 3:44 pm

Re: BGP outbound metric

Tue Nov 16, 2021 12:09 am

Using both bgp-out-med and bgp-med doesn't change the metric received on the other device. I've tried using the following filters.

rule="if (dst in 0.0.0.0/0 && dst-len == 0) {set bgp-out-med +60; accept}"
rule="if (dst in 0.0.0.0/0 && dst-len == 0) {set bgp-med +60; accept}"

Network Next Hop Metric LocPrf Weight Path
* 0.0.0.0 10.0.0.2 0 XXX02 i

Where other devices are sending a metric:

Network Next Hop Metric LocPrf Weight Path
* 0.0.0.0 10.0.0.2 0 XXX02 i
* 10.0.0.7 40 0 XXX01 i
* i 10.0.0.107 10 300 0 XXX00 i
*> 10.0.0.5 20 400 0 XXX00 i
 
jayray
just joined
Topic Author
Posts: 8
Joined: Tue Nov 02, 2021 3:44 pm

Re: BGP outbound metric

Tue Nov 16, 2021 9:49 pm

setting any of the following does not work. I think this is a v7 bug, as it works in v6 with no issues.


add chain=bgp-out-to-core disabled=no rule="if (dst in 0.0.0.0/0 && dst-len == 0) {set bgp-out-med +60; accept}"
add chain=bgp-out-to-core disabled=no rule="if (dst in 0.0.0.0/0 && dst-len == 0) {set bgp-med +60; accept}"
add chain=bgp-out-to-core disabled=no rule="set bgp-med +60; accept"
add chain=bgp-out-to-core disabled=no rule="set bgp-out-med +60; accept"
 
jayray
just joined
Topic Author
Posts: 8
Joined: Tue Nov 02, 2021 3:44 pm

Re: BGP outbound metric

Tue Nov 16, 2021 11:17 pm

The below works. The filters work on match once principal, so it was matching on bgp-med and then not following the next test filter.


add chain=bgp-out-to-core disabled=no rule="if (dst in 0.0.0.0/0 && dst-len == 0) {set bgp-out-med 60; accept}"
add chain=bgp-out-to-core disabled=no rule="set bgp-out-med 60; accept"
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7053
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: BGP outbound metric

Wed Nov 17, 2021 10:47 am

There is a difference between "set bgp-out-med 60" and "set bgp-out-med +60".

The first one sets the MED value to 60,
the second one tries to get the current med value and add 60 to it, but if the value does not exist, then it will not do anything.
 
maxfava
Member Candidate
Member Candidate
Posts: 225
Joined: Mon Oct 17, 2005 12:30 am

Re: BGP outbound metric

Sun Nov 26, 2023 8:53 pm

I noted that bgp-med does not work in iBGP
any idea?

Who is online

Users browsing this forum: No registered users and 10 guests