Escolar Documentos
Profissional Documentos
Cultura Documentos
2
Terms
6
When to use BGP and when not to use BGP
Use BGP when the effects of BGP are well understood and one of the following
conditions exist:
The AS allows packets to transit through it to reach another AS (transit AS).
The AS has multiple connections to other ASs.
The flow of traffic entering or exiting the AS must be manipulated.
This is policy based routing and based on attributes.
7
When to use BGP and when not to use BGP
Do not use BGP if you have one or more of the following conditions:
A single connection to the Internet or another AS
No concern for routing policy or routing selection
A lack of memory or processing power on your routers to handle constant
BGP updates
A limited understanding of route filtering and BGP path selection process
Low bandwidth between ASs
8
Who needs BGP?
9
Overview of autonomous systems
AS - A group of routers that share similar routing policies and operate within
a single administrative domain.
An AS can be a:
Collection of routers running a single IGP (Single company)
Collection of routers running different protocols all belonging to one
organization (ISP)
In either case, the outside world views the entire Autonomous System as a
single entity.
10
Overview of autonomous systems
AS Numbers
Assigned by an Internet registry or a service provider.
Between 1 and 65,535.
0 - Reserved
1 through 64,495 Assignable for public use
64,512 through 65,535 - Private use
This is similar to RFC 1918 IP addresses.
65,535 - Reserved
Because of the finite number of available AS numbers, an organization must
present justification of its need before it will be assigned an AS number.
11
Today, the Internet Assigned Numbers Authority (IANA) is enforcing a policy
whereby organizations that connect to a single provider and share the
provider's routing policies use an AS number from the private pool, 64,512
to 65,535.
12
RFC 4893 BGP Support for Four-Octet AS Number Space describes 32 bit
AS numbers the anticipated depletion of current BGP 16-bit AS numbers
http://www.cisco.com/en/US/prod/collateral/iosswrel/ps6537/ps6554/ps659
9/white_paper_C11_516823.html
http://www.potaroo.net/tools/asn16/
http://www.iana.org/assignments/as-numbers/as-numbers.xml
13
Using BGP
14
Connection Redundancy
The ISP connection can also be made redundant.
A customer can be connected to a single ISP or to multiple ISPs.
15
Single-homed autonomous systems
Single-homed system AS
One Link per ISP, One ISP
Only one exit point to outside networks.
Often referred to as stub networks or stubs.
Usually use a default route to handle all traffic destined for non-local
networks.
BGP is not normally needed in this situation
16
Single-homed autonomous systems
IGP Option
IGP: Both the provider and the customer use an IGP to share information
regarding the customer's networks.
Customer:
Sends public network address
Receives default route 17
Single-homed autonomous systems
BGP Option
In a single-homed autonomous system the customer's routing policies
are an extension of the policies of the provider.
Internet number registries are unlikely to assign public AS number.
AS number from the private pool of AS numbers, 64,512 to 65,535.
The provider will strip off these numbers when advertising the
customer's routes towards the core of the Internet. (later)
18
Dual Homed
Option 3
Dual-homed AS
Two or more links per ISP, One ISP
Same options as single-homed
Additional advantages:
Primary and backup link functionality
Load Balancing
19
Single Multi-homed
21
Dual Multi-homed
Dual Multi-homed
Two or more links per ISP, Two or more ISPs
Similar options as Single Multi-homed
Same benefits as single multi-homed but with enhanced resiliency.
22
Using BGP in an Enterprise Network
23
Transit
AS
Multihomed system
More than one exit point to outside networks.
May be a:
Transit
Non-transit AS
Transit traffic - Traffic that has a source and destination outside the AS.
Transit AS - allows transit traffic
Non-transit AS - does not allow transit traffic.
Advertises only its own routes to both the providers
Does not advertise routes it learned from one provider to another.
Therefore, ISP1 will not use AS 24 to reach destinations that belong to ISP2
24
and visa versa.
AS 65500 is learning routes from both ISP-A and ISP-B via EBGP
Also running IBGP on all of its routers. (later)
Learns about routes and chooses the best way to each one based on the
configuration of the routers in the AS and the BGP routes passed from the
ISPs.
If one of the connections to the ISPs goes down, traffic will be sent
25
through the other ISP.
Transit AS
AS 65500 wants to have a redundant Internet connection, but does not want
to act as a transit AS between ISP-A and ISP-B.
AS 65500 learns from ISP-A is the route to 172.18.0.0/16.
If that route is:
Propagated through AS 65500 using IBGP
And mistakenly announced to ISP-B
Then ISP-B might decide that the best way to get to 172.18.0.0/16 is
through AS 65500, instead of through the Internet.
AS 65500 would then be considered a transit AS (an ISP)
Not a very undesirable situation
26
Careful BGP configuration is required to avoid this situation.
Default Route Default Route
+ ISP1 Routes
AS 65500
Send Networks Send
0.0.0.0/0 0.0.0.0/0
AS 65500
Networks Sends ISPB
Sends ISPA
Prefixes and
Prefixes and
0.0.0.0/0
0.0.0.0/0
Both ISPs pass default routes
plus select specific routes to
the AS.
The internal routers of the customer can receive these routes via:
Redistribution into IGP
IBGP transit path (later)
The internal routers route packets:
ISP A networks via ISP A
ISP B networks via ISP B
Default routes via nearest edge router (possible suboptimal routing)
29
Multihoming with Full
Routes from All Providers
All ISPs pass all routes to the
AS
IBGP is run on at least all the AS 65500
routers in the transit path in this Sends all Networks Sends all
Internet
AS. Internet
Routes
Routes
Requires a lot of resources
within the AS because it must
process all the external routes.
The internal routers of the customer can receive these routes via:
Redistribution into IGP (ex: OSPF): Not recommended!
IBGP transit path (later): Well say this is the case.
The ISP that a specific router within AS 64500 uses to reach the external
networks is determined by the IBGP protocol.
The routers in AS 64500 can be configured to influence the path to certain
networks.
For example, Router A and Router B can influence the outbound traffic from AS
64500. (Later - Attributes) 30
BGP Path Vector Characteristics
Path Advertised:
64520 64600 64700
Networks in AS 64700:
192.168.24.0
192.168.25.0
172.20.0.0
32
172.16.0.0/16
(4, 2, 1)
Loop Free Path 172.16.0.0/16
(6, 5, 3, 1) AS7
AS4
AS6
AS2
AS_PATH
List of AS numbers associated with a BGP route
One of several path attributes associated with each route.
Path attributes will be discussed in much more detail later.
We will discuss how BGP chooses best path later.
The shortest inter-AS path is very simply determined by the least number of AS
numbers.
In this example, AS7 will choose the shortest path (4, 2, 1).
We will see later what happens with equal cost paths.
33
172.16.0.0/16
(7,4,2,1)
172.16.0.0/16
(8,7,4,2,1)
AS9 172.16.0.0/16
(4, 2, 1)
X AS7
172.16.0.0/16
(9,8,7,4,2,1)
AS4
AS6
AS2
34
Possible paths for AS 64512 to reach networks in AS 64700, through AS
64520:
64520 64600 64700
64520 64600 64540 64550 64700
64520 64540 64600 64700
64520 64540 64550 64700
AS 64512 does NOT see all these possibilities.
AS 64520 advertises to AS 64512 only its best path:
64520 64600 64700 (assuming no other policies supersede AS Path)
AS 64512 could also get a best path from AS 64530
AS 64512 would then decide which path is best (via 64530 or via 64520)
35
based on its own AS policies.
Multihomed nontransit autonomous systems
Here are the
Here are the
networks you can
networks you
reach through me.
can reach
I will try and make it
through me.
so that you prefer
me.
We have a choice
on which way to
send our traffic.
36
Multihomed nontransit autonomous systems
37
BGP Hazards Inadvertent Transit Domain
38
BGP Hazards Doyle, Routing TCP/IP
BGP Peering
Creating a BGP peering relationship involves an interesting
combination of trust and mistrust.
You must trust the network administrator on that end to know what
they are doing.
At the same time, if you are smart, you will take every practical
measure to protect yourself in the event that a mistake is made on
the other end.
Paranoia is your friend. 39
BGP Hazards Doyle, Routing TCP/IP
Your ISP will show little patience with you if you make mistakes in your BGP
configuration.
Suppose, for example, that through some misconfiguration you advertise
207.46.0.0/16 to your ISP.
On the receiving side, the ISP does not filter out this incorrect route, allowing
it to be advertised to the rest of the Internet.
This particular CIDR block belongs to Microsoft, and you have just claimed to
have a route to that destination.
A significant portion of the Internet community could decide that the best
path to Microsoft is through your domain.
You will receive a flood of unwanted packets across your Internet connection
and, more importantly, you will have black-holed traffic that should have gone
to Microsoft.
They will be neither amused nor understanding.
40
YouTube Hijacking: A RIPE NCC
RIS case study
YouTube Hijacking: A RIPE NCC RIS case study
This presentation is taken from RIPE NCC web site.
For more detailed information, please consult this web site:
http://www.ripe.net/news/study-youtube-hijacking.html
Internet
BGP
Internet
BGP
208.65.152.0/22
44
Before, during and after Sunday, 24 February 2008
Internet
BGP
208.65.152.0/22
45
Before, during and after Sunday, 24 February 2008
Internet
2 hops 1 hop
BGP
3 hops 1 hop
2 hops
BGP
Unless other policies are used, routers will choose the shortest AS path.
This is a simplification of BGP, assuming shortest AS-Path is being used.
46
Before, during and after Sunday, 24 February 2008
www.youtube.com ip route 206.63.153.0 255.255.255.0 null0
206.65.153.0/24
Internet
2 hops 1 hop
BGP
3 hops 1 hop
2 hops
Pakistan Telecom
Wants to block traffic within its own AS from going to www.youtube.com.
Note: Details of how they did this is not known at them time this presentation
was created.
Most likely they created a route within their own AS that sent any traffic to
208.65.153.0/24 (DNS address for www.youtube.com) to a non-existent
network, in effect denying their own customers access to www.youtube.com.
47
Their mistake was that they propagated this route to PCCW Global.
Sunday, 24 February 2008, 18:47 (UTC)
Internet
2 hops 1 hop
2 hops 3 hops
BGP
BGP
? 208.65.152.0/22
208.65.153.0/24
Dest IP = 208.65.153.251
Why do the ISP routers forward traffic to Pakistan Telecom?
When a router receives packets for 208.65.153.251 which path will it
choose?
Routers will learn about both 208.65.153.0/24 and 208.65.152.0/22
networks and install the both routes in their routing tables.
When a router receives packets for 208.65.153.251 it will choose the
longest prefix match (more specific match): 208.65.153.0/24
49
24 bits is a longer (better) match than 22 bits
Sunday, 24 February 2008, 20:07 (UTC):
Internet
Routed traffic to
youtube.com
BGP
208.65.152.0/22
208.65.153.0/24 208.65.153.0/24
Internet
Routed traffic to
youtube.com
BGP
208.65.152.0/22
208.65.153.0/24 208.65.153.0/24
208.65.153.0/25
208.65.153.128/25
Internet
Routed traffic to
youtube.com
BGP
208.65.152.0/22
208.65.153.0/24 208.65.153.0/24
208.65.153.0/25
For CCNP students 208.65.153.128/25
Internet
Routed traffic to
youtube.com
X BGP
208.65.152.0/22
208.65.153.0/24 208.65.153.0/24
208.65.153.0/25
208.65.153.128/25
57
There are several requirements for EBGP neighborship:
Different AS number:
EBGP neighbors must reside in different autonomous systems to be
able to form an EBGP relationship.
Define neighbors:
A TCP session must be established prior to starting BGP routing update
exchanges.
Reachability:
The IP addresses used in the neighbor command must be reachable
58
EBGP neighbors are usually directly connected.
EBGP
RTA(config)#router bgp 100
RTA(config-router)#
The remote-as value (200) is the same routers will attempt to establish an
IBGP session.
Note: AS 200 is not a remote AS , for simplicity, the keyword remote-as is
used.
63
Transit Path
Transit Path
64
IBGP in a Transit AS
Transit Path
Transit Path
BGP was originally intended to run along the borders of an AS, with the
routers in the middle of the AS ignorant of the details of BGP
A transit AS is an AS that routes traffic from one external AS to another
external AS.
Transit autonomous systems are typically ISPs.
All routers in a transit path must have complete knowledge of external routes.
Run IBGP on all routers within the AS transit path
Redistribute BGP routes into an IGP at the edge routers (however, this
approach has problems) 65
IBGP in a Nontransit AS
X
X I learned about networks from
ISP2 but I cant tell ISP1 or ISP1
might forward packets to me to get
to those networks making me a
transit AS.
A Nontransit AS:
AS multihoming with two ISPs
But does not pass routes between the ISPs
66
BGP Peers
IBGP
IBGP
EBGP
The designers of BGP could not guarantee that an AS would run BGP on all routers
So a method had to be developed to ensure that IBGP speakers could pass updates to one
another while ensuring that no routing loops would exist.
All IBGP routers (in the transit path) need to peer with each other (full mesh)
Note: Although this presentation refers to all IBGP routers in the transit path must be
fully-meshed, it is recommended that all IBGP routers in the AS are fully-meshed IBGP.
This will be discussed in Part 2.
BGP specifies that routes learned through IBGP are never propagated to other IBGP
peers.
By default, each BGP speaker is assumed to have a neighbor statement for all other IBGP
speakers in the ASthis is known as full mesh IBGP.
When a change is received from an external AS:
The BGP router is responsible for informing all other IBGP neighbors of the change.
67
IBGP neighbors that receive this update do not send it to other IBGP neighbors
BGP Partial-Mesh and Full-Mesh Examples
68
IBGP update behavior in a partially meshed neighbor environment
BGP Update
BGP Update
In this example, Routers A, B, E, and F are the only ones running BGP.
Router B has an:
EBGP neighbor statement for Router A
IBGP neighbor statement for Router E
Router E has an:
EBGP neighbor statement for Router F
IBGP neighbor statement for Router B.
Routers C and D are not running BGP.
71
Routers B, C, D and E are running OSPF as their IGP.
BGP Update
Network
10.0.0.0
72
BGP Update
Packet to
Network
Network 10.0.0.0
10.0.0.0
No route to 10.0.0.0
Drop packet
So far
Routers A, B, E and E all know about the 10.0.0.0 network
Routers C and D do not have a route for the 10.0.0.0 network
If Router F has a packet for 10.0.0.0
Router F would forward the packet to Router E
Router E would send the packets to its BGP peer, Router B
To get to Router B packets must go through Router C or D
Neither of these routers have an entry in their routing tables for
network 10.0.0.0.
When this packet to 10.0.0.0 is forwarded to either Routers C or D,
those packets would be discarded. 73
BGP Update
Transit Path
Packet to
Network
Network Transit Path 10.0.0.0
10.0.0.0
Default Route
Even if Routers C and D have a default route going to the exit points of the
AS (Routers B and E)
Those packet for 10.0.0.0 might go back to Router E causing a routing
loop.
To solve this problem:
BGP must be implemented on all routers in the transit path
Routers C and/or D
This leads us to the question Can BGP help ensure that all routers AS
65102 know about these external networks in other ASs?
74
I learned about 172.16.0.0 via IBGP from
Router B. I will not advertise 172.16.0.0 to
BGP Synchronization Router E via EBGP unless I see this network
in my routing table leaned via an IGP (OSPF).
Note: There is not a physical
link b/t A and B
?
OSPF IBGP
AS 65000 networks
Into OSPF
BGP synchronization rule states: A BGP router should not use or advertise
to an external BGP neighbor a route learned by IBGP, unless that route is
directly connected or learned from the IGP.
In the past this use to be the default.
If there were small enough number of BGP routes they could be
redistributed into the IGP (by Router A and Router B).
Routers C and D would then know about 172.16.0.0 and all AS 65000
networks via redistribution by Router B.
Then IBGP would not have to run on all routers in the transit path.
75
I learned about 172.16.0.0 via IBGP from
Router B. I will not advertise 172.16.0.0 to
BGP Synchronization Router E via EBGP unless I see this network
in my routing table leaned via an IGP (OSPF).
?
OSPF IBGP
AS 65000 networks
Into OSPF
It is important that Router C and Router D learn about the networks from AS
650000 (172.16.0.0).
Otherwise, when Router A forwards a packet to Router C destined for
172.16.0.0, Router C would drop the packet because that network is not in
its routing table.
This is why synchronization was the default on BGP routers.
However, in the modern Internet it not practical to redistribute so my
networks into the IGP this is no longer the best practice!
76
No BGP I learned about 172.16.0.0 via IBGP from
Router B. I can
will not
advertise
advertise
172.16.0.0
172.16.0.0
to to
?
OSPF IBGP
AS 65000 networks
Into OSPF
OSPF
BGP Update
BGP Routing
Table Table
Network Network
79
WLam
Summary of the BGPWeight Path Selection Process
BGP uses the following Localcriteria, in the order presented, to select a path for a
Preference
destination:
NOTE: Not all of these as path
are commonly used and will be examined in more
detail later in this presentation
med and in the next presentation.
1. If the path specifies a next hop that is inaccessible, drop the update.
2. Prefer the path with the largest weight.
3. If the weights are the same, prefer the path with the largest local preference.
4. If the local preferences are the same, prefer the path that was originated by
BGP running on this router.
5. If no route was originated, prefer the route that has the shortest AS_path.
6. If all paths have the same AS_path length, prefer the path with the lowest
origin type (where IGP is lower than EGP, and EGP is lower than Incomplete).
7. If the origin codes are the same, prefer the path with the lowest MED
attribute.
8. If the paths have the same MED, prefer the external path over the internal
path.
9. If the paths are still the same, prefer the path through the closest IGP
neighbor.
10. Prefer the path with the lowest IP address, as specified by the BGP router ID
80
BGP Message Types
Before establishing a BGP peer connection the two neighbors must perform
the standard TCP three-way handshake and open a TCP connection to port
179.
After the TCP session is established, BGP peers exchanges several
messages to open and confirm connection parameters and to send BGP
routing information.
All BGP messages are unicast to the one neighbor over the TCP
connection.
There are four BGP message types:
Type 1: OPEN
Type 2: KEEPALIVE
Type 3: UPDATE
Type 4: NOTIFICATION
81
Type 1:
BGP Open Message
After the TCP session is established, both neighbors send Open messages.
This message is used to establish connections with peers.
Each neighbor uses this message to identify itself and to specify its BGP
operational parameters including:
BGP version number (defaults to version 4)
AS number: AS number of the originating router, determines if BGP
session is EBGP or IBGP.
BGP identifier: IP address that identifies the neighbor using the same
method as OSPF router ID.
Optional parameter: authentication, multiprotocol support and route
refresh.
82
Type 2: BGP Keepalive Message
The UPDATE messages contain all the information BGP uses to construct a
loop-free picture of the internetwork.
Update messages advertises feasible routes, withdrawn routes, or both.
The three basic components of an UPDATE message are:
Network-Layer Reachability Information (NLRI)
Path Attributes
Withdrawn Routes
84
Type 3: BGP Update Message
Attributes Attributes Attributes
Path Networks Path Networks Path Networks
Path Attributes
This is described later, providing the information that allows BGP to choose a
shortest path, detect routing loops, and determine routing policy.
Withdrawn Routes
These are (Length, Prefix) tuples describing destination that have become
unreachable and are being withdrawn from service.
Network-Layer Reachability Information (NLRI)
This is one or more networks (IP address prefix and prefix lengths) that can
be reached by this path.
85
Type 4: BGP Notification Message
86
BGP FSM
87
BGP FSM
88
This process can be viewed with:
debugipbgpipv4unicast
debugipbgpevents (older IOSs)
BGP always begins in the Idle state, in which it refuses all incoming connections.
It is normally initiated by an administrator or a network event.
If BGP does not find a route to the neighboring IP address, it stays in the idle
state.
When Start event occurs, the BGP process:
Initializes all BGP resources
Starts the ConnectRetry timer
Initializes a TCP connection the the neighbor
Listens for a TCP initialization from the neighbor
Changes its state to Connect
90
Connect State
In this state, the BGP process is waiting for the TCP connection to be
completed.
If it finds a route, it goes to the connect state when the TCP handshaking
synchronize acknowledge (SYN ACK) packet returns (when the TCP three-
way handshake is complete).
If the connection is successful, the BGP process:
Clears the ConnectRetry timer
Completes initialization
Sends an Open message to the neighbor
Transitions to the OpenSent state 91
Connect State
92
Active State
In this state, the BGP process is trying to initiate a TCP connection with the
neighbor.
If the TCP connection is successful:
Clears the ConnectRetry timer
Completes initialization
Sends an Open message to the neighbor
Transitions to the OpenSent state
93
Problem
Active State
If the ConnectRetry timer expires while BGP is in the Active State, the BGP
process:
Transitions back to the Connect state
Resets the ConnectRetry timer
In general, a neighbor state that is switching between "Connect" and
"Active" is an indication that something is wrong and that there are
problems with the TCP connection.
It could be because of many TCP retransmissions, or the incapability of a
neighbor to reach the IP address of its peer.
94
OpenSent State
errors
No errors
In this state an Open message has been sent and BGP is waiting to hear an Open
message from its neighbor.
After the TCP connection is set up, the BGP process creates a BGP open
message and sends it to the neighbor.
After BGP dispatches this open message, the BGP peering session changes to the
open sent state.
When an Open message is received, all its fields are checked.
If errors exist, a Notification message is sent and the state transitions to Idle.
If no errors exist, a Keepalive message is sent and the Keepalive timer is
set, the peer is determined to be internal or external, and state is changed to
OpenConfirm. 95
OpenConfirm
State
error
No errors
96
Established
State
In this state, the BGP connection is fully established and the peers can
exchange Update, Keepalive and Notification messages.
If an Update or Keepalive message is received, the Hold timer is
restarted.
If a Notification message is received, the state transitions to Idle.
97
CIS 185 CCNP ROUTE
Ch. 6 Border Gateway Protocol Solution
for ISP Connectivity Part 1
Rick Graziani
Cabrillo College
graziani@cabrillo.edu