Border Gateway Protocol (BGP4)
Border Gateway Protocol (BGP4)
Border Gateway Protocol (BGP4)
Routing/Forwarding basics
Building blocks
Exercises
BGP protocol basics
Exercises
BGP path attributes
Best path computation
Exercises
Routing/Forwarding
Basics
R1
R2
10/8 -> R3
10.1/16 -> R4
20/8 -> R5
30/8 -> R6
..
R4
10.1/16
R1
R4
R2
10/8 -> R3
10.1/16 -> R4
20/8 -> R5
10.1/16
10.1.1.1 & FF.0.0.0
is equal to
10.0.0.0 & FF.0.0.0
..
R2s IP routing table
Match!
R1
R4
R2
10/8 -> R3
10.1/16 -> R4
20/8 -> R5
10.1/16
10.1.1.1 & FF.FF.0.0
is equal to
10.1.0.0 & FF.FF.0.0
..
R2s IP routing table
Match as well!
R1
R4
R2
10/8 -> R3
10.1/16 -> R4
20/8 -> R5
..
10.1/16
R1
R2
R4
10.1/16
10/8 -> R3
10.1/16 -> R4
20/8 -> R5
..
R2s IP routing table
default is 0.0.0.0/0
can handle it using the normal longest
match algorithm
matches everything. Always the shortest
match.
Forwarding
Uses the routing table built by routing
protocols
Performs the lookup to find next-hop and
outgoing interface
Switches the packet with new encapsulation
as per the outgoing interface
Building Blocks
Autonomous System(AS)...
Identified by AS number
Public & Private AS numbers
Examples:
Service provider
Multi-homed customers
Anyone needing policy discrimination
AS 1
accept
announce
announce
Routing flow
accept
AS2
ingress
packet
flow
Egress Traffic
Packets exiting the network
Based on
Route availability (what others send you)
Route acceptance (what you accept from others)
Policy and tuning (what you do with routes from
others)
Peering and transit agreements
Ingress Traffic
Packets entering your network
Ingress traffic depends on:
What information you send and to who
Based on your addressing and ASes
Based on others policy (what they accept from
you and what they do with it)
Types of Routes
Static Routes
configured manually
Connected Routes
created automatically when an interface is up
Interior Routes
Routes within an AS
Exterior Routes
Routes exterior to AS
What Is an IGP?
What Is an EGP?
Exterior
Specifically configured
peers
BGP4 / OSPF
BGP4
Local NAP
FDDI
BGP4/Static
Customers
DMZ
Network
AS 100
B
AS 101
D
AS 102
Addressing - ISP
Need to reserve address space for its
network.
Need to allocate address blocks to its
customers.
Need to take growth into consideration
Upstream link address is allocated by
upstream provider
BGP Basics
Terminology
Protocol Basics
Messages
General Operation
Peering relationships (EBGP/IBGP)
Originating routes
Terminology
Neighbor
Configured BGP peer
NLRI/Prefix
NLRI - network layer reachability information
Reachability information for a IP address &
mask
Router-ID
Highest IP address configured on the router
Route/Path
NLRI advertised by a neighbor
Protocol Basics
Peering
A
AS 100
AS 101
B
AS 102
BGP Peers
A
AS 101
AS 100
220.220.16.0/24
220.220.8.0/24
BGP speakers
are called peers
Peers in different ASs
are called External Peers
AS 102
220.220.32.0/24
eBGP TCP/IP
Peer Connection
BGP Peers
A
AS 101
AS 100
220.220.16.0/24
220.220.8.0/24
AS 102
220.220.32.0/24
BGP Peers
A
AS 101
AS 100
220.220.16.0/24
220.220.8.0/24
AS 102
220.220.32.0/24
AS 101
222.222.10.0/30
.2
220.220.8.0/24
.1
.2
.1
.2
220.220.16.0/24
.1
interface Serial 0
ip address 222.222.10.2 255.255.255.252
interface Serial 0
ip address 222.222.10.1 255.255.255.252
AS 100
.2
220.220.8.0/24
.1
.2
.1
.2
220.220.16.0/24
.1
interface Serial 1
ip address 220.220.16.2 255.255.255.252
interface Serial 1
ip address 222.220.16.1 255.255.255.252
iBGP TCP/IP
Peer Connection
AS 100
215.10.7.3
iBGP TCP/IP
Peer Connection
215.10.7.2
AS 100
215.10.7.3
iBGP TCP/IP
interface
loopback 0
ip
address
215.10.7.1 255.255.255.255
Peer
Connection
router bgp 100
network 220.220.1.0
neighbor 215.10.7.2
neighbor 215.10.7.2
neighbor 215.10.7.3
neighbor 215.10.7.3
remote-as 100
update-source loopback0
remote-as 100
update-source loopback0
215.10.7.2
AS 100
215.10.7.2
215.10.7.3
iBGP TCP/IP
Peer Connection
interface loopback 0
ip address 215.10.7.2 255.255.255.255
remote-as 100
update-source loopback0
remote-as 100
update-source loopback0
AS 100
215.10.7.3
iBGP TCP/IP
Peer Connection
interface loopback 0
ip address 215.10.7.3 255.255.255.255
router bgp 100
network 220.220.1.0
neighbor 215.10.7.1
neighbor 215.10.7.1
neighbor 215.10.7.2
neighbor 215.10.7.2
remote-as 100
update-source loopback0
remote-as 100
update-source loopback0
215.10.7.2
AS path
Next hop
Local preference
Multi-Exit Discriminator (MED)
Community
Origin
Aggregator
AS-Path Attribute
Sequence of ASes a route
has traversed
Loop detection
Apply policy
AS 300
AS 200
AS 100
170.10.0.0/16
180.10.0.0/16
Network
Path
180.10.0.0/16 300 200 100
170.10.0.0/16 300 200
AS 400
150.10.0.0/16
AS 500
Network
180.10.0.0/16
170.10.0.0/16
150.10.0.0/16
Path
300 200 100
300 200
300 400
AS 200
150.10.0.0/16
140.10.0.0/16
192.10.1.0/30
.1
.2
D
E
B
.2
.1
AS 100
160.10.0.0/16
BGP Update
Messages
Network
Next-Hop
160.10.0.0/16 192.20.2.1
Path
100
AS 200
150.10.0.0/16
140.10.0.0/16
192.10.1.0/30
.1
.2
D
E
B
.2
.1
Network
Next-Hop
150.10.0.0/16 192.10.1.1
160.10.0.0/16 192.10.1.1
Path
200
200 100
AS 100
160.10.0.0/16
BGP Update
Messages
AS 200
150.10.0.0/16
140.10.0.0/16
192.10.1.0/30
.1
.2
D
E
B
.2
.1
AS 100
160.10.0.0/16
BGP Update
Messages
Network
Next-Hop
150.10.0.0/16 192.10.1.1
160.10.0.0/16 192.10.1.1
Path
200
200 100
BGP Updates
Withdrawn Routes
Used to withdraw network reachability
Each Withdrawn Route is composed of:
Network Prefix
Mask Length
BGP Updates
Withdrawn Routes
AS 321
AS 123
.1
192.168.10.0/24
.2
BGP Update
Message
Withdraw Routes
192.192.25.0/24
Connectivity lost
Network
Next-Hop
Path
150.10.0.0/16
192.168.10.2 321 200
192.192.25.0/24 192.168.10.2 321
192.192.25.0/24
Next-Hop
192.20.2.2
192.20.2.2
Path
i
i
10.1.2.0/24
160.10.1.0/24
160.10.3.0/24
153.22.0.0/16
192.1.1.0/24
Route Table
Next-Hop
0.0.0.0
192.20.2.2
192.20.2.2
192.20.2.2
Path
i
i
i
i
10.1.2.0/24
160.10.1.0/24
160.10.3.0/24
153.22.0.0/16
192.1.1.0/24
Route Table
Next-Hop
0.0.0.0
192.20.2.2
192.20.2.2
192.20.2.2
192.20.2.2
Path
i
i
i
i
?
10.1.2.0/24
160.10.1.0/24
160.10.3.0/24
153.22.0.0/16
192.1.1.0/24
Route Table
Update
Update
Network
Next-Hop
173.21.0.0/16 192.20.2.1
OUT Process
BGP RIB
Network
*>i160.10.1.0/24
*>i160.10.3.0/24
* > 173.21.0.0/16
Next-Hop
192.20.2.2
192.20.2.2
192.20.2.1
Path
i
i
100
Path
100
BGP in process
receives path information from peers
results of BGP path selection placed in the BGP table
best path flagged (denoted by >)
OUT Process
BGP RIB
Network
*>i160.10.1.0/24
*>i160.10.3.0/24
*> 173.21.0.0/16
Next-Hop
192.20.2.2
192.20.2.2
192.20.2.1
Path
i
i
100
Update
Network
160.10.1.0/24
160.10.3.0/24
173.21.0.0/16
Next-Hop
192.20.2.2
192.20.2.2
192.20.2.1
192.20.2.2
Update
Path
200
200
200 100
Next-Hop changed
D
D
D
R
S
B
10.1.2.0/24
160.10.1.0/24
160.10.3.0/24
153.22.0.0/16
192.1.1.0/24
173.21.0.0/16
Route Table
Next-Hop
192.20.2.2
192.20.2.2
192.20.2.1
Path
i
i
100
UPDATE
To exchange routing information
KEEPALIVE
To maintain peering session
NOTIFICATION
To report errors (results in session reset)
AS 100
AS 101
An Example
35.0.0.0/8
AS3561
AS200
F
B
AS21
AS101
AS675
Configuration commands
router bgp <AS-number>
neighbor <ip address> remote-as <as-number>
Show commands
show ip bgp summary
show ip bgp neighbors
Originating routes...
Using network command or redistribution
network <ipaddress>
redistribute <protocol name>
Originating routes/Inserting
prefixes into BGP
network command
network 198.10.4.0 mask 255.255.254.0
ip route 198.10.0.0 255.255.254.0 serial 0
matching route must exist in the routing
table before network is announced!
Origin: IGP
Update message
Withdrawn routes
Path Attributes
Advertised routes
BGP4 continued...
Origin
AS-path
Next-hop
Multi-Exit Discriminator (MED)
Local preference
BGP Community
Others...
AS-PATH
Updated by the sending router with its AS
number
AS-Path
AS 200
AS 100
170.10.0.0/16
180.10.0.0/16
180.10.0.0/16
dropped
AS 400
150.10.0.0/16
AS 500
180.10.0.0/16
170.10.0.0/16
150.10.0.0/16
Next-Hop
150.10.1.1
150.10.1.2
AS 200
150.10.0.0/16
AS 300
150.10.0.0/16 150.10.1.1
160.10.0.0/16 150.10.1.1
AS 100
160.10.0.0/16
20
150.1.1.1
peering
150.1.1.3
150.1.1.2
B
192.68.1.0/24
AS 201
150.1.1.3
Next Hop...
Local Preference
Not for EBGP, mandatory for IBGP
Default value is 100 on Ciscos
Local to an AS
Used to prefer one exit over another
Path with highest local preference wins
Local Preference
AS 100
160.10.0.0/16
AS 200
AS 300
D
500
800
A
160.10.0.0/16
> 160.10.0.0/16
500
800
AS 400
C
Multi-Exit Discriminator
Non-transitive
Represented as a numeric value (0-0xffffffff)
Used to convey the relative preference of entry points
Comparable if paths are from the same AS
Path with lower MED wins
IGP metric can be conveyed as MED
C
preferred
192.68.1.0/24
2000
192.68.1.0/24
B
192.68.1.0/24
AS 201
1000
Origin
Conveys the origin of the prefix
Three values:
IGP - Generated using network statement
ex: network 35.0.0.0
Communities
Transitive, Non-mandatory
Represented as a numeric value (0-0xffffffff)
Used to group destinations
Each destination could be member of multiple
communities
Flexibility to scope a set of prefixes within or
across AS for applying policy
Community...
Community
201:110
201:120
Community:201:110
Community:201:120
B
192.68.1.0/24
Customer AS 201
Local Preference
110
120
Synchronization
1880
D
690
OSPF
35/8
209
Largest weight
Local to the router
Locally sourced
Via redistribute or network statement
Lowest origin
IGP < EGP < INCOMPLETE
Lowest MED
between paths from same AS
Closest next-hop
Lower IGP metric, closer exit from as AS
Lowest router-id
Lowest IP address of neighbor
AS 200
AS 300
D
Increase AS path attribute
length by at least 1
AS 400
AS 400s Policy to reach AS100
AS 200 preferred path
AS 300 backup
Stub AS
Typically no need for BGP
Point default towards the ISP
ISP advertises the stub network to
Internet
Policy confined within ISP policy
Stub AS
B
A
AS 100
Customer
AS 101
Provider
Multi-homed AS
Only border routers speak BGP
IBGP only between border routers
Exterior routes must be redistributed in
a controlled fashion into IGP or use
defaults
Multi-homed AS
AS 100
provider
AS 300
D
A
C
AS 200
customer
provider
H
B
AS 300
D
provider
E
AS 400
AS 200
Routing Policy
Why?
To steer traffic through preferred paths
Inbound/Outbound prefix filtering
To enforce Customer-ISP agreements
How ?
AS based route filtering - filter list
Prefix based route filtering - distribute list
BGP attribute modification - route maps
Route Maps
router bgp 300
neighbor 2.2.2.2 remote-as 100
neighbor 2.2.2.2 route-map SETCOMMUNITY out
!
route-map SETCOMMUNITY permit 10
match ip address 1
match community 1
set community 300:100
!
access-list 1 permit 35.0.0.0
ip community-list 1 permit 100:200
Set Clauses
AS-path prepend
Community
Local-Preference
MED
Origin
Weight
Others...
ISP2
C21
ethH
C22
eth H
ISP3
Inbound route-map
to set community
C31
eth
C32
eth
A
AS100
Loopback 0
10.200.0.2
AS200
Loopback 0
20.200.0.1
100
200
Redundancy - Multi-homing
Reliable connection to Internet
3 common cases of multi-homing:
- default from all providers
- customer + default routes from all
- full routes from all
Provider
Provider
AS 200
AS 300
D
AS 400
C
Provider
Provider
AS 200
AS 300
D
C chooses shortest AS
path
AS 400
C
AS 500
AS 200
AS 300
D
C chooses shortest AS
path
AS 400
C
Best Practices
IGP in Backbone
IGP connects your backbone together, not
your clients routes
IGP must converge quickly
IGP should carry netmask information OSPF, IS-IS, EIGRP
Best Practices...
Connecting to a customer
Static routes
You control directly
No route flaps
Best Practices...
Connecting to other ISPs
Use BGP4
Advertise only what you serve
Take back as little as you can
Take the shortest exit
Best Practices...
The Internet Exchange
Long distance connectivity is expensive
Connect to several providers at a single
point
Q&A