Skip to main content

MikroTik RouterOS: essential BGP commands (v6 and v7 syntax)

Mikrotik 22 June 2022

A short reference of the RouterOS commands we use daily to inspect BGP sessions on our edge routers. RouterOS 7 changed the routing menu structure, so both syntaxes are listed. Replace the peer names with your own.

Routes received from a peer

# RouterOS 6
ip route print where received-from=<peer_name>
ipv6 route print where received-from=<peer_name>
ip route print where received-from=PEER_EXAMPLE_V4_1

# RouterOS 7
/ip/route/print where received-from=<peer_name>

Gateway used for a destination

ip route print where dst-address in <prefix>
ipv6 route print where dst-address in <prefix>
ip route print where dst-address in 130.59.138.0/24

# a single IP address
/ip route print where 159.148.147.204 in dst-address

Routes advertised to a peer

# RouterOS 6
routing bgp advertisements print <peer_name>
routing bgp advertisements print ROUTE-SERVER_V6-SWISS_IX.RS1

# RouterOS 7 (use the session name, not the connection name)
/routing/bgp/advertisements print where peer=PEER_MICROSOFT_V4-1

Example output on RouterOS 7, our IPv6 and IPv4 aggregates announced to a transit provider:

[admin@edge] > /routing bgp advertisements print where
0 peer=PEER_HE_V6-1 dst=2a02:4460::/32 afi=ipv6 nexthop=2001:7f8:c5::a520:2032:1 origin=0 as-path=sequence 202032 8224 communities=64555:10000

[admin@edge] > /routing bgp advertisements print where
0 peer=PEER_HE_V4-1 dst=185.54.80.0/22 afi=ip nexthop=185.1.114.53 origin=0 as-path=sequence 202032 13097 communities=64555:10000

Set the affinity on all eBGP connections at once (RouterOS 7)

/routing/bgp/connection set [find local.role=ebgp] input.affinity=main output.affinity=main

Running every eBGP session in the main process makes the behaviour predictable on routers with a small number of peers; on busy routers keep the default so that sessions are spread across cores.

Bonus: protect the router from port scans

Not BGP, but present on every edge router: the RouterOS firewall can detect port scans with the psd matcher and abnormal TCP flag combinations, put the source address in a list for two weeks and reject its traffic. The complete rule set is in the MikroTik firewall documentation linked below; place the reject rule before the detection rules, and both before any accept rule for established connections you want to keep.

References: MikroTik documentation: BGP and MikroTik documentation: Firewall. Related: AS202032 peering policy and RoutePulse, our BGP analysis platform.

0 0 votes
Article Rating
Subscribe
Notify of

0 Comments
Oldest
Newest Most Voted
Goline It Services Logo

News

  • GOLINE is pleased to announce that it has achieved ESET Gold Partner status for 2027. The recognition follows the successful completion of ESET’s partner certification requirements and confirms GOLINE’s continued investment in cybersecurity expertise and professional development. ESET’s partner programme is designed to support companies working with its cybersecurity solutions through dedicated technical and sales resources, training and other partner services. For GOLINE, the achievement further strengthens its collaboration with ESET and its ability to integrate ESET security technologies into the cybersecurity solutions and services it provides to businesses. ESET solutions are already part of GOLINE’s cybersecurity portfolio, alongside technologies...
  • GOLINE SA is excited to announce a new partnership with NetApp, a global leader in cloud data services and storage solutions. This collaboration aims to help organizations modernize their IT infrastructure, streamline data management, and enhance performance across cloud and hybrid environments. Modern Data Solutions for Businesses Through this partnership, GOLINE integrates advanced data management solutions, enabling businesses to securely store, manage, and access critical information across cloud, on-premises, or hybrid setups. Clients can benefit from: Flexible and scalable storage solutions to meet growing data needs Simplified management of cloud and on-premises environments Enterprise-grade security for sensitive and mission-critical data...
  • GOLINE SA is proud to announce a new strategic partnership with Omnissa, a global leader in digital workspace platforms and Horizon Cloud Service solutions. This collaboration marks a significant step forward in helping organizations embrace secure, flexible, and high-performance work environments. Why Choose Omnissa for Your Business? The platform enables virtual desktops, applications, and unified endpoint management. Organizations can deploy scalable workspaces across cloud, hybrid, or on-premises setups. Key benefits include: Easy access to desktops and apps on any device Centralized management for Windows, macOS, iOS, Android, and ChromeOS Strong security with access controls and multi-factor authentication Automated scaling to...
  • Hosting Services
  • +41 (0)91 260 76 50
0
Would love your thoughts, please comment.x
()
x
| Reply