BGP Fundamentals for Inter-Autonomous System Routing
To manage increasingly large networks, the internet is divided into autonomous systems (ASes). Originally, the Exterior Gateway Protocol (EGP) was used to exchange routing information between ASes. However, EGP lacked mechanisms for route selection, loop prevention, and scalability, prompting the development of a more robust solution.
Border Gateway Protocol (BGP) was introduced to replace EGP. Unlike EGP, BGP supports intelligent route selection, prevents routing loops, efficiently propagates updates, and scales to handle vast routing tables—making it the de facto protocol for inter-domain routing on the internet.
Autonomous Systems (AS)
Interior Gateway Protocols (IGPs) like OSPF and IS-IS operate within a single administrative domain. As networks grow, managing all routes with a single IGP becomes impractical. An AS is a collection of routers under a common administrative policy, identified by a unique AS number (ASN). ASNs can be 16-bit or 32-bit, assigned by IANA.
Why Not Use IGP Between ASes?
Using IGPs across AS boundaries poses several issues:
- Requires direct or logically tunneled (e.g., GRE) connectivity.
- Exposes internal network topology to external entities, raising security concerns.
- Leads to excessively large routing tables, slower convergence, and higher resource consumption.
Advantages of BGP for Inter-AS Communication
BGP addresses these limitations by:
- Operating over TCP (port 179), enabling neighbor relationships without physical adjacency.
- Advertising only reachability information with out revealing internal topology.
- Using triggered, incremental updates instead of periodic full-table advertisements.
BGP Overview and Evolution
BGP is a path-vector protocol that enables ASes to exchange routing information and select optimal paths. Key versions include:
- BGP-1 (RFC 1105), BGP-2 (RFC 1163), BGP-3 (RFC 1267)
- BGP-4 (RFC 1771, later updated by RFC 4271) for IPv4 unicast
- MP-BGP (RFC 4760) for multi-protocol support (e.g., IPv6, VPNs)
Key Characteristics of BGP
- Runs over TCP port 179.
- Supports massive routing tables (hundreds of thousands of prefixes).
- Uses rich path attributes (e.g., AS_PATH, LOCAL_PREF, MED) for flexible policy-based routing.
- Enables route aggregation and dampening to enhance stability.
- Fundamental to MPLS/VPN architectures.
BGP Peering Relationships
BGP peers (or speakers) establish sessions over TCP. Two types exist:
- EBGP (External BGP): Peers in different ASes. Typically requires direct connectivity (TTL=1 by default).
- IBGP (Internal BGP): Peers within the same AS. Does not require direct links but must be fully meshed or use route reflectors.
BGP Session Establishment
The BGP session setup process:
- One router initiates a TCP connection to port 179 of the peer.
- After TCP handshake, both exchange
Openmessages containing:- Local ASN
- Hold Time
- BGP Identifier (Router ID)
- If parameters match, both send
Keepalivemessages, transitioning toEstablishedstate. - Routing updates are then exchanged via
Updatemessages.
TCP Source Address Considerations
By default, BGP uses the outgoing interface’s IP as the TCP source. Best practices:
- IBGP: Use Loopback interfaces as the source to leverage IGP redundancy and ensure session stability.
- EBGP: Usually uses physical interface IPs. If Loopback is used, configure
ebgp-multihopto allow TTL > 1.
BGP Message Types
Open: Initiates peeringUpdate: Advertises or withdraws routesKeepalive: Maintains session livenessNotification: Signals errors and terminates session
BGP Peer Table
<R1> display bgp peer
BGP local router ID : 10.0.1.1
Local AS number : 100
Total peers : 1 Established : 1
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
10.0.12.2 4 100 25719 25714 0 0428h32m Established 1
Key fields: peer IP, ASN, uptime, session state, and number of received prefixes.
BGP Routing Table
<R1> display bgp routing-table
Status codes: * - valid, > - best
Origin: i - IGP, e - EGP, ? - incomplete
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 10.0.45.0/24 10.0.4.4 0 100 0 ?
* i 10.0.4.0/32 10.0.4.4 0 100 0 ?
Use display bgp routing-table [prefix] for detailed path attributes like AS_PATH, originator, and cluster list.
Injecting Routes into BGP
BGP does not discover routes autonomously. Routes are injected from existing sources:
- Network command: Explicitly advertises exact prefixes present in the IP routing table.
- import-route: Imports routes from connected, static, OSPF, IS-IS, etc., simplifying bulk injection.
Route Aggregation
BGP supports manual summarization using the aggregate command, which creates a summary route when matching more-specific routes exist in the BGP table.
BGP Route Advertisement Principles
- Only best and valid routes are advertised. Validity requires reachable next-hop; best is selected via BGP decision process.
- Routes learned from EBGP peers are advertised to all peers (IBGP and EBGP).
- IBGP horizontal split: Routes learned from a IBGP peer are not re-advertised to other IBGP peers (prevents loops).
- Synchronization rule (historical): Before advertising an IBGP-learned route to EBGP, ensure it exists in the IGP table. This avoids "black holes" where transit routers lack the route.
Addressing the IBGP Black Hole Problem
Due to IBGP split-horizon, non-BGP routers in the AS core may drop traffic. Solutions include:
- Full IBGP mesh: All BGP routers peer with each other.
- Redistribute BGP into IGP: Propagate BGP routes via OSPF/IS-IS (use cautiously due to scale).
- MPLS/LDP: Use label switching to forward packets with out requiring BGP on core routers.
Basic BGP Configuration
Configuration Steps
-
Enable BGP and set Router ID: ```
[Huawei] bgp 100 [Huawei-bgp] router-id 10.0.1.1
-
Define peers: ```
[Huawei-bgp] peer 10.0.3.3 as-number 100 # IBGP [Huawei-bgp] peer 10.0.34.4 as-number 200 # EBGP
-
Set source interface and EBGP multihop (if needed): ```
[Huawei-bgp] peer 10.0.3.3 connect-interface LoopBack1 [Huawei-bgp] peer 10.0.34.4 ebgp-max-hop 2
Example Topology Configuration
Assume R1 and R3 are in AS 100; R4 is in AS 200. Loopback1 is used as Router ID and IBGP source.
R1:
[R1] bgp 100
[R1-bgp] router-id 10.0.1.1
[R1-bgp] peer 10.0.3.3 as-number 100
[R1-bgp] peer 10.0.3.3 connect-interface LoopBack1
R3:
[R3] bgp 100
[R3-bgp] router-id 10.0.3.3
[R3-bgp] peer 10.0.1.1 as-number 100
[R3-bgp] peer 10.0.1.1 connect-interface LoopBack1
[R3-bgp] peer 10.0.34.4 as-number 200
R4:
[R4] bgp 200
[R4-bgp] router-id 10.0.4.4
[R4-bgp] peer 10.0.34.3 as-number 100
Verification on R3:
<R3> display bgp peer
BGP Local router ID : 10.0.3.3
Local AS number : 100
Total peers : 2 Established : 2
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
10.0.1.1 4 100 0 0 0 00:00:07 Established 0
10.0.34.4 4 200 32 35 0 00:17:49 Established 0