BGP route filtering

We are switching to Microtik for our BGP router and we are currently using OpenBGPD. Mostly things are pretty straight forward when switching over but there are some differences I can’t seem to wrap my head around. For example, we have the following route filters on OpenBGPD:

match from group “group1” source-as AS 1234 set {localpref +150}
match from group “group1” transit-as AS 1234 set {localpref +50}

source-as being the rightmost AS number and transit-as being all but the rightmost AS number.

Is there any way to do this on RouterOS? I know you can do multiple rules per chain, but I can’t seem to figure out how this could be done.

There unfortunately isn’t a + or - operator, so you need to set local preference explicitly.


/router filter add bgp-as-path="^(111_)+(222_)+$" set-bgp-local-pref=150

as111 is transit and as222 origin


"_222$"

Originated by as222


"_111_"

Transits as111

You need to escape out $ via cli, eg:

bgp-as-path="^(111_)+(222_)+\$"