BGP Fundamentals
BGP Fundamentals
BGP Fundamentals
2
Path Vector Routing Protocol
• A path vector routing protocol is used to span
different autonomous systems
– It defines a route as a collection of number of ASes that it
passes through from source AS to destination AS
– This list of ASes are called AS path and used to avoid routing
loop
– AS path is also used to select path to destination
AS Path
Internal & External BGP
• eBGP used to:
– Exchange networks/routes between ASes
• Aggregates and sub-aggregates
4
BGP Message Types
• Open:
– After a TCP connection has been established between two
BGP routers, an Open message is sent
• Once the open message is confirmed (keepalive), the BGP session is
established – become BGP peers/neighbors!
– Contains:
• Sender’s ASN
• BGP version
• BGP router ID
• Hold-time (3 x keepalive interval)
• *Optionally authentication information
5
BGP Message Types
• Keepalive:
– Exchanged initially to acknowledge Open messages
– Exchanged periodically (60 secs) to maintain BGP session
• Dataless packet
• Update:
– BGP peers exchange network information through Update
messages
• One update for each path!
– Contains:
• Withdrawn routes – routes that are no more reachable <prefix, length>
• Path attributes – attributes for this path to reach the destinations
specified by the NLRI
• NLRI – list of networks reachable through this path <prefix, length>
6
BGP Message Types
• Notification:
– Sent when an error condition is detected
– The BGP session is torn down immediately!
– Contains:
• Error code
• Error sub-code
• Data related to error
7
BGP Neighbor States
• A BGP router goes through six different states
– Idle
• The router is looking for a route to its neighbor
– Connect
• BGP router moves from Idle to Connect state if it has found a route to its
neighbor, and has started the TCP handshake
• If the TCP session successful, sends an Open message (and transitions to
OpenSent)
• Else, move to Active state
– Active
• A router transitions to Active state if the initial TCP connection was not
successful (in Connect state)
• Restarts the TCP connection
• If successful, sends an Open message
• Else, falls back to Idle state
8
BGP Neighbor States
– OpenSent
• An Open message has been sent to the neighbor
• Waiting for an Open message from neighbor
• If it receives an Open message and there are no mismatches (version,
source addr same as TCP addr, ASN, router-ID, TTL, md5), sends
Keepalive, moves to OpenConfirm
• Else (if mismatches/errors), sent Notification and falls back to Idle
– OpenConfirm
• waiting for the initial Keepalive
• If received, transitions to Established
• If holdtimer expires or Notification received, moves to Idle
– Established
• The BGP neighbor relationship (session) is established!
• Routing information can now be exchanged
• If holdtimer expires/error, moves back to Idle
9
BGP State Machine
Idle
Connect
Active
OpenSent
OpenConfirm
Established
10
BGP Neighbor Relationship
• eBGP neighbors/peers
– BGP session between routers in different ASes
– Generally directly connected!
• Session established using directly connected interface IP
• Peering address must match the TCP session!
11
BGP Neighbor Relationship
• iBGP neighbors/peers
– BGP session between routers within the same AS
– Does not need to be directly connected
• IGP ensures reachability (TCP connection)
– Generally using loopback addresses
12
iBGP Operation
• iBGP routers must:
– Originate directly connected routes
13
iBGP full-mesh
10.10.10.4
R4
10.10.10.1
router bgp 17821
10.10.10.3
neighbor 10.10.10.2 remote-as 17821
neighbor 10.10.10.3 remote-as 17821
R1 R3 neighbor 10.10.10.4 remote-as 17821
!
AS17821
R2
10.10.10.2
14
Sourcing iBGP from Loopback
• By default, routers use the exit-interface address as
the source address for locally originated packets
(updates)
– If the BGP TCP session was established using any other
interface (loopbacks) addresses, the source address for BGP
updates must match!
15
BGP Synchronous Rule
• “iBGP learned routes should not be installed in the
routing table nor advertised to eBGP peers unless
the route was learned through an IGP first!”
16
Advertising Networks in BGP
• The network statement
– allows BGP to inject routes into BGP table and advertise to
neighbors only if it already exists in the routing table!
router bgp 17821
address-family ipv4 unicast
network <prefix> mask <subnet-mask>
address-family ipv6 unicast
network <prefix/length>
• Using redistribute
– Normally with static or connected routes
17
How it all works?
eBGP eBGP
18
Acknowledgement:
• Philip Smith
• Cisco Systems
19
20