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.