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.
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 peerand/routing bgp networkare not found on v7.- The session stays in
ActiveorConnect, 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 (example198.51.100.0/24) and the provider's ASN (65000). - Link addresses agreed with the provider, for example you
203.0.113.2/30and them203.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:
/ip route add dst-address=198.51.100.0/24 blackhole
/ip firewall address-list add list=bgp-out address=198.51.100.0/242. Filters. Accept only sensible prefixes from the provider, and announce only your own:
/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:
/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-inIf your input firewall drops traffic from the WAN, allow BGP from the provider:
/ip firewall filter add chain=input src-address=203.0.113.1 protocol=tcp dst-port=179 action=accept comment="BGP" place-before=0Verification
/routing bgp session print
/ip route print where bgpThe 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
/routing bgp connection disable to-ispWatch the video: How to configure BGP in MikroTik RouterOS v7
This topic is covered hands-on in MTCINE — MikroTik Certified Inter-Networking Engineer.
View MTCINE