BGP Attributes
BGP Attributes
BGP Attributes
Selection
ISP Training Workshops
1
BGP Attributes
The tools available for the job
2
What Is an Attribute?
Next
... Hop AS Path MED ... ...
3
AS-Path
! Sequence of ASes a
route has traversed
AS 200 AS 100
! Mandatory 170.10.0.0/16 180.10.0.0/16
transitive attribute
! Used for: 180.10.0.0/16 300 200 100
170.10.0.0/16 300 200
" Loop detection AS 300
" Applying policy
AS 400
150.10.0.0/16
AS 200 AS 100
170.10.0.0/16 180.10.0.0/16
AS 500 ! 180.10.0.0/16 is
not accepted by
AS100 as the prefix
180.10.0.0/16 300 200 100 has AS100 in its
170.10.0.0/16 300 200 AS-PATH this is
140.10.0.0/16 300 loop detection in
action 6
Next Hop
150.10.1.1 150.10.1.2
iBGP C
AS 200 A B
150.10.0.0/16 eBGP AS 300
150.10.0.0/16 150.10.1.1
160.10.0.0/16 150.10.1.1
120.1.1.0/24 120.1.254.2
120.1.2.0/23 120.1.254.3
10
Next Hop (Summary)
! IGP should carry route to next hops
! Recursive route look-up
! Unlinks BGP from actual physical topology
! Use next-hop-self for external next hops
! Allows IGP to make intelligent forwarding
decision
11
Origin
! Conveys the origin of the prefix
! Historical attribute
" Used in transition from EGP to BGP
! Transitive and Mandatory Attribute
! Influences best path selection
! Three values: IGP, EGP, incomplete
" IGP generated by BGP network statement
" EGP generated by EGP
" incomplete redistributed from another routing protocol
12
Aggregator
! Conveys the IP address of the router or BGP
speaker generating the aggregate route
! Optional & transitive attribute
! Useful for debugging purposes
! Does not influence best path selection
! Creating aggregate using aggregate-address
sets the aggregator attribute:
13
Local Preference
AS 100
160.10.0.0/16
AS 200 AS 300
D 500 800 E
A B
160.10.0.0/16 500 AS 400
> 160.10.0.0/16 800
C
14
Local Preference
! Non-transitive and optional attribute
! Local to an AS only
" Default local preference is 100 (IOS)
! Used to influence BGP path selection
" determines best path for outbound traffic
! Path with highest local preference wins
15
Local Preference
! Configuration of Router B:
router bgp 400
neighbor 120.5.1.1 remote-as 300
neighbor 120.5.1.1 route-map local-pref in
!
route-map local-pref permit 10
match ip address prefix-list MATCH
set local-preference 800
route-map local-pref permit 20
!
ip prefix-list MATCH permit 160.10.0.0/16
16
Multi-Exit Discriminator (MED)
C D
AS 400
17
Multi-Exit Discriminator
! Inter-AS non-transitive & optional attribute
! Used to convey the relative preference of entry
points
" determines best path for inbound traffic
! Comparable if paths are from same AS
" bgp always-compare-med allows comparisons of MEDs
from different ASes
! Path with lowest MED wins
! Absence of MED attribute implies MED value of
zero (RFC4271)
18
MED & IGP Metric
! IGP metric can be conveyed as MED
" set metric-type internal in route-map
! enables BGP to advertise a MED which corresponds to
the IGP metric values
! changes are monitored (and re-advertised if needed)
every 600s
! bgp dynamic-med-interval <secs>
19
Multi-Exit Discriminator
! Configuration of Router B:
router bgp 400
neighbor 120.5.1.1 remote-as 200
neighbor 120.5.1.1 route-map set-med out
!
route-map set-med permit 10
match ip address prefix-list MATCH
set metric 1000
route-map set-med permit 20
!
ip prefix-list MATCH permit 120.68.1.0/24
20
Weight
! Not really an attribute local to router
! Highest weight wins
! Applied to all routes from a neighbour
21
Weight Used to help Deploy RPF
AS4 Link to use for most traffic from AS1
B
AS4, LOCAL_PREF
Backup link, but RPF 100, weight 100
still needs to work A AS1
B
AS7
AS1
D
A
Router A customers AS4, LOCAL_PREF
have best path to AS7 100, weight 100
A B
AS 100 AS 200
160.10.0.0/16 170.10.0.0/16
25
Community Example
(after)
Peer AS1 160.10.0.0/16 300:1
170.10.0.0/16 300:1
X Upstream
100.10.0.0/16 AS 400
F
E
100.10.0.0/16 300:9
D ISP 1
AS 300
160.10.0.0/16 300:1 C
170.10.0.0/16 300:1
A B
AS 100 AS 200
160.10.0.0/16 170.10.0.0/16
26
Well-Known Communities
! Several well known communities
" www.iana.org/assignments/bgp-well-known-communities
! no-export 65535:65281
" do not advertise to any eBGP peers
! no-advertise 65535:65282
" do not advertise to any BGP peer
! no-export-subconfed 65535:65283
" do not advertise outside local AS (only used with
confederations)
! no-peer 65535:65284
" do not advertise to bi-lateral peers (RFC3765)
27
No-Export Community
105.7.0.0/16
105.7.X.X no-export
105.7.X.X
A D
105.7.0.0/16
AS 100 AS 200 G
B E
C F
C
105.7.0.0/16
upstream E
A
upstream
B
30
Summary
Attributes in Action
Router6>sh ip bgp!
BGP table version is 30, local router ID is 10.0.15.246!
Status codes: s suppressed, d damped, h history, * valid, >
best, i - internal, r RIB-failure, S Stale!
Origin codes: i - IGP, e - EGP, ? - incomplete!
!
Network Next Hop Metric LocPrf Weight Path!
*>i10.0.0.0/26 10.0.15.241 0 100 0 i!
*>i10.0.0.64/26 10.0.15.242 0 100 0 i!
*>i10.0.0.128/26 10.0.15.243 0 100 0 i!
*>i10.0.0.192/26 10.0.15.244 0 100 0 i!
*>i10.0.1.0/26 10.0.15.245 0 100 0 i!
*> 10.0.1.64/26 0.0.0.0 0 32768 i!
...
31
BGP Path Selection
Algorithm
Why is this the best path?
32
BGP Path Selection Algorithm for
Cisco IOS: Part One
1. Do not consider path if no route to next
hop
2. Do not consider iBGP path if not
synchronised (Cisco IOS)
3. Highest weight (local to router)
4. Highest local preference (global within
AS)
5. Prefer locally originated route
6. Shortest AS path
33
BGP Path Selection Algorithm for
Cisco IOS: Part Two
7. Lowest origin code
" IGP < EGP < incomplete
8. Lowest Multi-Exit Discriminator (MED)
" If bgp deterministic-med, order the paths by
AS number before comparing
" If bgp always-compare-med, then compare
for all paths
" Otherwise MED only considered if paths are
from the same AS (default)
34
BGP Path Selection Algorithm for
Cisco IOS: Part Three
9. Prefer eBGP path over iBGP path
10. Path with lowest IGP metric to next-hop
11. For eBGP paths:
" If multipath is enabled, install N parallel paths
in forwarding table
" If router-id is the same, go to next step
" If router-id is not the same, select the oldest
path
35
BGP Path Selection Algorithm for
Cisco IOS: Part Four
12. Lowest router-id (originator-id for
reflected routes)
13. Shortest cluster-list
" Client must be aware of Route Reflector
attributes!
14. Lowest neighbour address
36
BGP Attributes and Path
Selection
ISP Training Workshops
37