Computer Networking - BGP
Categories:
Understanding BGP: The Internet's Routing Protocol

Explore the fundamentals of Border Gateway Protocol (BGP), its role in inter-domain routing, and key concepts like ASNs, peering, and path attributes.
The Border Gateway Protocol (BGP) is the de facto standard exterior gateway protocol (EGP) used to exchange routing and reachability information among autonomous systems (AS) on the Internet. Unlike interior gateway protocols (IGPs) like OSPF or EIGRP, which route traffic within a single AS, BGP handles routing between different ASes, making it the backbone of the global internet routing table. Understanding BGP is crucial for anyone involved in network architecture, internet service provision, or large-scale enterprise networking.
BGP Fundamentals: Autonomous Systems and Peering
At the core of BGP is the concept of an Autonomous System (AS). An AS is a collection of IP networks and routers under the control of one or more network operators that presents a common, clearly defined routing policy to the Internet. Each AS is identified by a unique Autonomous System Number (ASN), a 16-bit or 32-bit number assigned by regional internet registries (RIRs).
BGP routers establish peering relationships with other BGP routers to exchange routing information. These peering sessions can be internal (iBGP) within the same AS or external (eBGP) between different ASes. eBGP is used to exchange routes with external neighbors, while iBGP ensures that all routers within an AS have a consistent view of external routes.
graph TD subgraph AS65001 R1_AS1[Router 1 (AS65001)] R2_AS1[Router 2 (AS65001)] R1_AS1 -- iBGP --> R2_AS1 end subgraph AS65002 R1_AS2[Router 1 (AS65002)] R2_AS2[Router 2 (AS65002)] R1_AS2 -- iBGP --> R2_AS2 end R1_AS1 -- eBGP --> R1_AS2
Basic BGP Peering between two Autonomous Systems
BGP Path Attributes and Route Selection
BGP is a path-vector routing protocol, meaning it doesn't just advertise reachability to a destination network, but also the full path (sequence of ASes) that packets must traverse to reach that destination. This path information is carried within BGP updates as 'path attributes'. These attributes are crucial for BGP's sophisticated route selection process.
Key BGP path attributes include:
- AS_PATH: The sequence of ASNs through which a route advertisement has passed.
- NEXT_HOP: The IP address of the next-hop router to reach the advertised destination.
- LOCAL_PREF: An attribute used within an AS to prefer one exit path over another for outbound traffic.
- MED (Multi-Exit Discriminator): An attribute exchanged between ASes to influence inbound traffic decisions.
- ORIGIN: Indicates how the route was learned (e.g., IGP, EGP, Incomplete).
When a BGP router receives multiple paths to the same destination, it uses a deterministic best-path selection algorithm, evaluating these attributes in a specific order to choose the optimal route. This algorithm allows network operators to implement complex routing policies.
Configuring a Basic eBGP Peer
Setting up a basic eBGP peering session involves configuring the BGP process on both routers, specifying the remote AS number, and defining the neighbor's IP address. Here's a simplified example for Cisco IOS-XE/IOS-XR and Juniper Junos.
Cisco IOS-XE/IOS-XR
router bgp 65001
neighbor 192.0.2.2 remote-as 65002
address-family ipv4 unicast
network 10.0.0.0 mask 255.255.255.0
neighbor 192.0.2.2 activate
exit-address-family
Juniper Junos
protocols {
bgp {
group EBGP-PEER {
type external;
peer-as 65002;
neighbor 192.0.2.2;
}
}
}
routing-options {
autonomous-system 65001;
}
These configurations establish a basic eBGP session and advertise a network (10.0.0.0/24 in the Cisco example). Real-world BGP configurations often involve extensive policy maps, route maps, and filtering to control which routes are advertised and accepted.