Border Gateway Protocol (BGP) is the routing protocol of the internet, designed for exchanging routing information between different autonomous systems (AS). An autonomous system is a network or group of networks under a single administrative domain. BGP is a path-vector protocol, which means it considers the path (via AS numbers) that a route takes to reach its destination.
BGP uses TCP (port 179) for reliable communication between peers, called BGP neighbors or BGP speakers.
BGP uses four main types of messages to communicate between peers:
Open:
Update:
Keepalive:
Notification:
Key Points to Remember:
BGP uses attributes to provide additional information about routes. These attributes influence route selection and propagation.
AS_PATH:
NEXT_HOP:
ORIGIN:
BGP uses a step-by-step process to select the best route among multiple available routes:
Weight (Cisco-specific, local to the router):
Local Preference:
AS_PATH:
Origin:
MED:
eBGP vs. iBGP:
Shortest IGP Path to Next-Hop:
Oldest Route:
Router ID:
BGP has two operational modes depending on the relationship between peers:
eBGP (External BGP):
iBGP (Internal BGP):
Configuration Example:
set protocols bgp group EBGP neighbors 192.168.1.1 peer-as 65002
set protocols bgp group IBGP neighbors 10.0.0.1 local-as 65001
In large networks, a full-mesh iBGP setup is impractical due to the exponential growth of peer connections.
What is a Route Reflector?
Key Components:
Configuration Example:
set protocols bgp group INTERNAL type internal
set protocols bgp group INTERNAL neighbor 10.1.1.1 route-reflector-client
Communities are used to tag routes for policy implementation.
Configuration Example:
set policy-options policy-statement COMMUNITY-EXAMPLE term 1 then community add NO-EXPORT
BGP configuration involves setting up sessions between peers, defining policies, and managing attributes. Below is a detailed breakdown with examples for both eBGP and iBGP setups.
Scenario:
Configuration on Router A:
set protocols bgp group EBGP type external
set protocols bgp group EBGP local-address 192.168.1.1
set protocols bgp group EBGP peer-as 65002
set protocols bgp group EBGP neighbor 192.168.1.2
Configuration on Router B:
set protocols bgp group EBGP type external
set protocols bgp group EBGP local-address 192.168.1.2
set protocols bgp group EBGP peer-as 65001
set protocols bgp group EBGP neighbor 192.168.1.1
Explanation:
type external:local-address:peer-as:neighbor:Scenario:
Configuration on Router A:
set protocols bgp group IBGP type internal
set protocols bgp group IBGP local-address 10.0.0.1
set protocols bgp group IBGP neighbor 10.0.0.2
set protocols bgp group IBGP neighbor 10.0.0.3
Configuration on Router B:
set protocols bgp group IBGP type internal
set protocols bgp group IBGP local-address 10.0.0.2
set protocols bgp group IBGP neighbor 10.0.0.1
set protocols bgp group IBGP neighbor 10.0.0.3
Configuration on Router C:
set protocols bgp group IBGP type internal
set protocols bgp group IBGP local-address 10.0.0.3
set protocols bgp group IBGP neighbor 10.0.0.1
set protocols bgp group IBGP neighbor 10.0.0.2
Key Points:
Scenario:
Configuration on Router A (Route Reflector):
set protocols bgp group IBGP type internal
set protocols bgp group IBGP neighbor 10.0.0.2 route-reflector-client
set protocols bgp group IBGP neighbor 10.0.0.3 route-reflector-client
Configuration on Routers B and C:
set protocols bgp group IBGP type internal
set protocols bgp group IBGP neighbor 10.0.0.1
Key Points:
Path Selection Optimization:
Security:
Use prefix-lists and route-maps to filter routes.
Implement BGP peer authentication using MD5:
set protocols bgp group EBGP authentication-key securekey
Route Aggregation:
Aggregate multiple prefixes to simplify route advertisements:
set policy-options policy-statement AGGREGATE term 1 from route-filter 192.168.0.0/16 orlonger
set policy-options policy-statement AGGREGATE term 1 then accept
set protocols bgp group EBGP export AGGREGATE
Monitoring:
Use BGP troubleshooting commands to check peer status and routing table:
show bgp neighbor
show route protocol bgp
BGP issues often arise from misconfigurations, attribute mismatches, or connectivity problems. Key steps for troubleshooting:
Verify Neighbor State:
show bgp neighbor
Check Routes:
show route protocol bgp
Debugging:
monitor start file bgp-log
monitor stop
Common Issues:
as-path-ignore cautiously to avoid loop prevention mechanisms.BGP is a path-vector routing protocol used to exchange routing information between autonomous systems (ASes). It is the core protocol of the internet, and also used within enterprises for inter-domain routing. BGP supports policy-based routing and uses attributes like AS_PATH, NEXT_HOP, and LOCAL_PREF to make route selection decisions.
While iBGP (Internal BGP) is used within a single AS, it has a strict rule that significantly impacts design and scalability:
iBGP-learned routes are not advertised to other iBGP peers.
This loop prevention mechanism ensures routing stability.
To ensure full reachability, networks must:
Use a full mesh of iBGP sessions, or
Deploy Route Reflectors to overcome scalability limitations.
This behavior contrasts with eBGP, where learned routes are freely propagated to other peers.
BGP uses the AS_PATH attribute to prevent routing loops across autonomous systems.
By default, a BGP router will reject any route that contains its own AS number in the AS_PATH.
This simple but effective mechanism ensures that routes do not loop indefinitely between ASes.
It’s visible in the routing table as a string of AS numbers.
The as-path-ignore option (in Junos and other vendors) can override this behavior, but it should be used with extreme caution.
When establishing a BGP session, the protocol goes through a series of states defined by the BGP Finite State Machine (FSM). Understanding these states is crucial for troubleshooting peer establishment issues.
| State | Description |
|---|---|
| Idle | Initial state. BGP waits for a Start event to begin TCP connection. |
| Connect | TCP connection initiated; waiting for response. |
| Active | TCP connection still being attempted (e.g., retry after Connect fails). |
| OpenSent | TCP connection established. Open message sent to peer. |
| OpenConfirm | Awaiting Keepalive message from peer after Open has been acknowledged. |
| Established | BGP session is fully established. Route updates can now be exchanged. |
Use show bgp neighbor to see the current session state. Common failure points include:
Stuck in Active: TCP connectivity issue (e.g., port 179 blocked).
OpenSent/OpenConfirm: Misconfigured BGP parameters (e.g., AS number mismatch).
Established flapping: Possibly due to Keepalive or Hold timer mismatches, or authentication failures.
| Topic | Key Detail |
|---|---|
| iBGP Propagation Rule | iBGP does not advertise routes learned from other iBGP peers. Requires full mesh or route reflectors. |
| AS_PATH Loop Prevention | Routes containing the router's own AS are dropped by default to prevent loops. |
| BGP FSM States | Idle → Connect → Active → OpenSent → OpenConfirm → Established. Essential for troubleshooting BGP session issues. |
How does BGP select the best path between multiple routes?
BGP evaluates several attributes in sequence, such as local preference, AS path length, and MED.
When multiple routes to the same destination exist, BGP applies a best-path algorithm to determine which route should be installed in the routing table. The process compares several attributes in a defined order. Local preference is typically evaluated first and determines the preferred exit point from an AS. If local preference values are equal, BGP compares the AS-path length, preferring the route with the shortest path. Additional attributes such as origin type, MED, and eBGP versus iBGP are then evaluated. This step-by-step decision process ensures consistent route selection across the network.
Demand Score: 90
Exam Relevance Score: 95
What is the purpose of the BGP local preference attribute?
Local preference determines the preferred exit point for traffic leaving an autonomous system.
Local preference is a well-known discretionary attribute used within an autonomous system to influence outbound traffic. Routes with higher local preference values are preferred over those with lower values. Because local preference is propagated to all iBGP peers inside the AS, it allows network operators to enforce consistent routing decisions across the network. For example, a service provider may assign higher local preference to routes learned from a primary upstream provider and lower values to backup providers.
Demand Score: 85
Exam Relevance Score: 93
Why might a BGP route not be advertised to a neighbor?
Because of route policies, route filtering, or next-hop reachability issues.
BGP advertisements are often controlled by routing policies that filter or modify routes before they are sent to peers. If a policy rejects a route or changes its attributes, the route may not be exported. Another common issue is next-hop reachability; BGP requires that the next-hop address be reachable through the routing table. If the next hop cannot be resolved, the route will not be advertised. Engineers typically verify this using commands such as show route advertising-protocol bgp.
Demand Score: 88
Exam Relevance Score: 92
What is the difference between eBGP and iBGP?
eBGP operates between different autonomous systems, while iBGP operates within the same AS.
External BGP (eBGP) sessions are established between routers belonging to different autonomous systems. These sessions exchange routing information between networks. Internal BGP (iBGP) runs within the same AS and distributes external routing information across the network. iBGP requires a full mesh or route reflection design to ensure routes are properly propagated. Additionally, eBGP typically uses a TTL of 1 and modifies the next-hop attribute, while iBGP preserves it.
Demand Score: 79
Exam Relevance Score: 87
What is the purpose of the BGP AS-Path attribute?
The AS-Path records the sequence of autonomous systems a route has traversed.
The AS-Path attribute serves two important purposes: loop prevention and path selection. Each BGP router that advertises a route prepends its AS number to the path. If a router receives a route containing its own AS number in the AS-Path, the route is rejected to prevent routing loops. Additionally, shorter AS-Paths are generally preferred during best-path selection because they represent a shorter route through the Internet.
Demand Score: 80
Exam Relevance Score: 90
What is a route reflector in BGP?
A route reflector reduces the need for a full mesh of iBGP sessions.
In large networks, maintaining a full mesh of iBGP sessions between all routers becomes impractical because the number of sessions grows exponentially. Route reflectors solve this scalability issue by allowing one router to reflect routes to other routers. Clients send routes to the reflector, which then distributes them to other clients. This design reduces the number of required BGP sessions while maintaining consistent routing information.
Demand Score: 76
Exam Relevance Score: 91