BGP is a path vector protocol that is primarily used for inter-domain routing. Unlike OSPF or IS-IS, which are used within a single autonomous system (AS), BGP is designed to exchange routing information between multiple ASes.
Key Characteristics:
Purpose:
BGP operates in two modes depending on whether it is used between or within ASes:
eBGP (External BGP):
iBGP (Internal BGP):
BGP uses attributes to determine the best path. These attributes are divided into categories:
Well-Known Mandatory:
Optional Transitive:
BGP is highly policy-driven, meaning you can control which routes are advertised or accepted. Policies can:
As BGP networks grow, managing iBGP peering can become complex. Two mechanisms help address this:
When a router receives multiple routes to the same destination, BGP uses a decision-making process to choose the best path. The steps are evaluated in this order:
Local Preference:
AS_PATH:
Multi-Exit Discriminator (MED):
eBGP vs. iBGP:
Router ID:
Communities allow tagging and grouping of routes. They are used in routing policies to apply consistent actions.
Predefined Communities:
Custom Communities:
eBGP peering is configured to establish a connection between routers in different ASes. Example:
set protocols bgp group ebgp-peer type external
set protocols bgp group ebgp-peer peer-as 65002
set protocols bgp group ebgp-peer neighbor 192.0.2.1
To configure a router as a route reflector:
set protocols bgp group internal type internal
set protocols bgp group internal cluster 192.0.2.100
set protocols bgp group internal neighbor 192.0.2.2
Policies play a significant role in controlling BGP behavior. Below are some common advanced configurations:
Control which prefixes are advertised or accepted using filters.
Example: Filter incoming prefixes from a specific AS:
set policy-options policy-statement block-as term 1 from as-path AS-65002
set policy-options policy-statement block-as term 1 then reject
set protocols bgp group ebgp-peer import block-as
Add your own AS multiple times to make a route less preferred.
Example: Prepend AS path for outbound routes:
set policy-options policy-statement prepend-as term 1 then as-path-prepend "65001 65001"
set protocols bgp group ebgp-peer export prepend-as
Set a higher Local Preference to make a route preferred within the AS.
Example: Assign Local Preference of 200 to certain routes:
set policy-options policy-statement set-local-pref term 1 from route-filter 192.0.2.0/24 exact
set policy-options policy-statement set-local-pref term 1 then local-preference 200
set protocols bgp group internal import set-local-pref
Combine multiple prefixes into a single route to reduce the size of routing tables.
Example: Aggregate multiple prefixes:
set routing-options aggregate route 203.0.113.0/24
set routing-options aggregate route 203.0.113.0/24 policy aggregate-policy
set policy-options policy-statement aggregate-policy term 1 then accept
When issues arise with BGP, the following steps and commands can help identify and resolve problems.
TCP Port 179 Blocked:
Neighbor Configuration Mismatch:
Command to check:
show bgp neighbor
Filters in Place:
Prefix Not Advertised:
Commands to verify:
show route advertising-protocol bgp <neighbor-ip>
show route receive-protocol bgp <neighbor-ip>
as-path filters to reject such routes.BGP Summary:
show bgp summary
BGP Table:
show route protocol bgp
BGP Logs:
show log messages
Organizations often connect to multiple ISPs for redundancy and load balancing.
Example: Configure BGP for two ISPs:
set protocols bgp group isp1 type external
set protocols bgp group isp1 peer-as 65002
set protocols bgp group isp1 neighbor 192.0.2.1
set protocols bgp group isp2 type external
set protocols bgp group isp2 peer-as 65003
set protocols bgp group isp2 neighbor 198.51.100.1
Control how traffic enters or leaves your network by manipulating attributes like Local Preference, AS_PATH, and MED.
Example: Prefer one ISP for inbound traffic:
set policy-options policy-statement prefer-inbound term 1 from route-filter 192.0.2.0/24 exact
set policy-options policy-statement prefer-inbound term 1 then med 50
set protocols bgp group isp1 export prefer-inbound
Advertise null routes or blackhole routes to block malicious traffic.
Example: Configure blackhole routing:
set routing-options static route 203.0.113.0/24 discard
set policy-options policy-statement blackhole term 1 from route-filter 203.0.113.0/24 exact
set policy-options policy-statement blackhole term 1 then community add blackhole
set policy-options policy-statement blackhole term 1 then accept
Administrative Distance (AD) is a critical concept when a router receives multiple routes to the same destination from different routing protocols. It helps determine which route to install in the routing table based on trustworthiness.
eBGP (External BGP):
Cisco default: 20
Juniper default: 170 for eBGP-learned routes
iBGP (Internal BGP): 200
OSPF: 110
Connected interface: 0
Static route: 5
A route learned via OSPF will override an iBGP route to the same prefix unless preference is explicitly changed.
In Junos, routing protocols have preference values, not AD. However, the concept is similar:
BGP (eBGP) preference: 170
BGP (iBGP) preference: 170
OSPF preference: 10 (internal), 150 (external)
You might be asked to choose which route is preferred between BGP and OSPF. Remember that in Juniper devices, the lower preference wins.
Loop prevention is fundamental in BGP's design and differs between eBGP and iBGP.
eBGP uses the AS_PATH attribute to detect routing loops.
If a BGP speaker sees its own AS number in the AS_PATH of a received update, it rejects the route.
iBGP does not modify the AS_PATH, so AS loop detection doesn’t apply.
To prevent loops, iBGP does not advertise routes learned from one iBGP peer to another iBGP peer.
This rule creates a challenge in large networks, which is resolved using either:
Full-mesh iBGP: All routers peer with each other
Route Reflectors (RRs): Allow hierarchical distribution of iBGP routes
“Why is full-mesh iBGP required?”
Normally, BGP installs only one best path per prefix into the routing table. However, in real-world scenarios (e.g., for load balancing), multiple paths might be desirable.
Junos allows multiple equal-cost BGP paths to be installed and used for ECMP (Equal-Cost Multi-Path) routing.
This is enabled with the multipath configuration under the BGP group:
set protocols bgp group ebgp-peer multipath
Multipath improves traffic distribution and resilience.
Add-Path solves BGP route oscillation and blackholing issues in multi-homed environments.
As networks increasingly support IPv6, BGP must be configured to carry IPv6 routes using the appropriate address family.
To enable BGP IPv6 unicast routing:
set protocols bgp group ebgp-v6 family inet6 unicast
inet6 denotes IPv6
unicast specifies the routing context (vs. multicast, for example)
Ensure that BGP peering is established over IPv6 addresses.
iBGP and eBGP over IPv6 are configured similarly to IPv4, but require address family declarations.
BGP Administrative Preference:
Loop Prevention:
Multipath Support:
multipath.IPv6 Support:
family inet6 unicast.Why are BGP routes learned from an eBGP neighbor not being advertised to an iBGP neighbor?
Because the BGP next-hop attribute is not reachable within the iBGP network.
When a router learns routes via eBGP, the next-hop attribute is preserved when advertising to iBGP peers. If the internal routers cannot reach that next-hop address through the IGP, the route is considered unusable.
To resolve this issue, the advertising router should configure:
next-hop-self
This changes the next-hop attribute to the advertising router’s address, ensuring internal routers have reachability.
Demand Score: 92
Exam Relevance Score: 88
What problem do BGP route reflectors solve in large networks?
They remove the requirement for a full iBGP mesh.
Standard iBGP rules require every BGP router in an AS to peer with every other router. In large networks this creates scalability issues because the number of sessions grows rapidly.
Route reflectors allow a hierarchical design where:
Route reflector clients peer only with the reflector
The reflector redistributes routes between clients
This significantly reduces the number of BGP sessions while maintaining route propagation.
Demand Score: 85
Exam Relevance Score: 90
What is the purpose of the BGP local preference attribute?
It determines the preferred exit point for outbound traffic within an autonomous system.
Local preference is a well-known discretionary attribute used inside an AS.
Higher values are preferred.
Operational usage:
Influence outbound path selection
Applied via routing policy
Propagated to all iBGP peers
Because it is evaluated early in the BGP decision process, it is a powerful tool for controlling how traffic exits a network.
Demand Score: 83
Exam Relevance Score: 86
Why does iBGP not advertise routes learned from other iBGP peers?
To prevent routing loops inside the autonomous system.
BGP uses a loop prevention rule: routes learned from iBGP peers are not advertised to other iBGP peers.
Without this rule, routing loops could occur because iBGP does not modify the AS_PATH attribute.
To distribute routes internally, networks use:
Route reflectors
BGP confederations
These mechanisms safely redistribute routes without forming loops.
Demand Score: 80
Exam Relevance Score: 85
What is the function of the BGP MED attribute?
It influences which entry point external neighbors use to reach a network.
MED (Multi-Exit Discriminator) is used between neighboring autonomous systems.
Lower MED values are preferred.
Typical scenario:
An AS has multiple links to another AS
MED signals which link is preferred
However, MED is not always compared across different AS paths, depending on implementation and configuration.
Demand Score: 76
Exam Relevance Score: 82
Why might a BGP session remain in the Active state?
The router cannot establish a TCP session with the neighbor.
BGP relies on TCP port 179. The Active state indicates that the router is attempting but failing to establish a TCP connection.
Common causes include:
Incorrect neighbor IP address
Connectivity issues in the IGP
Firewall blocking TCP 179
Misconfigured update-source
Verifying IP connectivity and session parameters usually resolves the issue.
Demand Score: 79
Exam Relevance Score: 87