BGP Fundamentals and Autonomous Systems
Border Gateway Protocol (BGP) is a path-vector routing protocol that operates at the application layer. It uses TCP port 179 to establish connections between routers. Unlike interior gateway protocols, BGP is designed specifically for routing between autonomous systems (AS), which are networks under a single administrative control.
Understanding Autonomous System Numbers
Each autonomous system receives a unique ASN (Autonomous System Number). These are 16-bit or 32-bit identifiers assigned by regional internet registries. BGP routers, called BGP speakers, establish neighbor relationships called peerings. These peerings form the foundation of BGP communication.
BGP Deployment Types
BGP routers exchange UPDATE messages containing network prefix information and path attributes. The two main deployment types are:
- eBGP (external BGP): Operates between different autonomous systems
- iBGP (internal BGP): Operates within the same autonomous system
BGP Decision Process
BGP uses a decision process to select the best path based on multiple attributes. These include AS path length, local preference, multi-exit discriminator (MED), and origin type. This makes BGP policy-based routing, meaning administrators control traffic flow through configuration rather than automatic calculations. Understanding these fundamentals is crucial because BGP is more complex but far more powerful than other routing protocols.
BGP Path Attributes and Route Selection
BGP uses path attributes to determine the best path to a destination network. These attributes are communicated in UPDATE messages and allow routers to make intelligent routing decisions based on network policies.
Key BGP Path Attributes
The most important attributes include:
- AS Path: A sequence of AS numbers the route has traversed. Shorter paths are preferred
- Origin: How the route was learned (IGP, EGP, or incomplete). IGP is most preferred
- Next Hop: The IP address of the next BGP router to reach the destination
- Local Preference: Used to prefer certain exit points from an AS. Higher values are preferred
- Multi-Exit Discriminator (MED): Used when multiple routes exist through the same neighboring AS
- Weight: A Cisco-specific attribute that is local to a router and not advertised to peers
BGP Best Path Selection Algorithm
The complete algorithm considers attributes in this specific order:
- Weight (highest preferred)
- Local preference (highest preferred)
- Locally originated routes
- AS path length (shortest preferred)
- Origin type (IGP preferred)
- MED (lowest preferred)
- eBGP versus iBGP routes
- IGP metric to next hop
- Router ID
- Cluster ID
Mastering these attributes and their selection order is essential for understanding how BGP makes routing decisions. This knowledge is critical for configuring BGP networks effectively.
BGP Configuration and Neighbor Relationships
Configuring BGP requires establishing neighbor relationships between routers. This is the foundation of BGP operation. To enable BGP, enter BGP configuration mode using the command 'router bgp [ASN]', where ASN is your autonomous system number.
Setting Up BGP Neighbors
Next, define BGP neighbors using the 'neighbor [IP] remote-as [ASN]' command. This specifies the IP address of the neighbor router and its autonomous system number. The neighbor IP address can be a direct neighbor for eBGP or any router within your AS for iBGP.
Once neighbors are configured, BGP attempts to establish a TCP connection on port 179. The routers then exchange UPDATE messages containing route information.
Advertising Networks in BGP
To advertise networks in BGP, use the 'network [network] mask [mask]' command. The network must exist in the routing table before it can be advertised. Alternatively, use 'redistribute' commands to inject routes learned from other routing protocols into BGP.
Route Filtering and Manipulation
BGP supports route filtering and manipulation through:
- Access lists: Filter routes based on network addresses
- Route maps: Enable conditional filtering and attribute modification
- Prefix lists: More efficient than access lists for filtering multiple routes
A prefix list uses the syntax 'ip prefix-list [name] seq [number] [permit/deny] [network/length]'. Route maps allow you to modify local preference, weight, MED, and other attributes during redistribution or neighbor policies. These tools help implement network policies effectively.
BGP Route Advertisement and Filtering
BGP route advertisement is the process by which routers share network reachability information with their BGP neighbors. When a router learns a route, it places it in its BGP table and announces it to peers. The router attaches path attributes that influence how the route is used.
The UPDATE message contains Network Layer Reachability Information (NLRI). This includes the network prefix, prefix length, and path attributes such as AS path, origin, next hop, and local preference.
Why Route Filtering Matters
By default, BGP advertises all learned routes to all configured neighbors. However, network policies often require filtering these advertisements. This controls traffic flow and improves network stability.
Route Filtering Mechanisms
Route filtering in BGP uses several mechanisms:
- Access lists: Filter routes by network address but are less efficient for large numbers
- Prefix lists: More efficient and support exact matches and range matches
- Route maps: Provide maximum flexibility with multiple match criteria and conditional actions
Use the 'neighbor [IP] distribute-list [number] out' command to filter outbound advertisements. Use 'in' to filter inbound advertisements. Outbound filtering prevents your network from advertising certain prefixes to peers. Inbound filtering prevents accepting routes from peers.
Communities for Policy Application
BGP also supports communities, which are optional transitive attributes. These allow grouping of routes for policy application. Understanding route filtering is critical for implementing network security policies, preventing route hijacking, and controlling traffic flow across interconnected autonomous systems.
BGP Troubleshooting and Advanced Concepts
Troubleshooting BGP issues requires systematic diagnosis and understanding of BGP operation at each step. Common problems include neighbor adjacency failures, route advertisement issues, suboptimal routing, and convergence delays.
Diagnosing Neighbor Issues
To diagnose neighbor problems, use the 'show ip bgp neighbors' command. This verifies neighbor state, which should show 'Established' for active peerings. The neighbor state machine includes stages: Idle, Connect, Active, OpenSent, OpenConfirm, and Established.
If neighbors remain in Connect or Active states, verify TCP port 179 connectivity, neighbor IP configuration, and AS number accuracy. The 'show ip bgp [prefix]' command displays detailed information about a specific route. This shows all received advertisements and the selected best path with its attributes.
Verifying Route Advertisement
If routes are not being advertised or received, verify several things. First, ensure networks are configured with the 'network' command or redistribution is enabled. Second, confirm that no filtering rules are blocking the routes. These checks resolve most route advertisement issues quickly.
Scaling iBGP Deployments
Route reflectors (RR) are used in iBGP deployments to reduce required connections. A route reflector reflects iBGP routes received from clients to other clients. This prevents the full mesh requirement of standard iBGP, reducing configuration complexity and improving scalability in large networks.
BGP confederation is another advanced technique that divides an AS into multiple sub-autonomous systems. This reduces iBGP peering requirements without requiring route reflectors. Understanding these advanced concepts allows engineers to design scalable, efficient BGP networks that support large-scale internet connectivity and implement complex routing policies.
