Document revision 06-Apr-2002
This document applies to the MikroTik RouterOS 2.5
MikroTik RouterOS supports BGP Versions 2, 3, and 4, as defined in RFCs 1163, 1267, and 1771, respectively.
The MikroTik RouterOS implementation of the BGP has the following features:
[MikroTik] > system package print Flags: I - invalid # NAME VERSION BUILD-TIME UNINSTALL 0 system 2.5 apr/03/2002 10:06:30 no 1 bgp 2.5 apr/03/2002 10:19:15 no [MikroTik] >
Hardware Resource Usage
The BGP requires additional RAM for storing the routing information.
It is recommended to have 128MB or more RAM.
BGP Description
For BGP description and implementation guidelines please refer to the readings
mentioned in the list of Additional Resources.
Current document discusses BGP configuration for MikroTik RouterOS.
BGP Setup
The BGP management can be accessed under the /routing bgp submenu.
[MikroTik] routing bgp> print enabled: no as: 0 router-id: 0.0.0.0 redistribute-static: no redistribute-connected: no redistribute-rip: no redistribute-ospf: no state: disabled [MikroTik] routing bgp> set as=65002 router-id=159.148.147.2206 enabled=yes [MikroTik] routing bgp> print enabled: yes as: 65002 router-id: 159.148.147.206 redistribute-static: no redistribute-connected: no redistribute-rip: no redistribute-ospf: no state: running [MikroTik] routing bgp>
Argument description:
enabled - (yes / no) Enable or disable the BGP.
as - Autonomous system number.
router-id – The Router ID.
redistribute-connected – ( yes / no ) If set to yes, then the router will redistribute the information about all connected routes, i.e., routes to networks, that can be directly reached from the router.
redistribute-static – ( yes / no ) If set to yes, then the router will redistribute the information about all static routes added to its routing database, i.e., routes, that have been created using the /ip route add command of the router.
redistribute-rip – ( yes / no ) If set to yes, then the router will redistribute the information about all routes learned by the RIP protocol.
state - Status of the BGP:
disabled - not working, has been disabled
running - working
Usually you want to redistribute connected and static routes, if any. Therefore change the settings for these arguments and proceed to the BGP networks.
To tell the BGP router which networks to advertise, use the /routing bgp network add command:
[MikroTik] routing bgp network> add network=159.148.150.192/27 [MikroTik] routing bgp network> print # NETWORK 0 159.148.150.192/27 [MikroTik] routing bgp network>
Here, the network argument is used to specify the network/mask to advertise. You can add to the list as many networks as required. Also, you can use 0.0.0.0/0 to advertise all networks.
Note, that the OSPF uses network list for different purpose - to determine where to send updates.
You need to specify the BGP peer with whom you want to exchange the routing information. The BGP exchanges routing information only if it can establish a TCP connection to its peer. You can add as many peers as required, for example:
[MikroTik] routing bgp peer> add remote-address=192.168.0.254 remote-as=217 [MikroTik] routing bgp peer> print # REMOTE-ADDRESS REMOTE-AS MULTIHOP ROUTE-REFLECT 0 192.168.0.254 217 no no [MikroTik] routing bgp peer> print detail 0 remote-address=192.168.0.254 remote-as=217 multihop=no route-reflect=no prefix-list-in=none prefix-list-out=none state=not-connected routes-received=0 [MikroTik] routing bgp peer>
Argument description:
remote-address - Address of the remote peer.
remote-as - AS number of the remote peer.
multihop - (yes / no) Allows BGP sessions, even when the neighbor is not on a directly connected segment. The multihop session is not established if the only route to the multi-hop peer's address is the default route (0.0.0.0).
route-reflect - (yes / no)
prefix-list-in - Name of the filtering prefix list for receiving routes.
prefix-list-out - Name of the filtering prefix list for advertising routes.
state - Shows the status of the BGP connection to the peer. Can be 'not-connected' or 'connected'.
routes-received - Shows the number of received routes from this peer.
The prefix lists should be defined under the '/routing prefix-list'.
BGP Filtering using Prefix Lists
Filtering by prefix list involves matching the prefixes of routes with those listed in the prefix list. When there is a match, the route is used. The prefix lists are used when specifying the peers under '/routing bgp peer'. An empty prefix list permits all prefixes.
To add a prefix list, use the '/routing prefix-list add' command, for example:
[MikroTik] routing prefix-list> add name=cybernet [MikroTik] routing prefix-list> print # NAME DEFAULT-ACTION 0 cybernet accept [MikroTik] routing prefix-list>
Argument description:
name - Name for the prefix list
default-action - (accept / reject) Default action for all members of this list.
The list members can be added using the '/routing prefix-list list _listname_ add' command, for example:
[MikroTik] routing prefix-list> list cybernet [MikroTik] routing prefix-list list cybernet> add prefix=172.16.0.0 prefix-length=16 [MikroTik] routing prefix-list list cybernet> print # PREFIX PREFIX-LENGTH ACTION 0 172.16.0.0/0 16 accept [MikroTik] routing prefix-list list cybernet>
Argument description:
prefix - Network preffix, e.g., 198.168.0.0
preffix-length - Length od the network preffix in bits, e.g., 16
action - (accept / reject) Action for the list member
You can add as many members to the list as required.
Additional Resources
Recommended readings for guidelines on building BGP networks:
(Not complete yet)