BGP Configuration Guide and Live Samples with MicroTik (RouterOS v7)
MicroTik Cloud Core Router (CCR) series devices are often preferred as BGP router in data centers, internet service providers (ISP) and large hosting companies.
Specifically RouterOS v7 Along with BGP engine was completely rewrited, multiple cores (multi-core) support came and the routing performance has increased incredibly.
In this article, the most needed on MicroTik Sample configurations that you can copy and use BGP scenarios directly together.
1. Script: BGP Installation with a Single Operator (Single-Homed eBGP)
In this scenario, its own ASN (Otonom System Number) and Your IP block There is a single line from Turkish Telecom, Cogent or another top provider (Upstream) and you want to tell your own IP block to the outside world.
Infrastructure Information:
-
Sizin ASN'niz:
AS65001 -
Your IP Block:
192.0.2.0/24 -
Operator (Provider) ASN:
AS65002 -
Connection IPs: Your
10.0.0.2/30, Operator side10.0.0.1/30
MicroTik RouterOS v7 CLI Commands:
# 1. WAN arayüzüne IP adresini tanımlayalım
/ip address
add address=10.0.0.2/30 interface=ether1 comment="WAN - Operator Baglantisi"
# 2. Kendi otonom sistemimizi (AS) tanımlayalım
/routing bgp template
set default as=65001 router-id=10.0.0.2
# 3. Dış dünyaya duyuracağımız (anons edeceğimiz) IP bloğumuzu ekleyelim
/routing bgp connection
add name=BGP-OPERATOR remote-address=10.0.0.1 templates=default \
as=65001 remote-as=65002 connect=yes listen=yes \
local.role=ebgp input.filter=bgp-in output.filter=bgp-out
# 4. Duyurmak istediğimiz IP bloğunu adres listesine (Address List) ekleyelim
/ip firewall address-list
add list=ANONS_IP_BLOKLARI address=192.0.2.0/24
# 5. BGP Filtrelerini oluşturalım (Sadece kendi bloğumuzu anons etmek için)
/routing filter rule
add chain=bgp-out rule="if (dst == 192.0.2.0/24) { accept } else { reject }"
add chain=bgp-in rule="accept"
2. Script: Replacement BGP with Two Different Operators (Multi-Homed BGP)
If you want zero downtime on your infrastructure, you need to get the internet from two different operators. In this case you must dry the eBGP neighboring with both operators and make the traffic from the outside.
In the following example, BGP AS-Path Prepend By using the method, we will supply the traffic from the first operator (Operator-A), that line is automatically coming from the second operator (Operator-B).
Infrastructure Information:
-
Sizin ASN'niz:
AS65001 -
Your IP Block:
192.0.2.0/24 -
Operator-A (Ana Hat): ASN
AS65002/ Router IP:10.0.1.1 -
Operator-B ASN
AS65003/ Router IP:10.0.2.1
MicroTik RouterOS v7 CLI Commands:
# 1. Operatör bağlantılarını kuralım
/routing bgp connection
add name=KOMSU-OPERATOR-A remote-address=10.0.1.1 templates=default \
as=65001 remote-as=65002 connect=yes local.role=ebgp \
input.filter=bgp-in-A output.filter=bgp-out-A
add name=KOMSU-OPERATOR-B remote-address=10.0.2.1 templates=default \
as=65001 remote-as=65003 connect=yes local.role=ebgp \
input.filter=bgp-in-B output.filter=bgp-out-B
# 2. Ana Hat için Filtre (Filtre A - Doğrudan Anons)
/routing filter rule
add chain=bgp-out-A rule="if (dst == 192.0.2.0/24) { accept } else { reject }"
add chain=bgp-in-A rule="accept"
# 3. Yedek Hat için Filtre (Filtre B - AS-Path Prepend ile Yolu Uzatıyoruz)
# Kendi ASN'mizi 3 kez tekrarlatarak bu hattı dış dünya için "daha uzun/tercih edilmeyen" bir yol yapıyoruz.
/routing filter rule
add chain=bgp-out-B rule="if (dst == 192.0.2.0/24) { set bgp-path-prepend 3; accept } else { reject }"
add chain=bgp-in-B rule="accept"
3. MicroTik BGP Status Control and Troubleshooting (Troubleshooting)
After completing the BGP installation, you can use the following commands via the terminal to check if everything goes on the way:
1. Checking BGP Neighborhood Status
Type the following command to see if the neighboring is not installed and dried. "established" must be.
/routing bgp session print
2. See incoming and outgoing routes
To see what IP routes you get from your neighbor:
/ip route print where bgp=yes
3. Checking Which Blocks Are Senseing To The Outside World
To see if you have successfully understood your operator:
/routing bgp advertised-routes print
Last Word: Managing BGP with MicroTik Now It's More Easy!
MicroTik RouterOS v7 has become one of the most trusted friends of large data centers and hosting providers with performance improvements, especially on dynamic routing (routing). With the correct filtering rules and backup configuration, you can set up a network infrastructure in world standards without wrapping your hardware budget.
You can get support from our expert network team to professionally design your MicroTik BGP infrastructure, work with zero downtime of your IP announcements and backed line passes (failover)!