Академический Документы
Профессиональный Документы
Культура Документы
What is BGP?
The Border Getaway Protocol (BGP) is an inter-autonomous system routing protocol based on distance-vector
algorithm. It is used to exchange routing information across the Internet and is the only protocol that is designed to
deal with a network of the Internet's size and the only protocol that can deal well with having multiple connections to
unrelated routing domains.
BGP is designed to allow for sophisticated administrative routing policies to be implemented. BGP does not
exchange information about network topology but rather reachability information. As such, BGP is better suited to
inter-AS environments and special cases like informational feeds. If you just need to enable dynamic routing in your
network, consider OSPF instead.
Enabling BGP
To enable BGP assuming only one BGP process will be present in the system, it is enough to do the following:
• modify configuration of the default BGP instance. In particular, change instance AS number to the desired ASN:
Note, that, unless explicitly specified, BGP router ID is set as the least IP address on the router.
• add at least one BGP peer. Refer to the next section for more information on how to configure BGP peers.
BGP Peers
Two BGP routers have to establish TCP connection between each other to be considered as BGP peers. Since BGP
requires a reliable transport for routing information, a TCP connection is essential for it to operate properly.
Once TCP connection is up, routers exchange some initial information such as the BGP router ID, the BGP version,
the AS number and the Hold Time interval value in the OPEN message. After these values are communicated and
agreed upon, the BGP session is established and the routers are ready to exchange routing information via BGP
UPDATE messages.
To establish TCP connection to another BGP router, issue the following command:
[eugene@SM_BGP] >
The BGP connection between two peers is up (state=established) with used value of Hold Time of 3 minutes. The
prefix-count parameter indicates the total number of prefixes received from this particular peer. In case a peer later
withdraws some prefixes from its routing announcements, the total number of prefixes is reduced by the appropriate
value.
Route Redistribution
BGP process does not redistribute routes by default. You need to set one or more of the redistribute-connected,
redistribute-static, redistribute-rip, redistribute-ospf and redistribute-other-bgp BGP instance parameters to
yes to enable redistribution of the routes of the particular type. Thus issuing the /routing bgp instance set default
redistribute-static=yes redistribute-connected=yes command enables redistribution of static and connected routes to
all BGP peers that are configured to use default BGP instance. This might not be the desired behavior, since now you
are announcing all of your internal routes into BGP. Moreover, some of the advertised prefixes might be too small
and should be substituted with larger ones. You need to configure routing filters and route aggregation to avoid these
problems.
Routing Filters
Unfiltered redistribution of routes might lead to undesired results. Consider the example below. R3 has a static route
to the 192.168.0.0/24 network and since it has redistribute-static set to yes it announces the route to its BGP peer R1.
This makes R1 believe that the AS300 is the source of the 192.168.0.0/24 network, which is misleading. To avoid
this problem a routing filter that permits redistribution only of the 192.168.11.0/24 network must be applied on the
R3.
Note the invert-match parameter. It makes the rule to match everything except the 192.168.11.0/24 prefix and
discard it.
Routing filters are accessible through /routing filter menu. A routing filter consists of one or more filter rules
identified by common chain. Rules are processed from top to bottom. Each rule consists of condition(s) to be
satisfied in order for rule to match and action(s) to be performed on the matched prefixes. To enable routing filter,
specify corresponding chain name as either in-filter or out-filter for BGP peer, or as out-filter for BGP instance.
• rule #0 matches prefix 10.0.0.0/8 and more specific prefixes like 10.0.1.0/24, 10.1.23.0/28, etc. and discards them
(these prefixes are silently dropped from inbound update messages and do not appear in memory)
• rule #3 sets BGP COMMUNITY attribute for prefix 4.23.113.0/24
• rule #4 has two actions. It simultaneously sets routing mark and comment for route to 4.36.116.0/23
• rule #5 discards prefix 8.8.0.0/16 and more specific ones, if they have COMMUNITY attribute of 2588:800
To use the filter above, add it as in-filter to the Latnet peer:
[eugene@SM_BGP] routing bgp peer> set Latnet in-filter=Latnet-in
[eugene@SM_BGP] routing filter> print
Flags: X - disabled
0 name="C7200" instance=latnet remote-address=10.0.11.202 remote-as=64527 tcp-md5-key=""
nexthop-choice=default multihop=no route-reflect=no hold-time=3m ttl=1 in-filter=""
out-filter=to_C7200
out-filter=to_Latnet
BGP Networks
The information in this article may be deprecated, and is described better elsewhere in the Wiki.
BGP allows to specify some arbitrary prefixes to be unconditionally advertised. These prefixes
should be added to the /routing bgp networks list. The prefixes in this list are advertised as IGP
routes. The redistribution of the BGP networks is affected by peer's routing filters. On the other
hand, BGP networks are not installed in main routing table. As a consequence, they are not
considered in best path selection algorithm, and do not affect aggregate processing.
Issue the following command to make the router advertise the 192.168.0.0/24 network to its peers:
Static Routes
You could always use a static route to originate a subnet. With the routing-test package bringing many bgp-related
enhancements into the /ip route menu, the static routes become a more powerful tool to originate prefixes. For
example, you could add a static route to the 10.8.0.0/16 network and set BGP Local Preference attribute value for
this route simultaneously:
BGP Advertisements
RouterOS provides a way to view what prefixes the router is redistributing to its peers. Issue /routing bgp
advertisements print <peer's address> command to view prefixes sent to this peer.
[eugene@SM_BGP] routing bgp advertisements> print 10.0.11.20
BGP Aggregates
This feature allows to redistribute one big prefix instead of many smaller ones.
[eugene@SM_BGP] routing bgp aggregate> print
Flags: X - disabled
advertise-filter=""
advertise-filter=""
Manual:BGP Case Studies 7
advertise-filter=""
The rules above suppress specific prefixes in ranges 3.0.0.0/8, 6.0.0.0/8 and 4.0.0.0/8 from being advertised:
[eugene@SM_BGP] routing bgp advertisements> print 10.0.11.20