Professional Documents
Culture Documents
BGP
(Border Gateway Protocol)
A
hm
ed
N
abi
l
July 2007
2 Overview
• BGPv4 is an Exterior Gateway Protocol (EGP) that can exchange routing updates
between different Autonomous Systems, so it operate mainly at the border of an AS.
• BGP is not designed to choose paths based on bandwidth, delay and other metrics,
but paths are chosen based on policy attributes.
• AS is a collection of networks under a single technical administration, AS is
identified by a unique number between 1 – 65535.The range 64512 - 65535 is
reserved for private use.
A
hm
ed
N
abi
l
3
When BGP is not appropriate?
1-Single connection to Internet or other AS
ﻧﻘص
A
hm
ed
N
abi
l
5 BGP C/Cs
• Reliable updates: BGP run on top of TCP port 179.
• Full BGP tables is exchanged at start-up.
• Incremental batched updates every 30 sec at change.
• BGP has no method for dynamic neighbor discovery, all neighbors
must be discover manually using the neighbor command.
• Updates is sent on unicast address to the statically configured
neighbors.
• Periodic keepalive messages to verify TCP connectivity.
• Use rich metrics called path attributes.
• Designed to scale huge internetworks.
• Support VLSM & CIDR (classless)
• Loop free (use BGP split-horizon & AS path list to avoid loops inside
AS and between ASs)
• Its symbol in routing table is B.
A
• External BGP has admin. distance 20. hm
ed
• Internal BGP has admin. distance 200. N
• BGP allows administrators to define policies or rules abi
l
for how data will flow through the Autonomous Systems.
6 BGP Tables
1-Neighbor table:
List of BGP neighbors "BGP peers" (configured statically with the
neighbor command & can be reachable)
1-Open message
It is used to open BGP session with a neighbor (Includes holdtime
and BGP router ID
2-Keepalive message
Periodic message that is sent to keep TCP session stay still
3-Update message
It contain information about destination networks and the attributes
to reach these networks
4-Notification message
Sent to identify that an error condition is detected for a certain router A
(i.e. memory or CPU error) hm
ed
N
abi
l
8
BGP neighbor states ﻣﺻطﻠﺢ
A
hm
ed
N
BGP Starts its operation when neighbors are statically defined, using abi
the neighbor command l
9
External BGP
• When BGP neighbors
belong to different
autonomous systems
they are called EBGP.
• EBGP neighbors, by
default, need to be
directly connected.
Internal BGP
•IGBP refers to the presence
of BGP neighbors within the
same AS.
A
• The neighbors do not have hm
ed
to be directly connected, N
because they can be reached abi
l
through an IGP.
10 Configuring BGP neighbors
A
This mean A is configuring B as iBGP hm
and C as eBGP ed
N
This mean B is configuring A as iBGP abi
l
11 BGP Start up Operation
after neighbor command is written
(config)#router bgp <as#>
(config-router)#neighbor <neighbor ip> remote-as < neighbor as# >
Idle state:
router is searching IP routing table to see if a route exists to reach the neighbor
Connect state:
router found route and has completed TCP 3-way handshake
Open sent:
open message is sent
Active state:
waiting confirmation on parameters to establish session
Open confirm:
receive agreement on parameters to establish session
A
Established state: hm
ed
peering is formed and routing exchange begins N
abi
l
12
BGP Start up Operation
Update
About
11.0.0.0 11.0.0.0
B has E in its neighbor table (using neighbor command), but for B to send update
about 11.0.0.0 to E the update is encapsulated in a packet with destination IP of E, but
there is no IGP running in the AS 65102, so B cant find a path for E in its routing A
table, so B will drop any updates going to E hm
ed
• Conclude: N
abi
IGP must run inside the AS, so as the BGP neighbors could be reachable l
14 2-BGP run on borders and IGP inside AS
4-Routing Table
No BGP
3-Update 11.0.0.0
4-Routing Table
No BGP
A
hm
ed
N
abi
l
16 BGP Synchronization
•Synchronization rule:
Do not use or advertise to an external neighbor a route learned by
IBGP until a matching route has been learned from an IGP.
• Ensures consistency of information throughout the AS
• Avoids black holes within the AS
• Safe to turn off if all routers in the AS are running full-mesh
IBGP, default.
Router(config-router)# no synchronization
• BGP Split horizon rule: "avoid routing loops inside the AS"
Route learned by iBGP neighbor can never be advertised back to another iBGP
neighbor
If Router A advertise a route to its eBGP neighbor B, so B must advertise that routes to
all it other neighbors, so B will advertise it to C & D, but due to split horizon rule, C
or D can never advertise that route again to their iBGP neighbor as E, so E will never
learn about that route.
A
hm
ed
• Conclude: N
abi
BGP must run in full mesh fashion (sessions between all BGP neighbors) to avoid l
split horizon rule
19 4-BGP must run in full mesh fashion
A
hm
• Full mesh BGP problem: ed
N
This will cause multiple TCP sessions, so a lot of CPU, memory abi
l
and bandwidth overhead will take place in the network
20
4-BGP must run in full mesh fashion
• Full mesh BGP problem:
The solution is to use:
1-Confederations:
divide the AS to sub ASs, where each Sub AS act with eBGP with other
sub Ass, so loops is avoided according to the eBGP rules (the advertised
route must contain a list of ASs that the route traverses, so if a router
finds its local AS in the AS path list it will detect that the update was
looped)
2-Route reflector:
to configure certain routers to override split horizon rule (route reflector
router)
A
hm
ed
N
abi
l
22
BGP considerations
1-Advertise routes in BGP updates (populate BGP table)
• Manual summarization
Method 1:
A
hm
ed
N
abi
l
25
Method 2:
(config)#router bgp <as#>
(config-router)#network <address> [mask <mask>]
This command was not designed to perform summarization by itself.
The aggregate-address command was designed for summarization.
• To use the network statement for summarization, the network number and mask used must
already exist exactly in the routing table.
• If the route was already summarized by EIGRP or OSPF, that summarization can be
أﻋﻠن
announced into BGP with the network and mask commands.
• If the route was not already summarized, a null static route must be created for BGP to
announce this summarization.
(config)#ip route <address> <mask> null0
A
hm
ed
N
abi
l
26 Cautions about Network Statement
• If a network statement is used for summarization,
do not use the more specific entries and the
summarized route as shown here.
• If both are used, the
summarized route and the
more specific routes will
be announced.
• 192.168.24.0/22 does not
exist in the IP routing table
without the null route.
• BGP will not announce the network
unless the summarized route
is already present in the
routing table.
A
hm
ed
N
abi
l
29 4-eBGP multihop
• Due to eBGP neighbors must be directly connected, so using
multiple links between the two neighbors, or using loopback as
source of update will cause a problem for the advertised updates
we can use the following command
(config-router)#neighbor <neighbor ip> ebgp-multihop [no. of
hops]
A
hm
ed
N
abi
l
30 5-Next hop behavior
• BGP is an AS by AS routing protocol, not a router by router routing protocol, so in BGP next
hop does not mean the next hop router, it means the ip address to reach the next AS
-Router A advertises
network 172.16.0.0 to
router B in EBGP, with
a next hop of 10.10.10.3.
-Router B advertises
172.16.0.0 in IBGP to
router C, keeping 10.10.10.3
as the next-hop address.
-So C see the next hop to reach
172.16.0.0 is 10.10.10.3
(next AS entry point)
To override that behaviour
(config-router)#neighbor <neighbor ip> next-hop-self
Forces all updates for this neighbor to be advertised with this router as the next hop. The IP
address used for the next-hop-self will be the same as the source IP address of the BGP
A
packet.
hm
ed
So if B has written N
(config-router)# neighbor 172.20.10.2 next-hop-self abi
So C will see 172.16.0.0 with next hop 172.20.10.1 l
31
Next Hop on a Multiaccess Network
The following takes place in a multiaccess
network:
• Router B advertises
network 172.30.0.0 to
router A in EBGP with
a next hop of 10.10.10.2,
not 10.10.10.1. This avoids
an unnecessary hop.
• BGP is being efficient by
informing AS 64520 of the
best entry point into AS 65000
for network 172.30.0.0.
A
hm
ed
N
abi
l
33
6-BGP peer groups
A
hm
ed
N
abi
l
34 Configuration without peer groups for 15 neighbor
(config)#router bgp <as#>
(config-router)#neighbor <ip> remote-as <as>
*15 times
(config-router)#neighbor <ip> route-reflector-client
*15 times
(config-router)#neighbor <ip> source-update loopback0
*15 times
(config-router)#neighbor <ip> next-hop-self
*15 times
(config-router)#neighbor <ip> route-map <name> <in/out>
*15 times
(config-router)#neighbor <ip> prefix-list <name> <in/out>
*15 times A
hm
(config-router)#neighbor <ip> distribute-list <name> <in/out> ed
N
*15 times abi
• we may need about 105 command on a single router l
35
Configuration with peer groups for 15 neighbor
(config)#router bgp <as>
(config-router)#neighbor <peer group name> peer-group
(config-router)#neighbor <ip> peer-group <peer group name>
*15 times
(config-router)#neighbor <peer group name> route-reflector-client
(config-router)#neighbor <peer group name> source-update loopback0
(config-router)#neighbor <peer group name> next-hop-self
(config-router)#neighbor <peer group name> route-map <name>
<in/out>
(config-router)#neighbor <peer group name> prefix-list <name>
<in/out>
(config-router)#neighbor <peer group name> distribute-list <name> A
hm
<in/out> ed
N
• we may need about 21 command on a single router abi
l
36
Example:
A
hm
ed
N
abi
l
38
8-Multihoming
• Multiple connections to ISP is required to increase reliability
(redundancy) and performance (load sharing)
– Reliability—If one ISP or connection fails, there is still
Internet access
– Performance—Better path selection to common Internet
destinations
• Types of connectivity:
1-Default routes from all providers
– Pass default route to internal routers
A
hm
ed
N
abi
l
40
Provider-Owned Routes and the Default Route from Each Provider
– Medium memory and CPU usage
– Best path to ISP-owned networks and to customer specific networks are
usually the shortest AS path
– Have ability to override path choice for some networks
– IGP metric to default route used for all other destinations
A
hm
ed
N
abi
l
41
Full Routes from All Providers
– Higher memory and CPU usage
– Reach all destinations by best path
• Usually shortest AS path
– Can manually tune all pathways
A
hm
ed
N
abi
l
42
Filter BGP Advertisements to ISPs
Router A Router B
A
Prevent a non-ISP (stub) AS from becoming a transit network by hm
performing route advertisement filtering using access lists. ed
N
abi
l
43
BGP attributes
A
hm
ed
N
abi
l
44
BGP attributes
Optional attributes:
recognised by some implementations (expected not to be
recognised by every router (depend on router position in AS))
Recognized optional attributes are propagated to other neighbors
based on their meaning
-Optional transitive
if not recognised are marked as partial and propagated to other
neighbors
(ex.: aggregator, community)
-Optional non transitive
discarded if not recognised
(ex.: MED (Multi Exit Discriminator))
A
hm
-Cisco Attribute: ed
N
local attribute on Cisco routers, it is not advertised in any updates abi
l
ex.: weight
45
1-AS path attribute
• The AS path attribute is Well known mandatory, transitive
A
hm
• A list of Autonomous Systems that a route has traversed ed
N
– For example, on router B, the path to 192.168.1.0 is abi
l
the AS sequence (65500, 64520).
46 2-Next hop attribute
• The next-hop attribute is Well known mandatory, transitive
• It provides an indication to routers in the inside of the AS about which path is preferred
to exit the AS (best way to leave the AS, it influence outbound traffic from AS)
A
hm
ed
N
abi
Any router inside the AS 64520 will prefer to exit that AS using path through A l
49 5-Multi Exit Discriminator (MED) attribute
• The MED is an optional, non transitive
• It is called metric
• Advertised between eBGP neighbors
• MED is an indication to eBGP neighbors about the prefered path to enter an
AS (affect how others can enter your AS, it influence inbound traffic to an AS)
• MED is used to advertise to EBGP neighbors how to exit their AS to reach
networks Owned by this AS.
• Lowest MED is prefered
• Default MED=0
• MED is not compared between neighbors from different ASs, unless
(config-router)#bgp-always-compare-med
• Configured locally on the router and is not propagated to any BGP neighbor
• Default weight for self originated routes are 32768, for other routes default is 0
(weight 0-65535)
A
hm
ed
N
abi
A will choose path through B l
to reach network 172.20.0.0
51 7-Atomic aggregate attribute
• Well known discretionary
• It informs the routers that the originating router has performed aggregation
(summarization) for routes, list of ASs that contain these routes can be
advertised (aggregate-address command)
8-Aggregator attribute
• Optional transitive
• It specifies the BGP router ID & AS no. of the router that perform the route aggregation
A
9- Community attribute hm
ed
• Optional transitive
N
• It is the grouping of routes and tag them for filtration actions abi
l
• All routes by default are members in a community called the Internet
52 BGP route selection process
• The BGP forwarding table usually has multiple pathways from
which to choose for each network.
A
hm
Best (>) pathways for networks 172.16.0.0/16 and 172.24.0.0/16 have not changed. ed
N
Best (>) pathway for network 172.30.0.0 has changed to a new next hop of 192.168.28.1 abi
due to the next hop of 192.168.28.1 having a higher local preference, 400. l
56
• MED is used when multiple pathways exist between two ASs
• A lower MED value is preferred.
• The default setting for Cisco is MED = 0.
• The metric is nontransitive.
• By default, MED is shared only between two Autonomous
Systems that have multiple EBGP connections with each other.
(config-router)#default-metric <value>
or
(config)#route-map <name> {permit/deny} [<seq no.>]
(config-route-map)#match ip address <acl #>
(config-route-map)#set metric <MED value>
•For all networks: Weight is equal (0); local preference is equal (100); routes are not originated
in this AS; AS path is equal (65001); origin code is equal (i). A
hm
• 192.168.24.0 has a lower metric (MED) through 172.20.50.2 (100) than 192.168.28.2 (200). ed
N
• 192.168.25.0 has a lower metric (MED) through 192.168.28.2 (100) than 172.20.50.2 (200).
abi
• 192.168.26.0 has a lower metric (MED) through 192.168.28.2 (100) than 172.20.50.2 (200). l
58 Route maps for BGP policy implementation
1-Create route map:
(config)#route-map <name> <permit/deny> [seq. no.]
(config-route-map)#match <conditions>
(config-route-map)#set <condition>
2-Activate route map:
(config-router)#neigbhor <ip/peer group> route-map <name> <in/out>
-Match conditions:
match ip address <acl#>
match community <community name>
-Set conditions:
set local-preference <no.>
set weight <no.>
set metric <no.>
set as-path <path list> A
hm
ed
N
abi
l
59
Verification and Troubleshooting
#sh ip bgp
#sh ip bgp summary
#sh ip route
#debug ip bgp [events/updates/keepalives]
#clear ip bgp <*/address>
(config-router)#[no] neighbor <ip/peer group> shutdown
A
hm
ed
N
abi
l
60
Verification and Troubleshooting
RouterA# show ip bgp summary
A
hm
ed
N
abi
l
63
Soft Reset Outbound
Router(config-router)#
neighbor [ip-address] soft-reconfiguration inbound
• This router stores all updates from this neighbor in case the inbound policy is changed.A
hm
• The command is memory-intensive. ed
Router# clear ip bgp {*|neighbor-address} soft in N
abi
• Uses the stored information to generate new inbound updates l
64
A
hm
ed
N
abi
l
65