Skip to content
MikroTik RouterOS Docs

BFD (Bidirectional Forwarding Detection)

For the impatient: enable BFD for BGP in RouterOS v7.

# Allow BFD on interface
/routing/bfd/configuration/add interfaces=ether1 comment="BGP peer link"
# Enable BFD on BGP connection
/routing/bgp/connection/set [find name=upstream] use-bfd=yes
# Verify session is up
/routing/bfd/session/print

What this does: BFD provides sub-second detection of link failures between network devices. Default settings detect failures in ~1 second (200ms interval x 5 multiplier), compared to BGP’s 180-second default hold time or OSPF’s 40-second dead interval.

When to use this:

  • Redundant uplinks where fast failover is critical
  • BGP peering with multiple upstream providers
  • OSPF backbone links requiring rapid convergence
  • Any scenario where routing protocol timers are too slow

Prerequisites:

  • RouterOS v7.0 or higher
  • BGP or OSPF configured
  • Direct connectivity for single-hop BFD (multi-hop requires address configuration)
  • Firewall allowing UDP 3784 (single-hop) or 4784 (multi-hop)
  • Both peers must support BFD

v7 Behavior Change

In RouterOS v7, if use-bfd=yes is set on a BGP connection and the BFD session cannot establish, BGP will not come up. Only enable BFD when you’ve confirmed the peer supports it.

BFD requires explicit configuration entries to allow sessions on interfaces:

/routing/bfd/configuration/add interfaces=ether1 \
min-tx=200ms min-rx=200ms multiplier=5 comment="BGP peer link"

Default timer values provide 1-second detection time (200ms x 5).

For BGP:

/routing/bgp/connection/set [find name=upstream] use-bfd=yes

For OSPF:

/routing/ospf/interface-template/set [find] use-bfd=yes

Check that the BFD session is established:

/routing/bfd/session/print

Expected output:

Columns: REMOTE-ADDRESS, LOCAL-ADDRESS, INTERFACE, STATE, MULTIHOP
# REMOTE-ADDRESS LOCAL-ADDRESS INTERFACE STATE MULTIHOP
0 192.168.1.2 192.168.1.1 ether1 up no

Enable BFD for a single-hop BGP peer:

# Step 1: Allow BFD on the peering interface
/routing/bfd/configuration/add interfaces=ether1 comment="BGP to ISP"
# Step 2: Enable BFD on the BGP connection
/routing/bgp/connection/set [find name=isp-upstream] use-bfd=yes
# Step 3: Verify
/routing/bfd/session/print

Enable BFD for all OSPF neighbors:

# Step 1: Create interface list for OSPF interfaces
/interface/list/add name=ospf-interfaces
/interface/list/member/add list=ospf-interfaces interface=ether2
/interface/list/member/add list=ospf-interfaces interface=ether3
# Step 2: Allow BFD on OSPF interfaces
/routing/bfd/configuration/add interfaces=ospf-interfaces comment="OSPF backbone"
# Step 3: Enable BFD in OSPF
/routing/ospf/interface-template/set [find] use-bfd=yes
# Step 4: Verify
/routing/bfd/session/print where state=up

For eBGP peers not directly connected:

# Step 1: Create address list for allowed peers
/ip/firewall/address-list/add list=ebgp-bfd-peers address=198.51.100.1
/ip/firewall/address-list/add list=ebgp-bfd-peers address=203.0.113.1
# Step 2: Configure BFD for multi-hop (uses addresses, not interfaces)
/routing/bfd/configuration/add address-list=ebgp-bfd-peers
# Step 3: Enable BFD and multi-hop on BGP connection
/routing/bgp/connection/set [find name=ebgp-peer] use-bfd=yes multihop=yes

Multi-hop BFD uses UDP port 4784 instead of 3784.

Control which interfaces can use BFD:

# Forbid BFD on management interface (specific rule first)
/routing/bfd/configuration/add interfaces=ether1 forbid-bfd=yes comment="No BFD on mgmt"
# Allow BFD on all other interfaces
/routing/bfd/configuration/add interfaces=all comment="Allow BFD elsewhere"

Order Matters

BFD configuration entries are order-sensitive (first match wins). Place specific forbid-bfd rules before general allow rules.

For fastest possible failover (50ms detection):

/routing/bfd/configuration/add interfaces=critical-uplink \
min-tx=10ms min-rx=10ms multiplier=5 comment="50ms detection"

CPU Impact

Very aggressive timers increase CPU load. On loaded systems, this may cause false positives (BFD flapping). Use 200ms or higher on production routers.

Different detection times for different links:

# Fast detection for primary uplink
/routing/bfd/configuration/add interfaces=ether1 \
min-tx=100ms min-rx=100ms multiplier=3 comment="300ms detection"
# Standard detection for backup
/routing/bfd/configuration/add interfaces=ether2 \
min-tx=200ms min-rx=200ms multiplier=5 comment="1s detection"

Confirm BFD is working correctly:

/routing/bfd/session/print

Expected: All sessions showing state=up.

/routing/bfd/session/print detail

Expected: packets-rx and packets-tx incrementing.

/routing/bfd/configuration/print

Expected: Entries allowing BFD on required interfaces.

/routing/bgp/session/print

Expected: BGP sessions established with BFD enabled.

/routing/ospf/neighbor/print

Expected: OSPF neighbors with BFD enabled.

/log/print where topics~"bfd"

Expected: No unexpected “down” events.

SymptomCauseSolution
BGP won’t establishBFD configured but peer doesn’t support itVerify peer supports BFD before enabling use-bfd=yes
BFD session stuck in “down”No configuration entry for interfaceAdd /routing/bfd/configuration entry for the interface
”TTL check failed” in logsPacket traversing extra hopsVerify direct connectivity; use multi-hop BFD if needed
Session flappingAggressive timers on loaded routerIncrease min-tx/min-rx to 200ms or higher
BFD not transmittingInterface matched by forbid-bfd ruleCheck configuration order; move forbid rule or add explicit allow
Multi-hop BFD not workingUsing interface filter for multi-hopUse addresses or address-list for multi-hop, not interfaces
Interop issues with CiscoCisco has echo mode enabledDisable echo on Cisco: no bfd echo
Session not restored after rebootConfiguration entry missing or disabledVerify /routing/bfd/configuration entries exist
/system/logging/add topics=bfd action=memory
/log/print where topics~"bfd"
/routing/bfd/session/print detail

Look for:

  • state-changes: High count indicates instability
  • packets-rx/packets-tx: Should be incrementing
  • hold-time: Calculated detection time

Ensure BFD traffic is allowed:

# Single-hop BFD
/ip/firewall/filter/add chain=input protocol=udp dst-port=3784 action=accept comment="BFD single-hop"
# Multi-hop BFD
/ip/firewall/filter/add chain=input protocol=udp dst-port=4784 action=accept comment="BFD multi-hop"

Common Mistakes

  • Enabling BFD without peer support - v7 requires both peers to have BFD; BGP stays down if BFD fails
  • Missing configuration entry - BFD won’t work without explicit /routing/bfd/configuration allowing it
  • Wrong order of rules - forbid-bfd rules must come before allow rules to work correctly
  • Using interfaces for multi-hop - Multi-hop BFD requires addresses or address-list, not interface filters
  • Timers too aggressive - 10ms timers can cause false positives; start with 200ms defaults
TimerDefaultDescription
min-tx200msMinimum transmit interval
min-rx200msMinimum receive interval
multiplier5Missed packets before failure
Detection time1 secondmin-rx x multiplier
min-tx/min-rxMultiplierDetection Time
200ms51 second
100ms3300ms
50ms5250ms
10ms550ms
  • BGP - primary use case for BFD fast failover
  • OSPF - OSPF neighbor failure detection
  • Static Routes - BFD-triggered route changes
  • MikroTik BFD Documentation
  • RFC 5880 - BFD Protocol
  • RFC 5881 - BFD for IPv4 and IPv6 (Single Hop)
  • RFC 5883 - BFD for Multihop Paths
CommandDescription
/routing/bfd/configuration/addCreate BFD policy entry
/routing/bfd/configuration/printView BFD configuration
/routing/bfd/session/printView active BFD sessions
/routing/bfd/session/print detailView session details with counters
PropertyTypeDefaultDescription
interfacesinterface-list-Interface filter for single-hop BFD
addressesIP range-Address range for multi-hop filtering
address-liststring-Named address list for destination matching
vrfstringmainVirtual routing instance
min-txtime200msMinimum transmit interval
min-rxtime200msMinimum receive interval
multiplierinteger5Detection multiplier
forbid-bfdyes/nonoBlock BFD on matching entries
disabledyes/nonoDisable configuration entry
commentstring-Description
PropertyTypeDescription
remote-addressIPPeer’s IP address
local-addressIPLocal source address
interfacestringAssociated interface
stateup/down/initCurrent session state
multihopyes/noMulti-hop session indicator
desired-tx-intervaltimeNegotiated transmit interval
required-min-rxtimeLocal minimum RX interval
remote-min-rxtimePeer’s minimum RX interval
multiplierintegerDetection multiplier
hold-timetimeCalculated detection time
packets-rxintegerReceived packet count
packets-txintegerTransmitted packet count
state-changesintegerSession state transition count
uptimetimeTime since session established
PortProtocolPurpose
3784UDPSingle-hop BFD control
4784UDPMulti-hop BFD control
3785UDPBFD echo (not supported on MikroTik)
FeatureNotes
Echo modeNot implemented; disable on Cisco peers
AuthenticationMD5/SHA not supported
Static route integrationMust use routing protocol for BFD