Skip to content
Back to Blog
MikroTik

BGP Routing on MikroTik RouterOS 7: New Routing Engine

Leverage RouterOS 7 new routing engine for BGP sessions, route filters, communities, and redundant ISP connectivity.

Oct 2025
15 min read

Introduction

BGP (Border Gateway Protocol) on MikroTik RouterOS 7 uses an entirely rewritten routing engine compared to ROS 6. The new engine is more efficient, better handles large routing tables, and introduces significant configuration changes. This guide covers the new BGP configuration model.

Key Differences in RouterOS 7 BGP

FeatureRouterOS 6RouterOS 7
BGP instance/routing bgp instance/routing bgp template
Peer config/routing bgp peer/routing bgp connection
Network advertising/routing bgp networkvia filters
Route filtersbasicpowerful scripting

Step 1: Configure BGP Template (Router Identity)

BASH
# Set router AS number and router-id
/routing bgp template
add name=default as=65001 router-id=10.0.0.1

Step 2: Add BGP Peer Connection

For a simple eBGP connection to your ISP:

BASH
/routing bgp connection
add name=ISP-Peer   template=default   remote.address=203.0.113.1   remote.as=65000   local.address=203.0.113.2   output.filter-chain=TO-ISP   input.filter-chain=FROM-ISP

Step 3: Route Filters

RouterOS 7 uses a new filter scripting language:

BASH
/routing filter rule
# Advertise only your own prefix
add chain=TO-ISP rule="if (dst == 192.168.0.0/16) { accept } else { reject }"

# Accept default route from ISP, reject everything else
add chain=FROM-ISP rule="if (dst == 0.0.0.0/0) { accept } else { reject }"

Step 4: Advertise Your Networks

BASH
# Add connected network to BGP output
/routing bgp connection
set ISP-Peer output.network=192.168.0.0/16

Or use more specific filter to control what gets announced:

BASH
/routing filter rule
add chain=TO-ISP rule="
  if (dst == 192.168.1.0/24 || dst == 192.168.2.0/24) {
    set bgp-communities 65001:100;
    accept
  }
  reject
"

iBGP Configuration

For connecting two routers within the same AS:

BASH
/routing bgp connection
add name=IBGP-R2   template=default   remote.address=10.0.0.2   remote.as=65001   local.address=10.0.0.1

Key difference: iBGP does NOT increment the as-path, so you need either:

  • Full mesh between all iBGP routers, OR
  • Route Reflector setup

Route Reflector Setup

Designate one router as the Route Reflector:

BASH
/routing bgp connection
add name=RR-Client1   template=default   remote.address=10.0.0.3   remote.as=65001   route-reflect=yes   cluster-id=10.0.0.1

BGP Communities

Set and match communities for traffic engineering:

BASH
/routing filter rule
add chain=FROM-ISP rule="
  if (bgp-communities includes 65000:200) {
    set bgp-local-pref 200;
    accept
  }
"

Verification and Troubleshooting

BASH
# View BGP sessions
/routing bgp connection print
/routing bgp session print

# View BGP routing table
/routing route print where bgp

# Check BGP advertisements
/routing bgp advertisement print

# Debug BGP events
/routing bgp connection monitor [find name=ISP-Peer] output=yes

Real-World Multi-Homing Setup

Two ISPs, prefer ISP1, failover to ISP2:

BASH
/routing bgp connection
add name=ISP1 template=default remote.address=1.1.1.1 remote.as=65100   input.filter-chain=FROM-ISP1 output.filter-chain=TO-ISP
add name=ISP2 template=default remote.address=2.2.2.2 remote.as=65200   input.filter-chain=FROM-ISP2 output.filter-chain=TO-ISP

/routing filter rule
add chain=FROM-ISP1 rule="set bgp-local-pref 200; accept"
add chain=FROM-ISP2 rule="set bgp-local-pref 100; accept"