BGP Notes
BGP Notes
BGP Notes
01
In the above figure, RouterB and RouterC in AS 200 would form an iBGP
peer relationship. RouterA in AS 100 and RouterB in AS 200 would form an
eBGP peering.
Once BGP peers form a neighbor relationship, they share their full routing
table. Afterwards, only changes to the routing table are forwarded to peers.
By default, BGP assumes that eBGP peers are a maximum of one hop away.
This restriction can be bypassed using the ebgp-multihop option with the
neighbor command (demonstrated later in this guide).
iBGP peers do not have a hop restriction, and are dependent on the
underlying IGP of the AS to connect peers together. By default, all iBGP
peers must be fully meshed within the Autonomous System.
A Cisco router running BGP can belong to only one AS. The IOS will only
allow one BGP process to run on a router.
The Administrative Distance for routes learned outside the Autonomous
System (eBGP routes) is 20, while the AD for iBGP and locally-originated
routes is 200.
BGP v2.01
The first step in configuring BGP is to enable the BGP process, and specify
the router’s Autonomous System (AS):
RouterB(config)# router bgp 100
Notice that the syntax is the same, and that the remote-as argument is always
used, regardless if the peering is iBGP or eBGP.
For stability purposes, the source interface used to generate updates to a
particular neighbor can be specified:
RouterB(config)# router bgp 100
RouterB(config-router)# neighbor 172.16.1.2 update-source lo0
Remember though: by default, BGP assumes that external peers are exactly
one hop away. Using the loopback as a source interface puts RouterB two
hops away from RouterC. Thus, the ebgp-multihop feature must be enabled:
RouterC(config)# router bgp 900
RouterC(config-router)# neighbor 1.1.1.1 ebgp-multihop 2
The 2 indicates the number of hops to the eBGP peer. If left blank, the
default is 255.
To authenticate updates between two BGP peers:
RouterB(config)# router bgp 100
RouterB(config-router)# neighbor 172.16.1.2 password CISCO
The above command sets the Keepalive timer to 30 seconds, and the Hold-
time timer to 90 seconds. If the configured Hold-time timers between two
peers are different, the peer session will still be established, and the smallest
timer value will be used.
To adjust the timers for a specific neighbor (which overrides the global timer
configuration):
RouterB(config)# router bgp 100
RouterB(config-router)# neighbor 172.16.1.2 timers 30 90
BGP v2.01
<snip>
BGP Synchronization
Consider the above example. RouterB may inject the 10.5.0.0/16 network
into BGP using the network command. However, unless that route is in the
local routing table (in this case, via an IGP), RouterB will not advertise the
route to RouterC.
Furthermore, the network statement must match the route exactly as it is
in the routing table:
RouterB(config)# router bgp 100
RouterB(config-router)# neighbor 172.16.1.2 remote-as 900
RouterB(config-router)# network 10.5.0.0 mask 255.255.0.0
The above configuration would match the route perfectly, while the
following configuration would not:
RouterB(config-router)# network 10.5.0.0 mask 255.255.255.0
The route has been injected into BGP using the network command. The
Next Hop of 0.0.0.0 indicates that the route was locally originated into BGP.
The Path is empty, as the route originated in the Autonomous Systems.
Notice the Status Codes of “*>”. The * indicates that this route is valid (i.e.
in the routing table). The > indicates that this is the best route to the
destination.
BGP will never advertise a route to an eBGP peer unless it is both valid and
the best route to that destination. BGP routes that are both valid and best
will also added the IP routing table as well.
To view the BGP routing table on RouterC:
RouterC# show ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 10.5.0.0 172.16.1.1 0 100 0 100 i
Notice that AS 100 has been added to the path, and that the Next Hop is
now RouterB.
BGP v2.01
BGP Route-Reflectors
Recall that BGP requires all iBGP peers to be fully meshed. Route-
Reflectors allow us to bypass this restriction. Fewer neighbor connections
will result in less bandwidth and CPU usage.
Route-reflector clients form neighbor adjacencies with the route-reflector
server. BGP updates will flow from the server to the clients, without the
clients having to interact with each other.
Consider the above example. In AS 100, there are three BGP speakers.
Normally, these iBGP peers must be fully-meshed. For example, RouterB
would need a neighbor statement for both RouterA and RouterD.
As an alternative, RouterA can be configured as a route-reflector server.
Both RouterB and RouterD would only need to peer with RouterA.
All route-reflector specific configuration takes place on the route reflector
server:
RouterA(config)# router bgp 100
RouterA(config-router)# neighbor 10.2.1.2 remote-as 100
RouterA(config-router)# neighbor 10.2.1.2 route-reflector-client
RouterA(config-router)# neighbor 10.1.1.2 remote-as 100
RouterA(config-router)# neighbor 10.1.1.2 route-reflector-client
BGP Confederations
Notice that the sub-AS (777) is used in the router bgp statement.
Additionally, the parent AS must be specified using a bgp confederation
identifier statement. Finally, any confederation peers must be identified.
RouterC will be unaware of RouterB’s confederation status. Thus,
RouterC’s neighbor statement will point to AS 300, and not AS 888:
RouterC(config)# router bgp 500
RouterC(config-router)# neighbor 172.16.1.1 remote-as 300
(Reference: http://www.cisco.com/univercd/cc/td/doc/cisintwk/ics/icsbgp4.htm#wp6834)
BGP v2.01
BGP Peer-Groups
Peer-groups simplify configuration of groups of neighbors, assuming those
neighbors share identical settings. Additionally, peer-groups conserve
processor/memory resources by sending updates to all peer-group members
simultaneously, as opposed to sending individual updates to each neighbor.
All neighbor parameters are applied to the peer-group itself. Configuration is
simple:
Router(config)# router bgp 200
Router(config-router)# neighbor MYPEERGROUP peer-group
Router(config-router)# neighbor MYPEERGROUP remote-as 200
Router(config-router)# neighbor MYPEERGROUP update-source lo0
Router(config-router)# neighbor MYPEERGROUP route-reflector-client
The above neighbors now inherit the settings of the peer-group named
MYPEERGROUP.
All “members” of a peer-group must exclusively be internal (iBGP) peers or
external (eBGP) peers. A mix of internal and external peers is not allowed in
a peer-group.
Outbound route filtering (via a distribution-list, route-map, etc.) must be
identical on all members of a peer-group. Inbound route filtering can still be
applied on a per-neighbor basis.
(Reference: http://www.cisco.com/warp/public/459/29.html)
BGP v2.01
BGP Attributes
BGP utilizes several attributes to determine the best path to a destination.
Well-known attributes are supported by all implementations of BGP, while
optional attributes may not be supported by all BGP-speaking routers.
Several subcategories of attributes exist:
• Well-known Mandatory – Standard attributes supported by all BGP
implementations, and always included in every BGP update.
• BGP Route Type – Is this an eBGP or iBGP route? (eBGP routes are
preferred)
• Age – Which route is the oldest? (oldest is preferred)
• Router ID – Which route originated from the router with the lowest
BGP router ID?
• Peer IP Address – Which route originated from the router with the
lowest IP?
(Reference: http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a0080094431.shtml)
BGP v2.01
Weight
(Reference: http://www.cisco.com/warp/public/459/bgp-toc.html#weight)
BGP v2.01
Local Preference
Both RouterB and RouterD will include the Local Preference attribute in
updates to iBGP neighbors. Thus, RouterA (and RouterB) will now prefer
the route through RouterD to reach any destination outside the local AS.
Local Preference can be applied on a per-route basis:
RouterD(config)# ip prefix-list MYLIST 192.168.1.0/24
RouterD(config)# route-map PREFERENCE permit 10
RouterD(config-route-map)# match ip address prefix-list MYLIST
RouterD(config-route-map)# set local-preference 300
RouterD(config)# router bgp 10
RouterD(config)# neighbor 172.17.1.2 route-map PREFERENCE in
(Reference: http://www.cisco.com/warp/public/459/bgp-toc.html#localpref)
BGP v2.01
AS-Path Prepend
Notice the inflated AS-Path through RouterB. RouterC will prefer the path
through RouterD to reach the 10.5.0.0/16 network.
BGP v2.01
AS-Path Filtering
To view what BGP routing entries the AS-Path access-list will match:
RouterF# show ip bgp regexp _100$
(Reference: http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a0080094a92.shtml)
BGP v2.01
Origin
The Origin attribute identifies the originating source of the route. The
origin codes are as follows (listed in order of preference for route selection):
• i (IGP) – Originated from an interior gateway protocol, such as
OSPF. This usually indicates the route was injected into BGP via the
network command under the BGP process. An origin code of “i” is
most preferred.
• e (EGP) – Originated from an external gateway protocol.
• ? (incomplete) - Unknown origin. This usually indicates the route
was redistributed into BGP (from either connected, static, or IGP
routes). An origin code of “?” is the least preferred.
When viewing the BGP routing table, the origin code is listed at the end of
each line in the table:
RouterB# show ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 10.5.0.0 10.1.1.1 0 0 0 i
*> 192.168.1.0 172.16.1.2 0 100 0 900 ?
The i at the end of the first routing entry indicates the 10.5.0.0 network was
originated via an IGP, probably with the BGP network command. The
192.168.1.0 network was most likely redistributed into BGP in AS 900, as
evidenced by the ? at the end of that routing entry.
BGP v2.01
MED
RouterC will now have two entries for the 10.5.0.0/16 route:
RouterC# show ip bgp
Network Next Hop Metric LocPrf Weight Path
* 10.5.0.0 172.16.1.1 200 100 0 100 i
*> 10.5.0.0 172.17.1.1 0 100 0 100 i
Notice that the route from RouterB has a higher metric, and thus is less
preferred. Note specifically the lack of a > on the route with a higher metric.
The MED value is exchanged from one AS to another, but will never be
advertised further than that. Thus, the MED value is passed from AS 100 to
all BGP routers in AS 900, but the metric will be reset to 0 if the route is
advertised beyond AS 900.
BGP v2.01
MED (continued)
A key aspect to consider when using the MED attribute is BGP’s method of
route selection. Recall that if BGP contains multiple routes to the same
destination, it compares the routes in pairs, starting with the newest entries
and working towards the oldest entries.
This can lead to sub-optimal routing, depending on the order of routes in the
BGP routing table. BGP employs two MED-related commands to alleviate
potential sub-optimal routing selections.
The bgp deterministic-med command forces the MED value to be compared,
when multiple routes to the same network are received via multiple routers
from the same AS, regardless of the order of routes in the BGP routing table.
RouterE(config)# router bgp 100
RouterE(config-router)# bgp deterministic-med
MED (continued)
The MED metric on routes sent to eBGP neighbors can be dynamically set
to the actual metric of an IGP (such as OSPF). This is accomplished using
the set metric-type internal command with a route-map:
RouterB(config)# access-list 5 permit 10.5.0.0 0.0.255.255
RouterB(config)# route-map MED_INTERNAL permit 10
RouterB(config-route-map)# match ip address 5
RouterB(config-route-map)# set metric-type internal
RouterB(config)# router bgp 100
RouterB(config-router)# neighbor 172.17.1.2 route-map MED_INTERNAL out
If the 10.5.0.0/16 network originated in OSPF, the link-state cost metric for
that route will be applied as the MED metric.
BGP v2.01
Communities
BGP allows routes to be placed (or tagged) into certain Communities. BGP
routers can make route policy decisions based on a route’s community
membership.
BGP communities can be assigned using one of three 32-bit formats:
• Decimal (1000000)
• Hexadecimal (0x1A2B3C)
• AA:NN (100:20)
The AA:NN format specifies a 16-bit AS number (the AA), and a 16-bit
generic community identifier (NN).
By default, the decimal format for communities will be displayed when
viewing a route. To force the router to display the AA:NN format:
RouterA(config)# ip bgp-community new-format
(Reference: http://www.cisco.com/en/US/tech/tk365/technologies_q_and_a_item09186a00800949e8.shtml#four;
http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a00800c95bb.shtml#communityattribute)
BGP v2.01
Communities (continued)
BGP Summarization
Routes that are redistributed into BGP are automatically summarized. To
disable auto-summary:
Router(config)# router bgp 100
Router(config-router)# no auto-summary
The access-list details the routes that should be suppressed. To allow the
summarized routes to retain their AS-Path information:
Router(config)# router bgp 100
Router(config-router)# aggregate-address 172.16.0.0 255.255.252.0 summary-
only suppress-map SUPPRESS as-set
BGP v2.01
The above values for the set dampening command represent the defaults.
The 15 (measured in minutes) indicates the half-life timer. If a route is
assigned a penalty, half of the penalty will decay after this timer expires.
The 750 (arbitrary penalty measurement) indicates the bottom threshold.
Once a penalized route falls below this threshold, it will no longer be
suppressed.
The 2000 (arbitrary penalty measurement) indicates the top threshold. If a
route flaps to the point that its penalty exceeds this threshold, it is
suppressed.
The 60 (measured in minutes) indicates the maximum amount of time a
route can be suppressed.
Finally, route-dampening must be enabled under the BGP process:
Router(config)# router bgp 100
Router(config-router)# bgp dampening route-map MYMAP
(Reference: http://www.cisco.com/warp/public/459/bgp-rec-routing.html)
BGP v2.01
BGP Next-Hop-Self
Consider the above diagram. If RouterC sends the 192.168.1.0/24 route to its
eBGP peer RouterB, the Next Hop for that route will be through RouterC:
RouterB# show ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 192.168.1.0 172.16.1.2 0 100 0 900 i
A serious problem arises when RouterB sends this route to its iBGP peers
(RouterA and RouterD). The Next Hop value is not changed:
RouterA# show ip bgp
Network Next Hop Metric LocPrf Weight Path
* 192.168.1.0 172.16.1.2 0 100 0 900 i
Notice the lack of >, indicating this is no longer the best route to the
destination. This is because RouterA has no route to the next hop address.
There are two workarounds. Either the 172.16.0.0/16 network must be added
to RouterA’s and RouterD’s routing tables, or the Next-Hop field must be
adjusted to identify RouterB as the next hop.
The configuration is simple, and is completed on RouterB:
RouterB(config)# router bgp 200
RouterB(config-router)# neighbor 10.1.1.1 next-hop-self
RouterB(config-router)# neighbor 10.2.1.2 next-hop-self
RouterB now advertises itself as the next hop for all eBGP routes it learns:
RouterA# show ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 192.168.1.0 10.1.1.2 0 100 0 900 i
BGP v2.01
BGP Backdoor
Recall that an external BGP route has an Administrative Distance (AD) of
20, which is less than the default AD of IGP’s, such as OSPF or EIGRP.
Under certain circumstances, this may result in sub-optimal routing. If both
an IGP route and eBGP route exist to the same network, and the IGP route
should be preferred, there are two workarounds:
• Globally change BGP’s default Administrative Distance values.
• Use the BGP network backdoor command.
Cisco does not recommend changing BGP’s default AD values. If necessary,
however, the distance bgp will adjust the AD for external, internal, and
locally-originated BGP routes, respectively:
Router(config)# router bgp 100
Router(config-router)# distance bgp 150 210 210
(Reference: http://www.cisco.com/en/US/tech/tk365/technologies_tech_note09186a00800c95bb.shtml#bgpbackdoor)
BGP v2.01