BGP

BGP Configuration on MikroTik RouterOS v7 (eBGP with Your ISP)

Set up an eBGP session with your upstream on RouterOS v7: connection, advertising your prefix, basic input and output filters, verification and common session problems.

Commands in this article follow RouterOS v7 documentation but have not yet been marked as lab-tested on this site. Always test changes in a lab or maintenance window and keep a backup.

Problem

You have your own ASN and IP prefix and need to announce it to your upstream provider, but the RouterOS v6 BGP commands (peers, networks) no longer exist in v7.

Symptoms

  • /routing bgp peer and /routing bgp network are not found on v7.
  • The session stays in Active or Connect, or it is up but your prefix is not announced.

Likely causes

RouterOS v7 uses connections instead of peers, address lists for announced networks, and a new routing filter language. Session problems usually come from a wrong remote AS, a blocked TCP port 179, or a missing route for the announced prefix.

Prerequisites

  • Your ASN (example 65001), your prefix (example 198.51.100.0/24) and the provider's ASN (65000).
  • Link addresses agreed with the provider, for example you 203.0.113.2/30 and them 203.0.113.1.

Solution (WinBox / CLI)

1. Prefix to announce. The prefix must exist in your routing table; a blackhole route is the usual way:

RouterOS CLI
/ip route add dst-address=198.51.100.0/24 blackhole
/ip firewall address-list add list=bgp-out address=198.51.100.0/24

2. Filters. Accept only sensible prefixes from the provider, and announce only your own:

RouterOS CLI
/routing filter rule add chain=isp-in rule="if (dst-len > 24) { reject } else { accept }"
/routing filter rule add chain=isp-out rule="if (dst in 198.51.100.0/24 && dst-len == 24) { accept } else { reject }"

3. BGP connection:

RouterOS CLI
/routing bgp connection add name=to-isp as=65001 router-id=203.0.113.2 local.role=ebgp remote.address=203.0.113.1 remote.as=65000 output.network=bgp-out output.filter-chain=isp-out input.filter=isp-in

If your input firewall drops traffic from the WAN, allow BGP from the provider:

RouterOS CLI
/ip firewall filter add chain=input src-address=203.0.113.1 protocol=tcp dst-port=179 action=accept comment="BGP" place-before=0

Verification

RouterOS CLI
/routing bgp session print
/ip route print where bgp

The session shows established. Ask the provider, or use a public looking glass, to confirm your prefix is received.

Common errors

  • Remote AS or neighbor address typed wrong: session never establishes.
  • Prefix not in the routing table: nothing is announced. Keep the blackhole route.
  • No input filter on a full-table session: the router can run out of memory on small devices. Accept only a default route or limit prefixes.
  • Announcing networks you do not own: the provider will block the session. Use the output filter.

Rollback

RouterOS CLI
/routing bgp connection disable to-isp

Watch the video: How to configure BGP in MikroTik RouterOS v7

Go deeper in class

This topic is covered hands-on in MTCINE — MikroTik Certified Inter-Networking Engineer.

View MTCINE
WhatsApp