Border Gateway Protocol (BGP) is the standardized exterior gateway protocol designed to exchange routing and reachability information among Autonomous Systems (ASes) on the internet. It is a path vector protocol, meaning it makes routing decisions based on paths, network policies, and/or rule-sets configured by a network administrator. BGP uses TCP as its transport protocol on port 179.
An Autonomous System is a collection of IP routing prefixes under the control of one or more network operators that presents a common, clearly defined routing policy to the internet. Palo Alto Networks firewalls participating in BGP must be configured with AS-specific parameters.
PAN-OS Path:
Network > Virtual Routers > (select VR) > BGP > Basic
PAN-OS Path:
Network > Virtual Routers > (select VR) > BGP > Basic
PAN-OS Path:
Network > Virtual Routers > (select VR) > BGP > Peer Group > (select Peer Group) > Peer > Peer AS
PAN-OS Path:
Network > Virtual Routers > (select VR) > BGP > Peer Group > (select Peer Group) > Connection Options (for eBGP type peer groups)
Diagram: Enforce First AS Behavior
Diagram: eBGP and iBGP Peers
BGP peers transition through several states to establish a session. Understanding these states is crucial for troubleshooting.
Diagram: BGP Peer States
BGP uses four main message types for communication over TCP port 179. A fifth type, ROUTE-REFRESH, is also common.
All BGP messages share a common 19-byte header, which includes Marker, Length, and Type fields.
Route redistribution is the process of taking routes learned through one routing protocol (or static/connected routes) and advertising them into another routing protocol. In PAN-OS, this is primarily managed through Redistribution Profiles and Import/Export rules within the BGP configuration.
PAN-OS Path:
Network > Virtual Routers > (select VR) > Redistribution Profiles
PAN-OS Path:
Network > Virtual Routers > (select VR) > BGP > Import
PAN-OS Path:
Network > Virtual Routers > (select VR) > BGP > Export
Example: Applying an AS Path filter in an Export rule.
Diagram: BGP Route Redistribution and Filtering Flow
BGP uses path attributes to describe routes. The BGP best path selection algorithm uses these attributes in a specific order to determine the single best path to a destination when multiple paths exist.
IGP (i)
: Originated via a
network
command in BGP. Most preferred.
EGP (e)
: Originated from an Exterior Gateway Protocol (historic, now generally means learned from another BGP speaker in a different AS).
Incomplete (?)
: Originated from redistribution of static or other routing protocols into BGP. Least preferred.
AS:NN
.
NO_EXPORT
: Do not advertise this route to eBGP peers (stays within AS or confederation).
NO_ADVERTISE
: Do not advertise this route to any BGP peer (eBGP or iBGP).
LOCAL_AS
(or
NO_EXPORT_SUBCONFED
): Do not advertise outside the local AS, not even to other sub-ASes in a BGP confederation.
Palo Alto Networks firewalls follow this sequence to select the best BGP route (if a step results in a single best path, subsequent steps are not evaluated):
bgp bestpath med missing-as-worst
or
always-compare-med
is configured).
The order of these steps is critical for understanding and troubleshooting BGP path selection. Refer to the official Palo Alto Networks documentation for the most precise details.
In iBGP, all peers within an AS must be fully meshed to avoid routing loops due to the iBGP split-horizon rule (routes learned from an iBGP peer are not advertised to other iBGP peers). As the number of routers in an AS grows, a full mesh becomes unscalable (n*(n-1)/2 sessions). Route Reflectors solve this scalability issue.
PAN-OS Path:
Network > Virtual Routers > (select VR) > BGP > Peer Group > (select Peer Group of type iBGP) > Peer > Route Reflector Client (checkbox)
Diagram: iBGP Full Mesh vs. Route Reflector Design
Administrative Distance is used by a router to select the best path when it learns about the same destination prefix from multiple routing protocols. The route with the lower AD is preferred. AD is locally significant and not advertised.
Lower administrative distance values are preferred. For example, if a firewall learns a route to 10.1.1.0/24 via OSPF (AD 110 or 30) and also via eBGP (AD 20), it will prefer the eBGP route in its main IP routing table, assuming all other factors for that specific protocol are met.
PAN-OS Path for filters:
Network > Virtual Routers > (select VR) > BGP > Import/Export > Add Rule > Match tab
Max Prefixes
option in Peer configuration). This helps prevent routing table overload if a peer accidentally or maliciously advertises a large number of routes (e.g., the full internet table). You can configure actions like warning or session restart when the limit is exceeded.
PAN-OS Path:
Network > Virtual Routers > (select VR) > BGP > Peer Group > (select Peer Group) > Peer > Connection Options > Max Prefixes
PAN-OS Path:
Network > Virtual Routers > (select VR) > BGP > Basic > Install Route
PAN-OS Path:
Network > Virtual Routers > (select VR) > BGP > Basic > Reject Default Route
Effective BGP troubleshooting involves checking peer status, routes, logs, and BGP-specific statistics.
show routing protocol bgp summary
(Provides an overview of peer states, uptime, received prefixes)
show routing protocol bgp peer
(Shows detailed status for each peer, including state, options, and counters)
show routing protocol bgp group
show routing protocol bgp loc-rib
(Shows routes received from peers before import policies are applied)
show routing protocol bgp rib
or
show routing protocol bgp rib-in
(Shows routes in the BGP table after import policies)
show routing protocol bgp rib-out
(Shows routes being advertised to peers after export policies)
show routing protocol bgp rib-in prefix
show routing route
(Verifies if BGP routes are installed in the FIB)
show routing route prefix
show config running | match bgp
(Displays running configuration related to BGP)
ping source
host
and
telnet host
port 179
less mp-log routed.log
or
tail follow yes mp-log routed.log
debug routing pcap bgp on
(Captures BGP messages for troubleshooting peering issues. Use
debug routing pcap off
to stop)
Be cautious with debug commands in a production environment as they can consume resources.
clear routing protocol bgp peer
soft [in|out]
(Soft reset re-sends/processes updates without tearing down TCP. No
soft
keyword does a hard reset.)
Network > Virtual Routers > (select VR) > More Runtime Stats
. This section provides a wealth of information:
Monitor > Logs > System
. Filter for BGP-related messages (e.g., `( subtype eq bgp )`). This can show errors in peer establishment or policy application.
Monitor > Logs > Traffic
. Ensure security policies allow TCP port 179 between BGP peers. If BGP packets are dropped by policy, it will be logged here.