Skip to main content

โšก BFD Failover

Bidirectional Forwarding Detection (BFD) provides subโ€‘second link failure detection for OSPF, BGP, and static routes. This guide enables BFD on MikroTik RouterOS v7 to achieve faster failover and smoother reconvergence.

info

BFD works best on pointโ€‘toโ€‘point links and stable transport. Use conservative timers if you have noisy links or high CPU usage.

Prerequisitesโ€‹

  • โœ… MikroTik RouterOS v7.x
  • โœ… Two routers with a direct link (PTP recommended)
  • โœ… OSPF or BGP already configured
  • โœ… Administrative access via Winbox/SSH
  • โœ… Firewall allows UDP 3784/3785 (BFD)
warning

Aggressive BFD timers can cause flapping on unstable links. Start with safe values and tune gradually.

Configuration Stepsโ€‹

Option A: Terminalโ€‹

  1. Enable BFD on an interface

    /routing bfd interface add interface=vlan10-OSPF required-min-rx=200ms desired-min-tx=200ms detect-mult=3
  2. Enable BFD for OSPF

    /routing ospf interface-template set [find interfaces=vlan10-OSPF] bfd=yes
  3. Verify BFD sessions

    /routing bfd session print

Option B: Winboxโ€‹

  1. Routing โ†’ BFD โ†’ Interfaces โ†’ Add (+)

    • Interface: vlan10-OSPF
    • Desired Min TX: 200ms
    • Required Min RX: 200ms
    • Detect Mult: 3
  2. Routing โ†’ OSPF โ†’ Interface Templates

    • Select your PTP interface
    • Enable BFD
  3. Routing โ†’ BFD โ†’ Sessions

    • Confirm state is Up

Understanding the Configurationโ€‹

Flow Diagram

[Link] -> [BFD Session] -> [OSPF/BGP] -> [Fast Failover]

Components Table

ComponentPurposeNotes
BFD interfaceLink monitoringPerโ€‘interface settings
OSPF templateRouting integrationbfd=yes
BFD sessionDetection stateShould show Up
TimersFailover speedLower = faster, riskier

Verificationโ€‹

  1. Check BFD sessions
    /routing bfd session print
  2. Check OSPF neighbors
    /routing ospf neighbor print
  3. Simulate link failure
    • Disable interface or unplug cable
    • Observe adjacency drops within subโ€‘second range

Troubleshootingโ€‹

IssueCauseSolution
No BFD sessionBFD not enabledEnable on both routers
Session flapsTimers too lowIncrease to 300โ€“500ms
CPU spikesToo many sessionsUse BFD only on core links
OSPF not reactingBFD not linkedEnsure bfd=yes in template
Oneโ€‘way BFDFirewall blockingAllow UDP 3784/3785
Session DownLink unstableCheck cable, MTU, VLANs
BFD Up, OSPF DownOSPF misconfigValidate OSPF area + IPs
BGP not failing fastBFD not on BGPEnable BFD in BGP peer
Duplicate sessionsMultiple templatesUse one template per link
No logsLogging disabledEnable routing logs
Timers ignoredWrong interfaceMatch correct interface name
BFD missing in v6UnsupportedUpgrade to RouterOS v7

Advanced Optionsโ€‹

  1. Use different timers per link class
  2. Combine BFD with ECMP for resilience
  3. Add route filters to prevent churn
  4. Enable BFD on BGP peers only
  5. Use BFD for static routes (routing rules)
  6. Monitor BFD with Netwatch/Telegram
  7. Increase detectโ€‘mult for noisy links
  8. Use dedicated VLAN for core links
  9. Log BFD events to syslog
  10. Document timer settings per link

Use BFD on both PTP links so OSPF fails over within subโ€‘second ranges when a link drops.

Topology

R1 <==== Link A (vlan10) ====> R2
R1 <==== Link B (vlan20) ====> R2

Link A: 172.16.0.0/30
Link B: 172.16.0.4/30

Router-A (R1)โ€‹

/routing bfd interface add interface=vlan10-OSPF required-min-rx=200ms desired-min-tx=200ms detect-mult=3
/routing bfd interface add interface=vlan20-OSPF required-min-rx=200ms desired-min-tx=200ms detect-mult=3

/routing ospf interface-template set [find interfaces=vlan10-OSPF] bfd=yes
/routing ospf interface-template set [find interfaces=vlan20-OSPF] bfd=yes

Router-B (R2)โ€‹

/routing bfd interface add interface=vlan10-OSPF required-min-rx=200ms desired-min-tx=200ms detect-mult=3
/routing bfd interface add interface=vlan20-OSPF required-min-rx=200ms desired-min-tx=200ms detect-mult=3

/routing ospf interface-template set [find interfaces=vlan10-OSPF] bfd=yes
/routing ospf interface-template set [find interfaces=vlan20-OSPF] bfd=yes
info

If you want one link as primary, set different OSPF costs. BFD will still detect failure quickly on both links.

Completionโ€‹

โœ… BFD fast failover is active!

Next steps:

  • Test failover under maintenance window
  • Tune timers based on link stability
  • Document BFD settings per link