BGP Sherif Summary
BGP Sherif Summary
BGP Sherif Summary
BGP ON CISCO ROUTERS
BGP Summary
Prepared by: Sherif Mokhtar
CCIE# 26013
Version Control:
Version 1: Created February 2010
Version 2: Edited April 2012
BGP Summary
Prepared by: Sherif Mokhtar – CCIE# 26013
Email: sherifmokhtar@hotmail.com
Introducing BGP, Why BGP
Routing protocols could be categorized as:
1- Interior Gateway Protocol (IGP)
2- Exterior Gateway Protocol (EGP)
IGP routing protocols don’t advertise routing tables, they advertise link states. The
distribution list affects the routing table not the link state data base.
The Border Gateway Protocol (BGP) allows you to create loop free interdomain routing
between autonomous systems [An autonomous system is a set of routers under a single
technical administration]
Routers in an AS can use multiple interior gateway protocols (IGP) to exchange routing
information inside the AS and an exterior gateway protocol to route packets outside the
AS.
The main function of BGP is to export the internal learned routes to the internet or to
import the outside learned routes to the AS. So, IGP protocol should be configured in
the autonomous system because the BGP works on top of the IGP.
Why BGP?
Scalable: Can carry routes of huge networks and internet
Batched updates.
Slow convergence: Neighbor is considered down after a hold down interval of 180
seconds (3 minutes).
Rich Metric: We can use any of BGP attributes to determine which path/link we can use,
not only the cost.
Security:
o Neighbors are manually configured on both routers
[BGP Summary] Prepared by: Sherif Mokhtar – CCIE# 26013
Email: sherifmokhtar@hotmail.com
o MD5 authentication
o Send unicast traffic.
o The source IP address of incoming connection attempts is verified against a list of
configured neighbors.
Reliable protocol: Use TCP to build neighborship between peers.
Note 1: Single-homed customer can use BGP with the SP in the below cases:
1. Customer multi-homed to the same provider.
2. Customer needs a dynamic routing protocol with the SP to detect failures.
In all other cases, use static routes.
Note 2:
AS number can be any number between 1–65535. This is the full range of AS numbers
that can be used in BGP
This AS range is divided into Private AS range and Public AS range (Like IP addresses):
o Private AS numbers: From 64512 to 65535. Any number of private AS range
can be used in private networks. Private AS numbers are never propagated onto
the public Internet.
o Public AS numbers: From 1 to 64511. This is used in routing Autonomous
systems in the Internet (Like public IP addresses)
BGP characteristics:
o Designed to route IP traffic through AS
o Designed to scale to huge Internetworks
o Currently in version 4
o By default, BGP finds the best path to a network using the best AS-path
o Routing policies are configure using BGP attributes
o It converges slowly. Batch (triggered) updates send once every 5 seconds for
iBGP peers and one every 30 seconds for eBGP peers.
o Uses TCP as its transport protocol (port 179)
BGP Tables:
BGP neighbor table ( show ip bgp summary) Contains list of all neighbors
BGP table ( show ip bgp) Contains all updates received from neighbors
After a BGP session is established, routing updates start to arrive. All inbound
updates are placed into the BGP table (debug ip bgp update).
When there is more than one way to reach a particular network, the local router
selects one of those as the best based on BGP selection criteria (Discussed later)
A local router propagates only the route that it selected as best to the neighbors.
However, the router never sends a route back on the same BGP session upon which it
was received.
The best BGP routes are copied into the IP routing table based on administrative
distance.
1. Network Command:
The network command controls what networks are originated by this box. This is a
different concept from what you are used to configuring with IGRP and RIP. With this
command we are not trying to run BGP on a certain interface, rather we are trying to
indicate to BGP what networks it should originate from this box. The mask portion is
used because BGP4 can handle subnetting and supernetting. A maximum of 200 entries
of the network command are accepted.
The network command will work if the network you are trying to advertise is
known to the router, whether connected, static or learned dynamically.
Example:
router bgp 1
network 192.213.0.0 mask 255.255.0.0
Note that we need the static route to get the router to generate 192.213.0.0 because the static
route will put a matching entry in the routing table. This is because network 192.213.0.0 is not
existing in the routing table, so we add a static route pointing to null in order to put this network
in routing table, then we can advertise it using BGP network command.
BGP summarization
1. BGP auto summarization
When using the aggregate-address command without the summary-only statement, both the
summarized network and the specific routes will be advertised. To only advertise the
summarized routes, use the summary-only statement. (Example: aggregate-address 10.16.0.0
255.255.0.0 summary-only)
Note: When automatic or manual summarization takes place, the routing protocol automatically
adds a static route with null 0 interface pointing to the summarized network in the routing table.
Benefits of sending only the aggregate address without the specific subnets:
• Smaller BGP routing tables
• More stable internetworks (less route flapping)
Drawback of sending only the aggregate address without the specific subnets:
• Problems with multihomed customers
Configuration:
R1
Show ip bgp 10.1.1.1 Displays detailed information about all paths for a single
prefix
debug ip bgp events Displays significant BGP events (neighbor state transitions,
update runs)
debug ip bgp updates Displays all incoming or outgoing BGP updates (Use with
caution)
IBGP is used if an AS wants to act as a transit system to other ASs. You might ask, why can’t we
do the same thing by learning via EBGP redistributing into IGP and then redistributing again into
another AS? We can, but IBGP offers more flexibility and more efficient ways to exchange
information within an AS; for example IBGP provides us with ways to control what is the best
exit point out of the AS by using local preference.
So we will build and IBGP session between router A and router D and send the updates through
this IBGP session
IBGP split horizon rule states that any IBGP received update should not be sent to
any other IBGP peer.
IBGP split horizon is enabled and can’t be disabled.
IBGP split horizon is a routing loop prevention mechanism for IBGP sessions.
To overcome the BGP discontinuity problem which results from IBGP split horizon,
one of the following solutions should be used:
Full mesh BGP setup with border routers.
Route Reflectors.
Confederations
Full mesh of IBGP sessions has to be established between all BGP-speaking routers in
the AS for proper IBGP route propagation.
The IBGP full mesh is a logical mesh of TCP sessions only; physical full mesh is not
required.
If the IP address of a loopback interface is used in the neighbor command, some extra
configuration needs to be done on the neighbor router. The neighbor router needs to tell BGP
that it is using a loopback interface rather than a physical interface to initiate the BGP neighbor
TCP connection. The command used to indicate a loopback interface is:
neighbor X.X.X.X update-source interface
EBGP multi-hop
In some special cases, there could be a requirement for EBGP speakers to be not directly
connected (OR EBGP is built using loopback interfaces instead of directly connected interfaces).
In this case EBGP multi-hop is used to allow the neighbor connection to be established between
two non directly connected external peers. The multi-hop is used only for external BGP and not
for internal BGP.
neighbor X.X.X.X ebgp-multihop
The next-hop attribute is not changed on IBGP updates, meaning that when the border router
forwards the BGP update on IBGP sessions, the next-hop address is still set to the IP address of
the far end of the EBGP session. Therefore, the receiver of IBGP updates will see the next-hop
information indicating a destination that is not directly connected. To resolve this problem, the
router will check its routing table and see if and how it can reach the next-hop address. But the
next-hop is not reachable in the transit AS routers, So it will drop the traffic.
Before we discuss synchronization let us look at the following scenario. RTC in AS300 is
sending updates about 170.10.0.0. RTA and RTB are running IBGP, so RTB will get the update
and will be able to reach 170.10.0.0 via next hop 2.2.2.1 (remember that the next hop is carried
via IBGP). In order to reach the next hop, RTB will have to send the traffic to RTE. Assume that
RTA has not redistributed network 170.10.0.0 into IGP, so at
this point RTE has no idea that 170.10.0.0 even exists. If RTB starts advertising to AS400 that he
can reach 170.10.0.0 then traffic coming from RTD to RTB with destination 170.10.0.0 will flow
in and get dropped at RTE.
Synchronization states: If your autonomous system is passing traffic from another AS to a third
AS, BGP should not advertise a route before all routers in your AS have learned about the route
via IGP. BGP will wait until IGP has propagated the route within the AS and then will advertise
it to external peers. This is called synchronization.
In some cases you do not need synchronization. If you will not be passing traffic from a different
autonomous system through your AS, or if all routers in your AS will be running BGP, you can
disable synchronization. Disabling this feature can allow you to carry fewer routes in your IGP
and allow BGP to converge more quickly.
Disabling synchronization is not automatic, if you have all your routers in the AS running BGP
and you are not running any IGP, the router has no way of knowing that, and your router will be
waiting forever for an IGP update about a certain route before sending it to external peers. You
have to disable synchronization manually in this case for routing to work correctly.
Notes:
Network designers used to use synchronization in older transit AS designs that relied on
BGP route redistribution into the IGP.
Modern AS designs don’t rely on synchronization anymore because the number of routes
carried in the internet exceeds the scalability range of any known IGP. So, redistribution
BGP into IGP is no longer applicable and the synchronization should be disabled.
Routes learned via BGP do not have an outgoing interface associated with them in the
routing table.
Recursive lookup is performed to forward IP packets toward external destinations.
A BGP route is installed in the IP routing table of a router only if the IP address in the
next-hop attribute is reachable according to the information already in the routing table
Traditional Cisco IOS software switching mechanisms perform recursive lookup when
forwarding the first packet.
o Fast switching, optimum switching.
CEF precomputes the routing table.
o All recursive lookups are performed while the routing table is built
Symptom An IBGP route is in the BGP table but is never selected as the best route.
Diagnosis The BGP next hop is not reachable.
Verification Use show ip bgp prefix to find the BGP next hop.
Use show ip route to verify next-hop reachability.
Symptom An IBGP route is selected as the best route but not entered into the IP
routing table.
Diagnosis BGP synchronization is not disabled.
Verification Disable BGP synchronization, clear the BGP sessions, and re-examine the IP
routing table after the BGP table becomes stable.
IBGP EBGP
IBGP:
The router chooses one IBGP path as the best path. The best path is then installed in the IP
routing table of the router.
The IBGP multipath load-sharing feature enables the BGP-speaking router to select multiple
IBGP paths as the best paths to a destination. The best paths, or multipaths, are then installed in
the IP routing table of the router.
For multiple paths to the same destination to be considered as multipaths, the following criteria
must be met:
All attributes must be the same. The attributes include weight, local preference, AS path
(entire attribute and not just length), origin code, multi-exit discriminator (MED), and
IGP distance.
The next hop router for each multipath must be different.
EBGP:
RTA#
int loopback 0
The above example illustrates the use of loopback interfaces, update-source and ebgp-multihop.
This is a workaround in order to achieve load balancing between two EBGP speakers over
parallel serial lines. In normal situations, BGP will pick one of the lines to send packets on and
load balancing would not take place. By introducing loopback interfaces, the next hop for EBGP
will be the loopback interface. Static routes (it could be some IGP also) are used to introduce two
equal cost paths to reach the destination. RTA will have two choices to reach next hop
160.10.1.1: one via 1.1.1.2 and the other one via 2.2.2.2 and the same for RTB.
Show ip bgp neighbor X.X.X.X advertised-routes Displays all the routes that the router has
advertised to the neighbor
Show ip bgp neighbor X.X.X.X received-routes Displays all the received routes (Both
accepted and rejected) from the specified
neighbor
Show ip bgp neighbor X.X.X.X routes Displays all the router that are received and
accepted.
Cisco IOS deals with the AS-Path as a string. For the IOS to know the beginning,
the end and other specification of the string, the string should have delimiters
(markers).
IOS uses Regular Expression as a tool to mach the AS-Path.
The following are some common used delimiters:
^ : Start of the string
$ : End of the string
. : Any single character
_ : Space
* : Repeated zero or more times
? : Repeated zero or one times
+ : Repeated once or more times
[] : Range of characters
- : Used to specify range (i.e. [0-9] )
( ) : Logical grouping
Example:
o BGP routes which pass through (via) AS# 23 are represented by reg-exp _23_
o BGP routes which are generated in AS# 100 are represented by reg-exp _100$
Expression Meaning
.* Anything
^$ Locally originated routes (Generated in
local AS)
^100_ Learned from AS 100
_100$ Originated in AS 100
^[0-9]+$ Directly connected ASes
Exercises:
1- Create a filter to prevent AS from acting as a transit AS.
ip as-path access-list 5 permit ^$
neighbor <ip address> filter-list 5 out
-------------------------------------------------------------------------------------------------------------------
2- Accept only BGP routes originated in your directly connected autonomous system.
ip as-path access-list 7 permit ^([0-9]+)(_\1)*$
neighbor <ip address> filter-list 7 in
-------------------------------------------------------------------------------------------------------------------
3- Accept all BGP routes.
ip as-path access-list 10 permit .*
neighbor <ip address> filter-list 10 in
5-
block updates about 160.10.0.0 from going to AS100
RTC#
router bgp 300
neighbor 3.3.3.3 remote-as 200
neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 filter-list 1 out
ip as-path access-list 1 deny ^200$
ip as-path access-list 1 permit .* permit any
Monitoring AS-Path Filters
Monitoring AS Path filters
Examples:
ip prefix-list A permit 0.0.0.0/0 ge 32 All host routes (Host means /32 subnets)
ip prefix-list B permit 128.0.0.0/2 ge 17 Any subnet in Class B address space
ip prefix-list C permit 0.0.0.0/0 le 32 All routes (permit any)
ip prefix-list D permit 0.0.0.0/0 Default route
ip prefix-list E permit 0.0.0.0/1 le 24 Any prefix in class A address space
covering at least 256 addresses
0.0.0.0/1 Class A
128.0.0.0/2 Class B
192.0.0.0/3 Class C
Private range:
10.0.0.0 10.255.255.255 10.0.0.0/8 le 32
172.16.0.0 172.31.255.255 172.16.0.0/12 le 32
192.168.0.0 192.168.255.255 192.168.0.0/16 le 32
Network Classes:
o Class A: 0.0.0.0 127.255.255.255
Classful class A: 0.0.0.0/1 ge 8 le 8
Classless class A: 0.0.0.0/1 le 32
o Class B: 128.0.0.0 191.255.255.255
Classful class B: 128.0.0.0/2 ge 16 le 16
Classless class B: 128.0.0.0/2 ge 17
o Class C: 192.0.0.0 223.255.255.255
Classful class C: 192.0.0.0/3 ge 24 le 24
Classless class C: 192.0.0.0/3 le 32
Multicast range:
224.0.0.0 239.255.255.255 224.0.0.0/4 le 32
Configuration:
ip prefix-list list-name [seq seq] {permit|deny} network/len [ge value] [le value]
neighbor {ip-address|peer-group-name} prefix-list prefix-listname {in|out}
Mach + Set:
No Mach + Set:
* No need for an additional statement to permit all routes since the first statement will do this.
Mach + No Set:
* No need for an additional statement to permit all routes because we need to filter out the routes that
don’t match the prefix list.
Note: The best way to set any BGP attribute is through the rout-map.
BGP Filters
Q.1) How does the router knows if its neighbor supports the standard inbound soft
reconfiguration?
One of the optional parameters that sent with the open message is the capabilities of each
router. If the standard inbound soft reconfiguration is supported by the router, it will be
mentioned in the capabilities parameter.
Note: For Transitive attributes, a partial bit is set to indicate that the attribute was not recognized.
Origin:
The Origin attribute is Mandatory, well-known attribute.
The Origin attribute means how the BGP route was generated (The origin of the path
information). There are two ways to generate the BGP route:
If the route generated using the Network statement, then route will be marked by
i-IGP.
If the route generated using redistribution, then route will be marked as unknown
(?).
AS-Path:
The AS-Path attribute is Mandatory, well-known attribute.
The AS-path attribute is empty when a local route is inserted in the BGP table.
The AS number of the sender is prepended to the AS-Path attribute when the routing
update crosses AS boundary.
The receiver of BGP routing information can use the AS-path attribute to determine
through which AS the information has passed.
There are 3 main reasons to configure the AS number under the BGP routing process:
To determine if the neighbor is IBGP or EBGP.
To prepend the local AS to the AS-Path for EBGP neighbors.
AS-Path Prepending:
Next Hop:
If the receiving BGP router is in the same subnet as the current next-hop address, the next-hop
address remains unchanged to optimize packet forwarding.
BGP next-hop processing can break connectivity with improper network designs over partially
meshed WAN networks.
Atomic aggregate
Informs the neighbor AS that the originating router aggregated routes ( Informs the
neighbor AS the routes are aggregated)
Has no effect on route selection criteria.
Aggregator
Specifies IP address and AS number of the router that performed route aggregation.
BGP Community:
The BGP community is an optional transitive attribute.
BGP communities are a means of tagging routes to ensure consistent filtering or route
selection policy.
Routers that do not support communities pass them along unchanged.
Any BGP router can filter routes in incoming or outgoing updates or select preferred
routes based on communities.
The community is represented by 32 bits (range 0 to 4,294,967,200)
Values of all zeroes and all ones in high-order 16 bits are reserved.
Example:
R1 Configuration:
1) Create the policy:
route-map Set-Community 10
set community 100:200 [additive] Additive key word make the
community to be added to any previous community.
2) Apply the policy to a neighbor:
neighbor <R2> route-map Set-Community out
neighbor <R2> send-community
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
There are 2 methods to affect the outgoing traffic (Tune incoming updates):
Weight
Local Preference
There are three methods to affect the returned back (incoming) traffic (Tune outgoing updated):
MED
AS-Path Prepending
BGP Community
Route Reflectors:
Route Reflector disables BGP split horizon. Can cause disaster to the network if configured
incorrectly because it may cause routing loops.
Route reflectors modify the classical IBGP split horizon rules and allow a particular router to
forward incoming IBGP updates to outgoing IBGP sessions under certain conditions. This
router becomes a concentration router, or a rout reflector.
When you implement a route-reflector-based IBGP network, the BGP routers are divided
into; route reflectors and clients.
Choose the router which has a direct link to most of the other routers to be a route reflector
and it’s connected routers will be route reflector clients.
All route reflectors in an AS should be fully meshed.
Route reflector clients are excluded from the full mesh.
A client may have IBGP sessions to more than one route reflector to avoid a single point of
failure.
In huge BGP environments, dedicated route reflectors are recommended.
Each route reflector client can have any number of EBGP sessions but must have IBGP
session(s) with its route reflectors only.
When a route is reflected, the route reflector will set the originator-ID BGP attribute
(optional non-transitive BGP attribute) to the router-ID of the peer from which it received the
R1:
no router bgp 64000
router bgp 64512
bgp confederation identifier 64000
bgp confederation peers 64513 64514 64515
Note: The bgp confederation peers command is used to inform the local BGP router about the
member autonomous systems that it is going to peer with, so that it follows the
intraconfederation BGP session rules when sending updates to them.
Peer groups are fundamental BGP scalability tool and should be used in all environments
where a router has a large number of BGP neighbors.
BGP peer groups helps to reduce the amount of redundant BGP configurations.
BGP peer groups names are locally significant on the router, the name of the group is not
passed to other routers.
Don’t put IBGP and EBGP peers in the same peer group.
Some peer group parameters can be overridden by neighbor configurations only if the
individual configurations apply on incoming updates.
Cisco IOS software assigns a peer group leader. Outgoing updates to the peer group
members are always prepared for the peer group leader and then replicated to the other
members of the peer group.
Example:
neighbor IBGP-Peers peer-group
Examples:
neighbor IBGP-Peers remote-as 64515
neighbor IBGP-Peers password cisco
3. Add neighbors with the same parameters to the same peer group.
neighbor <ip address> peer-group <peer-group-name>
Example:
neighbor 10.1.1.1 peer-group IBGP-Peers
Route-Dampening Operation:
Each time an EBGP route flaps, it gets 1000 penalty points (IGBP routes are not
dampened).
The penalty placed on a route decays according to the exponential decay algorithm.
When the penalty exceeds the suppress limit, the route is dampened (no longer used or
propagated to other neighbors).
A dampened route is propagated when the penalty drops below the reuse limit.
The flap history is forgotten when the penalty drops below half of the reuse limit.
A route is never dampened for more time than the maximum suppress limit.
An unreachable route with a flap history is put in the history state—it stays in the BGP
table but only to maintain the flap history.
A penalty is applied on the individual path in the BGP table, not on the IP prefix.
clear ip bgp dampening [ip-address network-mask] Releases all the dampened routes or just
the specified network
Dampening Example:
Neighbor flapped for the first time:
After the third flap, the penalty of the route exceeds the suppress limit, and the route could
be suppressed.
When the route exceeds the suppress limit, one of two things could happen:
The penalty of the route is decreased following an exponential curve. After a while, the penalty drops below the
suppress limit, but the route is not yet released—the route is released only after the penalty drops further below the
reuse limit.
We need extra configuration in order to allow BGP to send a default route to neighbor.
“neighbor ip-address default-originate”
The “neighbor default-originate” command advertises the default route to a BGP
neighbor even if the default route is not present in the BGP table
Note: The default route is not sent through the outbound BGP filters (prefix-list, filter-list, or
route-map).
The neighbor local-as command is used initially to configure BGP peers to support two local AS
numbers to maintain peering between two separate BGP networks.
This configuration allows the ISP to immediately make the transition without any impact on
existing customer configurations.
When the customer configurations have been updated, the next step is to complete the transition
from the old AS number to the new AS number.
The key work no-prepend Configures the router to not prepend the local AS number to any
routes received from an external peer.
replace-as: Optional keyword allows the router to prepend only the local AS number to the AS-
path attribute.
The AS number from the local BGP routing process is not prepended.
dual-as: Optional keyword allows the router to configure the EBGP neighbor to establish a
peering session using the real AS number (from the local BGP routing process) or by using the
AS number configured with the ipaddress
argument (local-as)
Consider the above diagram, RTA and RTC are running EBGP and RTB and RTC are running
EBGP. RTA and RTB are running some kind of IGP (RIP, IGRP, etc.) By definition, EBGP
updates have a distance of 20 which is lower than the IGP distances. Default distance is 120 for
RIP, 100 for IGRP, 90 for EIGRP and 110 for OSPF.
RTA will receive updates about 160.10.0.0 via two routing protocols: EBGP with a distance of
20 and IGP with a distance higher than 20.
By default, BGP has the following distances, but that could be changed by the distance
command:
distance bgp external-distance internal-distance local-distance
external-distance:20
internal-distance:200
local-distance:200
RTA will pick EBGP via RTC because of the lower distance. If we want RTA to learn about
160.10.0.0 via RTB (IGP), then we have two options:
1. Change EBGP’s external distance or IGP’s distance which is NOT recommended.
2. Use BGP backdoor
BGP backdoor will make the IGP route, the preferred route. Use the following command:
network address backdoor.
The configured network is the network that we would like to reach via IGP. For BGP this
network will be treated as a locally assigned network except it will not be advertised in bgp
updates.
At Router A:
network 160.10.0.0 backdoor
Now, RTA will learn 160.10.0.0 from RTB via EIGRP with distance 90, and will also learn it
from RTC via EBGP with distance 20. Normally EBGP will be preferred, but because of the
backdoor command EIGRP will be preferred.