d1 s2 BGP Path Attributes and Best Path Selection
d1 s2 BGP Path Attributes and Best Path Selection
1 v1.2
BGP Path Attributes & Best Path Selection
2 v1.2
BGP Path Attribute Categories
• There are four categories of path attribute:
– Well-known Mandatory
• This attribute must exist in BGP UPDATE
• If missing, a NOTIFICATION is generated and the session is terminated
– Well-known Discretionary
• This attribute must be recognized by all BGP implementations, but does not have to be
included in every BGP UPDATE
– Optional Transitive
• If the attribute is not recognized by the BGP implementation, the attribute should be
accepted and passed along to other peers
– Optional Non-transitive
• If the attribute is not recognized by the BGP implementation, the attribute should be
ignored and not passed on to other peers
3 v1.2
BGP Path Attribute Categories
BGP Path Attributes
Well-known Optional
ORIGIN CLUSTER_LIST
(RFC4271) (RFC4456)
4 v1.2
BGP Path Attributes & Best Path Selection
5 v1.2
BGP Best Path Selection
Step Cisco IOS Juniper Junos MikroTik RouterOS
1 Highest WEIGHT NEXT_HOP can be resolved NEXT_HOP is reachable
2 Highest LOCAL_PREF Lowest Route Preference value Prefer the first path received
3 Prefer locally originated path Highest LOCAL_PREF Highest WEIGHT
4 Shortest AS_PATH Lowest AIGP attribute Highest LOCAL_PREF
5 Lowest ORIGIN Shortest AS_PATH Shortest AS_PATH
6 Lowest MULTI_EXIT_DISC Lowest ORIGIN Prefer locally originated path
7 Prefer EBGP path over IBGP path Lowest MULTI_EXIT_DISC Lowest ORIGIN
8 Lowest IGP metric to NEXT_HOP Prefer locally originated path Lowest MULTI_EXIT_DISC
9 Continue if Multipath is not enabled Prefer EBGP path over IBGP path Prefer EBGP path over IBGP path
10 If paths are external, prefer the older one Lowest IGP metric to NEXT_HOP Lowest Router ID
11 Lowest Router ID If paths are external, prefer the active one Shortest CLUSTER_LIST
12 Shortest CLUSTER_LIST Prefer primary route over secondary route Lowest peer address
13 Lowest peer address Lowest Router ID
14 Shortest CLUSTER_LIST
15 Lowest peer address
6 v1.2
BGP Best Path Selection
• Reference:
– Cisco IOS
• https://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/13753-
25.html
– Juniper Junos
• https://www.juniper.net/documentation/en_US/junos/topics/reference/general/routing-
protocols-address-representation.html
– MikroTik RouterOS
• https://wiki.mikrotik.com/wiki/Manual:BGP_Best_Path_Selection_Algorithm
7 v1.2
BGP Path Attributes & Best Path Selection
8 v1.2
Weight (WEIGHT)
• WEIGHT indicates the preference Global Internet
level of specific path in current router.
– Default value: 0 AS65000 AS65001
– Can be set by inbound routing policy R101 R201
AS65000
Loopback: Loopback:
10.0.0.1 10.0.0.2
.1 172.20.0.0/30 .2
AS64512
172.18.1.0/24
172.18.1.0/24 172.18.1.0/24
R101 R1 R2
NEXT_HOP: 172.20.0.1 NEXT_HOP: 172.20.0.1
10 v1.2
Next Hop Self
• Forces the router to set its local peer address as NEXT_HOP
of the prefixes advertised to IBGP peers.
• Used when point-to-point link between EBGP peers
(172.20.0.0/30) is not advertised into IGP.
Next Hop Self
Configured
AS65000
Loopback: Loopback:
10.0.0.1 10.0.0.2
.1 172.20.0.0/30 .2
AS64512
172.18.1.0/24
172.18.1.0/24 172.18.1.0/24
R101 R1 R2
NEXT_HOP: 172.20.0.1 NEXT_HOP:
172.20.0.1 à 10.0.0.1
11 v1.2
Local Preference (LOCAL_PREF)
• LOCAL_PREF indicates the Global Internet
LOCAL_PREF is preferred.
AS64512’s best path for 1.1.1.0/24 is via AS65001
12 v1.2
AS Path (AS_PATH)
• List of ASNs that an update has traversed.
• Can be manipulated for traffic engineering.
– AS Path Prepending in outbound routing policy
AS65000 AS65001
Loopback: Loopback:
10.0.0.1 10.0.0.2
.1 172.20.0.0/30 .2
AS64512 .1 172.28.0.0/30 .2
172.18.1.0/24
13 v1.2
Origin (ORIGIN)
• Information about how a prefix is originated into BGP.
– IGP
• Prefix is fed into BGP by the network command
– EGP
• Prefix is learned via Exterior Gateway Protocol (now obsolete)
– Incomplete
• Origin is unknown
• Prefix is a result of aggregation
• Occurs when prefix is redistributed from other protocols into BGP
15 v1.2
MED Example
• AS64512
– R1 originates 10.2.1.0/24 and advertises AS65002
• to R2 (IBGP)
• to AS65000 (EBGP)
– MED is not set AS65000 AS65001
• to AS65001 (EBGP)
R101 R201
– Set MED: 50
– R2 re-advertises 10.2.1.0/24 2 4
. /
0 50
1
• to AS65001 (EBGP) 10.2.1.0/24 .2
10 ME
. D: 10.2.1.0/24
MED not set e t Set MED: 100
– Set MED: 100 S
10.2.1.0/24
R1 R2
AS64512
10.2.1.0/24
16 v1.2
MED Example
• AS65000
– R101 re-advertises 10.2.1.0/24 AS65002
• to AS65001 (EBGP)
– Set MED: 10 10.2.1.0/24 10.2.1.0/24
– By default, MED is not advertised to the third AS if not set No MED No MED
• to AS65002 (EBGP) AS65000 AS65001
10.2.1.0/24
– MED is not advertised to the third AS Set MED: 10
R101 R201
• AS65001 10.2.1.0/24
No MED
2 4
– R201 re-advertises 10.2.1.0/24 10.2.1.0/24 .2 1 .
. D:
/
0 50
10.2.1.0/24
10 ME
• to AS65000 (EBGP) MED not set
S e t Set MED: 100
17 v1.2
MED Example
• Prefix 10.2.1.0/24
– R1, R2 and R101 advertised the same AS65002
prefix to R201 with different MED values
10.2.1.0/24 10.2.1.0/24
• R1 set MED to 50 No MED No MED
• R2 set MED to 100 AS65000 AS65001
10.2.1.0/24
Set MED: 10
• R101 set MED to 10
R101 R201
– R201 compares only MEDs from the 10.2.1.0/24
No MED
same AS (R1 and R2), MED from 1 .
. D:
/2
0 50
4
10.2.1.0/24 .2 10.2.1.0/24
different AS (R101) is ignored MED not set 10 ME
S e t Set MED: 100
10.2.1.0/24
– MED is not re-advertised to the third AS R1 R2
AS64512
10.2.1.0/24
19 v1.2
Standard Community (COMMUNITIES)
• 32-bit value
– Value range: 0x00000000 – 0xFFFFFFFF
– Reserved values: 0xFFFF0000 – 0xFFFFFFFF
20 v1.2
Well-known Communities
• NO_EXPORT
– Value: 0xFFFFFF01
• Old Format: 4294967041
• New Format: 65535:65281
– Must not be advertised outside a BGP Confederation boundary
– A stand-alone AS that is not part of a Confederation is considered a
Confederation itself
21 v1.2
Well-known Communities
• NO_ADVERTISE
– Value: 0xFFFFFF02
• Old Format: 4294967042
• New Format: 65535:65282
– Must not be advertised to any BGP peer
22 v1.2
Well-known Communities
• NO_EXPORT_SUBCONFED
– Value: 0xFFFFFF03
• Old Format: 4294967043
• New Format: 65535:65283
– Must not be advertised to any EBGP peer, including peers from other
member ASes inside a BGP Confederation
– Also known as “local-AS”
23 v1.2
Well-known Communities
• NOPEER
– Value: 0xFFFFFF04
• Old Format: 4294967044
• New Format: 65535:65284
– Should not be advertised to external bilateral peer neighbor ASes
– RFC3765: NOPEER Community for Border Gateway Protocol (BGP)
Route Scope Control
24 v1.2
Standard Communities for AS64512
• Informational
– Relationship
• 64512:100 = Customer prefixes
• 64512:200 = Prefixes from private peering or Internet eXchange (IX)
• 64512:300 = Internet prefixes from upstream provider
– Geographic location
• 64512:1000 = Prefixes received from Asia
• 64512:2000 = Prefixes received from Europe
• 64512:3000 = Prefixes received from North America
• 64512:4000 = Prefixes received from South America
• 64512:5000 = Prefixes received from Africa
25 v1.2
Standard Communities for AS64512
• Action
– Access Control
• 64512:666 = Blackhole routes, drop traffic to these destinations
– Traffic Engineering
• 64512:901 = Prepend 1x when advertising to other ASes
• 64512:902 = Prepend 2x when advertising to other ASes
• 64512:903 = Prepend 3x when advertising to other ASes
• 64512:920 = Do not advertise to any Peer
• 64512:930 = Do not advertise to any Transit Provider
26 v1.2
Standard Community Example
R3
10.2.3.0/24
10.2.3.0/24
COMMUNITIES:
AS65000 NO_EXPORT
.1 172.20.0.0/30 .2
AS64512
10.2.2.0/24
10.2.2.0/24 10.2.2.0/24
R101 R1 R2
AS_PATH: 64512 64512 64512 COMMUNITIES:
(10.2.3.0/24 is not advertised) 64512:902