Prerequisites
Before proceeding, ensure you have the following:
- A Mikrotik router running RouterOS Version 7.x.
- Basic understanding of networking and BGP concepts.
- Two autonomous system numbers (ASNs) for the local and remote peers.
- IP connectivity between the local and remote routers.
- Administrative access to the Mikrotik router.
class="wp-block-heading">Step 1: Verify Your RouterOS Version
To verify that your Mikrotik router is running RouterOS Version 7 or higher, execute the following command:
/system/resource/print
Ensure the version displayed is 7.x or above. I recommend the latest Version 7, which, as of this writing, is 7.16.2.
If necessary, upgrade your RouterOS:
/system/package/update/check-for-updates
/system/package/update/install
Step 2: Enable BGP Service
By default, BGP is part of the routing package in RouterOS Version 7. Enable it if not already enabled:
/routing/bgp/instance/add name=default-asn as=65001
Replace 65001 with your local ASN.
Step 3: Configure BGP Instance
A BGP instance defines the local ASN and specifies the router’s role in the BGP topology. Use the following command to create a BGP instance:
/routing/bgp/instance/set default name=bgp-instance as=65001 router-id=192.168.1.1
Replace:
65001with your local ASN.192.168.1.1with the desired router ID (commonly an IP address from your router).
Step 4: Define BGP Peers
BGP peers are the remote routers with which your router will exchange routes. Add a BGP peer using:
/routing/bgp/connection/add name=peer1 remote.address=192.168.2.1 remote.as=65002
Replace:
peer1with a name for the peer.192.168.2.1with the IP address of the remote peer.65002with the ASN of the remote peer.
Step 5: Configure Networks to Advertise
To advertise networks, use the prefix command:
/routing/filter/rule/add chain=bgp-out action=accept prefix=10.0.0.0/24
/routing/bgp/connection/set peer1 out-filter=bgp-out
Replace 10.0.0.0/24 with the subnet you wish to advertise.
Step 6: Verify BGP Status
To ensure that the BGP session is established, use the following command:
/routing/bgp/connection/print status
Look for the established state in the output.
Step 7: View Received Routes
To check the routes received from the BGP peer:
/routing/route/print where bgp
Troubleshooting Tips
- Ensure Connectivity: Verify that the local and remote IP addresses can ping each other.
/ping 192.168.2.1 - Check Firewall Rules: Ensure that TCP port 179 is open for BGP communication.
- Debug Logs: Use the logging feature to debug BGP issues:
/system/logging/add topics=routing,bgp action=memoryCheck logs with:/log/print - Validate Configuration: Double-check ASN and IP configurations on both ends.
Conclusion
Setting up a BGP peer on Mikrotik RouterOS Version 7 is straightforward, thanks to its improved BGP implementation. Following this guide can establish a stable BGP session and manage routes effectively. Monitor the BGP session regularly to ensure optimal performance and quickly address any issues.
Discover more from RSS Feeds Cloud
Subscribe to get the latest posts sent to your email.
