Community discussions

MikroTik App
 
kerfuffle
just joined
Topic Author
Posts: 16
Joined: Wed Feb 22, 2023 6:50 am
Location: San Francisco, CA
Contact:

BGP MED - ROS v7.7

Wed Feb 22, 2023 7:09 am

In my network, i've got two PE (PR1 and PR2) routers each with a transit and some peering attached. They both connect to a core router (CR1) which in turn connects to multiple access routers (It advertises these a default).

Despite the transit on PR2 having a lower med, when all things are equal (Path length, local pref etc) routes are continually preferred toward PR1 - seemingly because it has a lower routerID or the BGP session has been up longer. I'd be expecting routes toward PR2 to be taking preference, when everything else is equal and the MED becomes the tie breaker.

As you can see here. Below is the output from my route collector (Sorry, but ROS7 is almost unusable for any type of bgp troubleshooting) which shows PR1 (.1) PR2 (.2) and the view of the CR1 (.3) at the end. You can clearly see PR2 there has a med of 0, and PR1 has a med of 10. The CR1 router is seeing the best path as the route with a med of 10.
6939 6939 13414 13414
    184.105.X.X from 194.X.X.1 (194.X.X.1)
      Origin IGP, metric 10, localpref 90, invalid, internal, atomic-aggregate
      Last update: Tue Feb 21 20:11:05 2023
  47787 1299 13414 13414
    193.109.X.X from 194.X.X.2 (194.X.X.2)
      Origin IGP, metric 0, localpref 90, invalid, internal, atomic-aggregate
      Last update: Tue Feb 21 20:17:18 2023
  6939 6939 13414 13414
    194.X.X.17 from 194.X.X.3 (194.X.X.3)
      Origin IGP, metric 10, localpref 90, invalid, internal, atomic-aggregate
      Last update: Tue Feb 21 20:08:59 2023

On the CR1 box directly you can see both routes, with the one to PR2 being inactive (.21 as the next hop).
[user@cr1] /ip/route> print detail where dst-address=104.244.42.0/24
Flags: D - dynamic; X - disabled, I - inactive, A - active; c - connect, s - static, r - rip, b - bgp, o - ospf, d - dhcp, v - vpn, m - modem, y - copy; H - hw-offloaded; + - ecmp
   DAb   dst-address=104.244.42.0/24 routing-table=main gateway=194.X.X.17 immediate-gw=194.X.X.17%sfp-sfpplus1 distance=200 scope=40 target-scope=30 suppress-hw-offload=no

   D b   dst-address=104.244.42.0/24 routing-table=main gateway=194X.X.21 immediate-gw=194.X.X.21%sfp-sfpplus2 distance=200 scope=40 target-scope=30 suppress-hw-offload=no

This seems to be the behavior for prefixes with multiple ASNs in the path at least.

However, if I pick a route i'm learning from a peer (With a single ASN in the path e.g. originated by the ASN I'm peering with), I can successfully move the active route between the two PR routers on the CR by modifying the MED. The specific context here is where I have the same external network connected via two Internet Exchanges, one into PR1 and one into PR2.

Worth noting that between the PR1, PR2 and CR1 this is iBGP route reflection (CR1 is the RR)

I noted in the route selection algo that MED is only considered for the left most ASN in the path - which confirms what I'm seeing above. Different to other router vendors which is a shame (Cisco and Juniper both compare MED for iBGP peers regardless of AS_PATH).

Is there a recommended way to overcome this? Allowing me to select the transit on the second router, when everything else is equal (e.g. use transit 1 when the AS_PATH is shorter - so simply changing LOCAL_PREF isn't a solution here since that'd ignore AS_PATH etc). Or do I really have to break the network, and make the connections between the PR and CR devices eBGP so MED is taken into consideration regardless of path - or be really crazy, and physically move the preferred transit to the lower routerID device
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7188
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: BGP MED - ROS v7.7

Thu Feb 23, 2023 1:29 am

That is not entirely true. Cisco by default works similarly. You have to explicitly enable "bgp always-compare-med".

Read more here:
https://www.cisco.com/c/en/us/support/d ... p-med.html

RouterOS currently do not have such options to play with.
 
kerfuffle
just joined
Topic Author
Posts: 16
Joined: Wed Feb 22, 2023 6:50 am
Location: San Francisco, CA
Contact:

Re: BGP MED - ROS v7.7

Thu Feb 23, 2023 9:58 am

For now, I've made the router with the preferred transit have a lower routerID, which whilst a complete bodge has enabled mostly what I'm looking todo. Any plans to implement a Cisco like option, to allow the user to choose how MED works on iBGP, so it matches eBGP?

Is there a roadmap for BGP features I can read? The BGP support on these things is pretty lacking at times (To see received routes from a peer, or advertised routes and all of their attributes such as communities etc).
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7188
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: BGP MED - ROS v7.7

Thu Feb 23, 2023 10:04 am

You already can see routes received by specific peer before and after filters and all the attributes. See /routing/route menu
 
kerfuffle
just joined
Topic Author
Posts: 16
Joined: Wed Feb 22, 2023 6:50 am
Location: San Francisco, CA
Contact:

Re: BGP MED - ROS v7.7

Thu Feb 23, 2023 7:26 pm

Example? I don’t see communities or AS_PATH in there, even when specifying “detail”

Any roadmap for BGP features you can share? The forum is peppered with inconsistencies between V4 and V6, and eBGP vs iBGP - I’ve got mostly everything I want working, RTBH, Customer communities, RPKI - happy to document and share if that’s useful along with some of the issues I’ve found too.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7188
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: BGP MED - ROS v7.7

Thu Feb 23, 2023 11:29 pm

I do not know why you cannot see bgp parameters unless those routes are not BGP routes"
[admin@dr_05] > /routing/route/print detail 
Flags: X - disabled, F - filtered, U - unreachable, A - active; 
c - connect, s - static, r - rip, b - bgp, o - ospf, d - dhcp, v - vpn, m - modem, a - ldp-address, l - ld>
H - hw-offloaded; + - ecmp, B - blackhole 

 Ab   afi=ip4 contribution=active dst-address=1.0.7.0/24 routing-table=main gateway=10.155.101.1 
       immediate-gw=10.155.101.1%ether1 distance=20 scope=40 target-scope=10 
       belongs-to="bgp-IP-10.155.101.217" 
       bgp.peer-cache-id=*B000002 .as-path="65530,100,6939,4826,38803" .atomic-aggregate=no .origin=igp 
       debug.fwp-ptr=0x20242BA0 

 Ab   afi=ip4 contribution=active dst-address=1.0.64.0/18 routing-table=main gateway=10.155.101.1 
       immediate-gw=10.155.101.1%ether1 distance=20 scope=40 target-scope=10 
       belongs-to="bgp-IP-10.155.101.217" 
       bgp.peer-cache-id=*B000002 .aggregator="18144:219.118.225.18" 
       .as-path="65530,100,24482,7670,18144" 
       .communities=24482:2,24482:65301,0:6939,19996:19996,0:7522,0:17511,24482:13010,24482:13011,0:7679 
       .ext-communities=rt:24482:310 .atomic-aggregate=no .origin=igp 
       debug.fwp-ptr=0x20242BA0 

Who is online

Users browsing this forum: No registered users and 9 guests