BGP outbound metric

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.

__

It doesn’t make sense to set bgp-weight in the output, it is local to the router and is never sent out.

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

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.

Does bgp-med increase outbound metric?

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

What result are you trying to achieve?

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

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…

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

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”

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”

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.

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

set bgp-med (for iBGP out-filter) still doesn’t work in v7.16. When it will be?

Because you should use bgp-out-med for output chain

set bgp-out-med for eBGP.
set bgp-med for iBGP.

That's according to mikrotik user guide.
Btw I tried both for iBGP and doesn't work at all