Routes are generally categorized into two types:
Directly Connected Routes: These routes have a default preference value of 0, representing the highest priority.
Non-Directly Connected Routes: These are further divided into static routes (default preference 60) and dynamic routes. Dynamic routing protocols fall into two categories:
- IGP (Interior Gateway Protocol): Includes Distance Vector protocols like RIP, IGRP, and EIGRP, as well as Link State protocols such as OSPF and IS-IS. OSPF operates at Layer 3, with routes derived from Type 1, 2, and 3 LSAs having a preference of 10, while Type 4, 5, and 7 LSAs yield routes with preference 150. IS-IS functions at Layer 2.
- EGP (Exterior Gateway Protocol): BGP is the primary EGP protocol. It is a Distance Vector protocol operating at the application layer over TCP port 179, with a default route preference of 255.
Rationale for Deploying BGP
BGP is essential for inter-AS communication and offers three key advantages:
- Stability: Utilizes TCP for reliable transport, employing five message types and six state transitions for reliable route propagation.
- Scalability: Capable of handling massive routing tables through precise network injection and import meechanisms.
- Rich Policy Control: Provides granular routing policies with 11 distinct path selection criteria.
Autonomous System Numbers
An Autonomous System (AS) is a unique identifier representing a collection of routers under a single administrative domain. Key characteristics include:
- AS numbers facilitate efficient routing decisions across the internet.
- The Internet Assigned Numbers Authority (IANA) oversees AS number allocation.
- AS numbers are classified as public (allocated by IANA) and private (allocated by Regional Internet Registries).
- 4-byte AS numbers are managed by IANA and distributed through RIRs.
BGP Operational Mechanics
Core Function
BGP dynamically exchanges routing information between autonomous systems.
Neighbor Relationships
- EBGP (External BGP): Established between routers in different ASs.
- IBGP (Internal BGP): Established between routers within the same AS.
Key Characteristics
- Operates at the application layer using TCP port 179.
- Routers running BGP are referred to as BGP Speakers.
- Connected BGP routers form a peer relationship.
- Routing updates are incremental and triggered rather than periodic.
- Designed to handle large-scale routing tables suitable for enterprise and ISP networks.
Message Types
BGP uses five distinct message types:
- Open Message: Initiates peer relationships and exchanges capabilities (analogous to a Hello packet).
- KeepAlive Message: Maintains the peer session. This is the only periodic message in BGP, sent every 60 seconds. If three consecutive KeepAlives are missed, a Notification is sent to terminate the session.
- Update Message: Carries routing information, including path attributes and reachable destinations. Also used to withdraw previously advertised routes.
- Notification Message: Reports errors and terminates BGP connections. Commonly triggered when attempting EBGP peering via loopback interfaces without proper configuration.
- Route-Refresh Message: Requests peers to resend routing advertisements. Triggered via command: ```
[RouterBGP] refresh bgp all import
Finite State Machine
BGP transitions through six states during neighbor establishment:
- Idle: Initial state where no TCP connection exists. Typically caused by Layer 3 reachability issues. Transitions to Connect when attempting TCP establishment.
- Connect: TCP connection attempt in progress. If successful, sends Open message and moves to OpenSent. If TCP fails, transitions to Active.
- Active: TCP connection failed. The router continues attempting TCP establishment. Upon success, moves to OpenSent.
- OpenSent: Open message has been sent. Awaiting response. Valid Open response triggers KeepAlive and moves to OpenConfirm. Invalid response results in Notification and return to Idle.
- OpenConfirm: Waiting for KeepAlive confirmation. Receipt of KeepAlive moves to Established. Receipt of Notification returns to Idle.
- Established: Peering is fully operational. Udpate messages can now be exchanged. Malformed Update or KeepAlive messages trigger Notification and return to Idle.
Connection Establishment Flow
- Establish Layer 3 reachability.
- Complete TCP three-way handshake.
- Form BGP neighbor relationship.
- Exchange routing information.
Attribute Categories
BGP path attributes fall into four categories:
- Well-known Mandatory
- Well-known Discretionary
- Optional Transitive
- Optional Non-transitive
Path Selection Algorithm
BGP evaluates routes sequentially through 11 criteria until a single best path is selected:
- Preference Value (PrefVal): Huawei-proprietary attribute, local to the router. Higher values are preferred. Default is 0.
- Local Preference (Loc_Pref): Well-known discretionary attribute. Higher values preferred. Default is 100.
- Locally Originated Routes: Routes originated locally take precedence over learned routes. Priority order: Manual aggregate > Automatic aggregate > Network command > Import.
- AS_Path Length: Shorter AS_Path is preferred. This attribute also prevents routing loops between EBGP peers.
- Origin Type: IGP (i) > EGP (e) > Incomplete (?). Network command yields IGP, while import yields Incomplete.
- MED (Multi-Exit Discriminator): Lower values indicate a better entry point into the AS. Analogous to IGP metric.
- EBGP vs IBGP: EBGP-learned routes are preferred over IBGP-learned routes.
- IGP Metric to Next-Hop: Lower IGP cost to reach the BGP next-hop is preferred.
If multiple paths remain equally preferred after these 8 criteria, load balancing can be enabled:
[Router-bgp] maximum load-balancing ibgp 2
- Cluster_List Length: Shorter length is preferred. Relevant in Route Reflector scenarios to prevent inter-cluster loops.
- Router ID / Originator ID: Lower Router ID is preferred. In RR scenarios, Originator ID is compared instead.
- Peer IP Address: Lowest peer IP address is selected as the tiebreaker.