Brkent 1179
Brkent 1179
Brkent 1179
BRKENT-1179
#CiscoLive
Cisco Webex App
Questions?
Use Cisco Webex App to chat
with the speaker after the session
How
1 Find this session in the Cisco Live Mobile App
3 Install the Webex App or go directly to the Webex space Enter your personal notes here
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 33
• Why BGP?
• Messages and States
• Attributes
• Internal vs External BGP
Best Path Selection
Agenda
•
Algorithm
• Policy Control and Traffic
Engineering
BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 4
Why BGP?
Autonomous System
A group of one or more IP prefixes (lists of IP addresses accessible on a network) run by
one or more network operators that maintain a single, clearly-defined routing policy.
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 6
• Created to address 2-byte ASN
depletion
• Interoperable with 2-byte ASNs
BGP 2-byte ASN (range includes 2-byte ASNs)
• 32-bit number
• 0 to 4294967295
RFC1105 (1989) • Additional private range
4200000000 to 4294967294
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 7
Border Gateway Protocol
• Border Gateway Protocol
• Large scale, robust and stable routing protocol designed to operate
between autonomous systems
• Based on TCP, listens on port 179
• Fundamentally a distance vector protocol
• Does not have the concept of a simple metric
• Instead, uses multiple characteristics called attributes
• Allows for strong control over advertised routes and their attributes
• Assumes that the routing inside the autonomous system is already fully
taken care of by an IGP (EIGRP, OSPF, IS-IS)
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 8
Inter-AS Routing Policies
BGP IS-IS
EIGRP
BGP
BGP
OSPF
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 9
Route Scale & Control Plane Stability
route-views> show bgp ipv4 unicast summary | ex never|Active|Idl
BGP router identifier 128.223.51.103, local AS number 6447
BGP table version is 2813468887, main routing table version 2813468887
Path RPKI states: 7708169 valid, 10262796 not found, 14390 invalid
962240 network entries using 238635520 bytes of memory
<Output omitted...>
<Output omitted...>
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 10
BGP Stability Considerations
• Events in networks often occur in bursts
• There is always a challenge how to react
• Reacting fast improves convergence time but may introduce churn
• Reacting with a delay improves stability but delays convergence
• BGP favors stability
• It delays sending updates to smoothen out the churn and to collect
possibly multiple changes for a single update
• It only advertises changes (incremental updates)
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 11
Route Scale & Control Plane Stability
<Output omitted>
<Output omitted>
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 12
Network Layer Reachability Information Exchange
R1(config)# router bgp 64512
R1(config-router)# address-family ?
ipv4 Address family
ipv6 Address family
l2vpn Address family
nsap Address family
vpnv4 Address family
vpnv6 Address family
Prefix/Length route-views> show bgp all neighbors 4.68.4.46 | i family
For address family: IPv4 Unicast
Address family IPv4 Unicast: advertised and received
Address family IPv4 Multicast: advertised and received
For address family: IPv6 Unicast
For address family: IPv4 Multicast
Address family IPv4 Unicast: advertised and received
Address family IPv4 Multicast: advertised and received
For address family: L2VPN E-VPN
For address family: MVPNv4 Unicast
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 13
Messages
BGP Message Types
• BGP runs on top of TCP transport layer protocol which is…
• Byte stream-oriented
• Unicast only
• Connection-oriented and reliable
• Providing flow and congestion control
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 15
BGP Message Types
• BGPv4 uses (only) 5 message types
• OPEN
• UPDATE
• NOTIFICATION
• KEEPALIVE
• ROUTE-REFRESH (not part of initial BGPv4 RFC 1654 specification,
brought in through RFC 2918 and nearly universally supported)
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 16
BGP OPEN Message
• BGP speakers use OPEN to advertise their configuration and
capabilities once their TCP session comes up
• Version advertisement
• Autonomous System Number advertisement
• Hold Time advertisement/negotiation
• BGP Router ID advertisement
• Optional Capabilities advertisement/negotiation
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 17
BGP OPEN Message
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 18
Select BGP Capability Codes for OPEN Message
https://www.iana.org/assignments/capability-codes/capability-codes.xhtml#capability-codes-2
Value Name RFC
1 Multiprotocol Extensions for BGP-4 2858
2 Route Refresh Capability for BGP-4 2918
3 Outbound Route Filtering Capability 5291
5 Extended Next Hop Encoding 8950
6 BGP Extended Message 8654
7 BGPsec Capability 8205
8 Multiple Labels Capability 8277
9 BGP Role 9234
64 Graceful Restart Capability 4724
65 Support for 4-octet AS number capability 6793
69 ADD-PATH Capability 7911
70 Enhanced Route Refresh Capability 7313
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 19
BGP NOTIFICATION Message
• The NOTIFICATION message is sent out by a peer who detected an
unrecoverable condition and needs to terminate the peering
• After sending out a NOTIFICATION, the sender closes the session
• The NOTIFICATION contents are useful for diagnostics
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 20
Select BGP Error Codes for NOTIFICATION
https://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#bgp-parameters-3
Value Name RFC
1 Message Header Error 4271
2 OPEN Message Error 4271
3 UPDATE Message Error 4271
4 Hold Timer Expired 4271
5 Finite State Machine Error 4271
6 Cease 4271
7 ROUTE-REFRESH Message Error 7313
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 21
Select BGP Error Subcodes
https://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#bgp-parameters-3
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 22
Select BGP Error Subcodes
https://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#bgp-parameters-3
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 24
BGP KEEPALIVE Message
• Instead of relying on TCP keepalives, BGP uses the
KEEPALIVE message to periodically announce a speaker’s liveliness
• KEEPALIVE is sent…
• Immediately after receiving an agreeable OPEN message from peer
• Periodically, with the period being one third of Hold Time by default
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 25
BGP ROUTE-REFRESH Message
• Original BGP specification did not specify means to ask a peer to resend
prefixes to us
• This is necessary when the inbound route policy changes
• Vendors worked around this deficiency by storing aside a separate unfiltered copy of all
routes from the peer (“Soft Reconfiguration”)
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 26
BGP UPDATE Message
• The UPDATE message is the workhorse of BGP
• Advertises reachable NLRIs along with their attributes
• Withdraws unreachable NLRIs
• The format of the UPDATE message targets maximum efficiency
• The path attributes are included only once, followed by the list of all NLRIs
that share them
• Every NLRI contains only the network prefix (and padding bits to a whole
octet if needed)
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 27
BGP Update Message – New/Updated Routes
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 28
BGP Update Message – Withdrawn Routes
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 29
States
Active, Idle, Connect
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 31
Open Sent & Open Confirmed
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 32
Established
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 33
Attributes
BGP Attributes
• An attribute is an additional piece of information accompanying an
advertised NLRI
• BGP uses attributes in multiple ways
• Prevents routing loops
• Performs best path selection
• Filters or sorts routes
• … and many more
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 35
BGP Attribute Types
• Well-known: Every BGP implementation must support it
• Well-known mandatory: Must always be included with a NLRI
• Well-known discretionary: May be included with a NLRI as needed
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 36
BGP Attributes
• Well-known mandatory: • Optional transitive
• AS_PATH • AGGREGATOR
• NEXT_HOP • COMMUNITIES
• ORIGIN • EXTENDED_COMMUNITIES
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 37
Internal vs
External BGP
Internal BGP
AS4
External BGP
AS4
AS2
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 39
NEXT_HOP in eBGP
Set NEXT_HOP to
the local address
used for BGP
peering
AS4
AS2 External BGP
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 40
NEXT_HOP in iBGP
Leave NEXT_HOP
unchanged (by
default!)
Internal BGP
AS4
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 41
AS_PATH in eBGP
AS4
AS2 External BGP
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 42
AS_PATH in iBGP
Internal BGP
AS4
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 43
Updates in eBGP
If update received
from eBGP peer,
advertise it to all
BGP peers
AS4
AS2 External BGP
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 44
Updates in iBGP
If update received
from an iBGP peer,
do not advertise it
to any iBGP peers
(by default!)
Internal BGP
AS4
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 45
eBGP/iBGP Attribute Handling Summary
Internal External
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 46
Best Path Selection
Algorithm
Best Path Selection in BGP
• BGP observes multiple constraints when selecting the best path
• Loop-free
• Shortest in terms of the number of ASes to traverse
• Most likely to hit the true destination
• Leaving the local autonomous system as quickly as possible (if needed)
• … but not updated unnecessarily if changed only insignificantly
• … and always with the possibility for the admin to override the selection
• BGP rules for best path selection aim to select exactly one best
path per NLRI – to be both used locally and advertised to peers
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 48
10,000 Miles View at BGP Best Path Selection
• BGP speaker needs to decide on the best path for an NLRI if it
learns about multiple options (variants) on how to reach it
• For every learned NLRI:
• Select the first variant in the database as the best one
• If there are more variants, go through them one by one, and compare the
current best one to the entry at hand, and pick the new best one
• The new best one may be the current one (no change), or the entry at hand
• Finish when all variants have been inspected
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 49
Before Getting to the Nitty Gritty…
• Before diving into the BGP best path algorithm steps, keep in mind:
• For every NLRI, BGP always compares the current best path to a variant in
its database (injected locally or learned from peers)
• The best path is both used locally (if it makes sense) and advertised to
other peers, subject to the advertisement rules and policies
• In upcoming slides, the diagrams demonstrate typical scenarios but
are not exhaustive
Router performing the best path selection Generic router (unspecific)
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 50
The logic behind BGP best path selection (1)
• Step 1: Prefer the path with the higher WEIGHT
• Rationale: Always have means to override the path choice locally
• Note: This is an override rule
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 51
The logic behind BGP best path selection (2)
• Step 2: Prefer the path with the higher LOCAL_PREF
• Rationale: Have means to override the best path for the entire AS from
a single exit point
• Note: This is an override rule
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 52
The logic behind BGP best path selection (3)
• Step 3: Prefer the locally originated path (network, redistribution,
aggregation)
• Rationale: I get a chance to speak on behalf of my own local AS
• Note: The best route is not just for me to use but also to advertise to
others so that they know
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 53
The logic behind BGP best path selection (4)
• Step 4: Prefer the path with the shortest AS_PATH / AS4_PATH
• Rationale: Traverse the least amount of autonomous systems
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 54
The logic behind BGP best path selection (5)
• Step 5: Prefer the path with the lower ORIGIN code
• Rationale: Take the most trustworthy path
• Note: IGP is lower than EGP, EGP is lower than Incomplete
Redistribution of
IGP into BGP
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 55
The logic behind BGP best path selection (6)
• Step 6: Prefer the path with the lower MULTI_EXIT_DISC
• Rationale: Respect the preferred path hint indicated by the neighbor AS
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 56
The logic behind BGP best path selection (7)
• Step 7: Prefer eBGP-learned path over iBGP-learned one
• Rationale: If you need to leave the local AS, leave right away if you can
iBGP
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 57
The logic behind BGP best path selection (8)
• Step 8: Prefer the path with the lower IGP metric to the next hop
• Rationale: If you need to traverse the local AS but can’t leave right away,
just take the shortest path toward the exit
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 58
The logic behind BGP best path selection (9)
• Step 9: If both paths are learned via eBGP, prefer the older one
• Rationale: The eBGP paths are, by this point, effectively equal – so don’t
bother updating anything
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 59
The logic behind BGP best path selection (10-12)
• Steps 10-12: Prefer the path learned from the BGP peer with the
lower Router ID, then with the shorter CLUSTER_LIST, then from the
BGP peer with the lower peering IP address
• Rationale: Technical tiebreakers to arrive at exactly one best path
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 60
BGP Best Path Selection Algorithm
https://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/13753-25.html
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 61
Policy Control and
Traffic Engineering
Outbound Traffic - Weight
AS4
10.10.10.0/24
AS2 AS3
AS1
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 63
Outbound Traffic - Weight
AS4
10.10.10.0/24
AS2 AS3
AS1
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 64
Outbound Traffic – LOCAL_PREF
AS4
10.10.10.0/24
AS3
AS2
AS1
Local Local
Preference Preference
> 100 <= 100
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 65
Outbound Traffic - LOCAL_PREF
AS4
10.10.10.0/24
AS3
AS2
Local Local
Preference > AS1 Preference <=
100 100
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 66
Inbound Traffic – MULTI_EXIT_DISC
AS2
MED > 0 MED <= 0
MED <= 0
MED > 0
AS1
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 67
Inbound Traffic – MULTI_EXIT_DISC
AS4
MED = ?
AS2 AS3
10.10.20.0/24
AS1
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 68
Inbound Traffic – AS_PATH
AS4
AS_PATH 1
AS_PATH 1,1,1
AS2 AS3
10.10.20.0/24
AS1
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 69
Concluding Remarks
• BGPv4 is ~30 years old but its core is still the same
• A credit to its well-thought design
• BGP is a world on its own – where to learn more?
• Cisco Press textbooks
• Cisco Communities, Cisco Learning Network
• IETF RFCs
• Wireshark
• Hands-on experience is key
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 70
“Like a fine wine, BGP only gets
better with age.”
Anonymous
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 71
Fill out your session surveys!
These points help you get on the leaderboard and increase your chances of winning daily and grand prizes
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 72
• Visit the Cisco Showcase
for related demos
BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 73
Thank you
#CiscoLive
Gamify your Cisco Live experience!
Get points for attending this session!
How:
1 Open the Cisco Events App.
4 Click the + at the bottom of the screen and scan the QR code:
#CiscoLive BRKENT-1179 © 2023 Cisco and/or its affiliates. All rights reserved. Cisco Public 75
75
#CiscoLive