Understanding BGP on Palo Alto Networks Firewalls

Border Gateway Protocol (BGP) is the standard exterior gateway protocol designed to exchange routing and reachability information among autonomous systems (AS) on the Internet. Palo Alto Networks firewalls implement BGP within their Virtual Router instances (or Logical Routers in Advanced Routing mode), allowing them to participate in complex routing environments. This document covers key BGP concepts as implemented on PAN-OS.

This guide primarily uses terminology consistent with the legacy Virtual Router (VR) interface unless otherwise specified. Concepts are generally applicable to the Advanced Routing Engine (ARE) Logical Routers (LR) as well, though configuration paths might differ.

Core BGP Configuration

Peering: eBGP vs. iBGP

Peering is the process of establishing a TCP session (port 179) between two BGP routers to exchange routing information.

Route Advertisement and Filtering

Controlling which routes are learned and advertised is crucial. PAN-OS (especially in legacy VR mode) uses specific profiles and rules:

Note on Order: For incoming routes, Dampening (if configured globally) is applied first, followed by Import Rules. For outgoing routes, Export Rules determine what is sent based on routes eligible in the BGP table (after import and redistribution).

Understanding the difference between Import (filtering/modifying received routes) and Export (filtering/modifying advertised routes) is critical for exam scenarios involving BGP policy.

BGP Peer Groups

Configuring multiple BGP peers, especially those with similar characteristics (like multiple peers within the same neighboring AS or multiple iBGP peers), can become repetitive. Peer Groups simplify this process significantly.

BGP Multihop

By default, eBGP peers expect to be directly connected (sharing the same subnet), meaning the neighbor IP address should be reachable in one Layer 3 hop (TTL=1). iBGP does not have this direct connection requirement, but the TCP session still needs to establish.

Important: When using multihop, especially for iBGP peering between loopback interfaces, ensure you have underlying IGP (like OSPF) or static routes providing reachability between those loopback addresses.

BGP Attributes and Path Selection Overview

BGP uses attributes carried within Update messages to learn about network reachability and select the best path when multiple paths to the same destination exist. Understanding the key attributes and the order they are evaluated in is fundamental.

Knowing the main attributes and their preference order (Weight -> LP -> AS_PATH -> Origin -> MED -> etc.) is essential for the exam.

BGP Best Path Selection Process

When a BGP router receives multiple paths for the same network prefix, it runs a deterministic algorithm to select a single "best" path to install in its routing table and advertise to peers. The process stops as soon as one path is determined to be better than the others based on the current step.

  1. Discard paths where the N ext-Hop is inaccessible (cannot be resolved in the RIB).
  2. Prefer highest W eight (Palo Alto/Cisco specific, local significance).
  3. Prefer highest L ocal Preference (Highest is better, AS-wide).
  4. Prefer path locally O riginated (network, redistribute, aggregate).
  5. Prefer path with shortest A S_PATH length.
  6. Prefer path with lowest O rigin code (IGP < EGP < Incomplete).
  7. Prefer path with lowest M ED (Multi-Exit Discriminator) - requires comparison between paths from the same neighboring AS by default.
  8. Prefer E BGP paths over IBGP paths.
  9. Prefer path with the lowest I GP metric to the BGP next-hop router.
  10. (If ECMP is enabled and configured) Mark multiple paths as eligible for M ultipath load sharing if they are equal up to step 9.
  11. Prefer the oldest (most stable) E BGP path.
  12. Prefer path from the BGP peer with the lowest Router ID .
  13. Prefer path from the BGP peer with the lowest neighbor IP address.

Key Takeaway: Steps higher in the list are more significant. A path chosen because it has a higher Local Preference (Step 3) will win, even if another path has a shorter AS_PATH (Step 5).

Route Selection Mnemonic

Remembering the order can be tricky. Here's a mnemonic (adapt or create your own!):

N o W ay L azy O ld A nts O ften M ake E xcellent I nternet M aps, E xcept R arely I n P aris!

( N ext-Hop, W eight, L ocal Pref, O riginated Locally, A S_PATH, O rigin Code, M ED, E BGP>IBGP, I GP Metric, M ultipath(ECMP), E BGP Age, R outer ID, Neighbor IP )

BGP Path Selection Flowchart

BGP Attribute: Weight

Understanding the Impact of Setting BGP Weight

The BGP Weight attribute is a vendor-specific parameter (supported by Cisco, Palo Alto Networks, and others, but not part of the BGP standard RFCs) used to influence path selection on a single, local router . It provides a simple way to prefer one path over another *before* considering more standard BGP attributes.

In Summary: Use Weight for strong local outbound preference on a single router. Use Local Preference for consistent AS-wide outbound preference . Use MED/Prepending to influence inbound preference .

BGP Weight Attribute Concept Illustrates how BGP Weight influences local outbound path selection but is not advertised. Router A (Local) Peer B (ISP 1) Peer C (ISP 2) Destination 198.51.100.0/24 Outbound Traffic (Preferred) Alternate Path Preferred Outbound Path Alternate Path (Lower Weight) Router Destination Network BGP Weight is a local attribute influencing outbound path selection. Higher weight (e.g., 200) preferred over lower weight (e.g., 100). Weight is not advertised to peers; it affects only the local router's decisions.
Diagram illustrating BGP Weight. Router A assigns higher weight to routes from Peer C, making it the preferred outbound path. Weight is a local attribute and is not shared with peers.

BGP Attribute: Local Preference

Understanding the Impact of Setting Local Preference

Setting BGP Local Preference (LP) is the standard and most effective method used *within* an Autonomous System (AS) to control outbound path selection. It allows an administrator to define which exit point the entire AS should prefer for traffic destined for external networks.

In Summary: Set Local Preference (via Import Rules on received routes) to control how your AS exits towards external networks (Outbound). Use MED or AS Path Prepending (via Export Rules on advertised routes) to influence how others enter your network (Inbound).

BGP Attribute: MED (Multi-Exit Discriminator)

Understanding the Impact of Changing Advertised MED

Modifying the MED (Multi-Exit Discriminator) value you send in your BGP advertisements is a specific technique used for traffic engineering. It's crucial to understand which direction of traffic flow it influences.

In Summary: Advertise MED to influence how others enter your network (Inbound). Use Local Preference (on received routes) to influence how you exit your network (Outbound).

Yes, the diagram is accurate in illustrating the primary and intended use case of the BGP MED attribute, even considering its non-transitive nature.

Here's why:

  • MED's Purpose: The MED attribute is specifically designed to influence how an adjacent Autonomous System (AS) chooses between multiple entry points into your AS .
  • Non-Transitive Explained: The term "non-transitive" means that when AS 100 (the ISP Router) receives route advertisements with MED values from AS 65000 (Edge Routers R1 and R2), it uses those MED values for its own path selection process. However, when AS 100 subsequently re-advertises the chosen route (192.168.0.0/16 via R1) to its other BGP neighbors (like the network potentially hosting the External Client), it should not include the original MED value it received from AS 65000 . The MED attribute is typically "stripped" or removed before being passed to another AS.
  • What the Diagram Shows:
    • AS 65000 correctly sends different MED values to its direct neighbor, AS 100 , over its two links.
    • AS 100 correctly compares these received MED values (as they originate from the same neighboring AS, AS 65000 ) and selects the path with the lower MED (via R1) as preferable. This decision directly impacts how AS 100 sends traffic back towards AS 65000 .
    • The diagram shows AS 100 advertising the route onwards (indicated by the dotted line). Crucially, it does not explicitly state that the MED=50 is included in this *onward* advertisement. It simply depicts the necessary route propagation for reachability.
    • The diagram accurately illustrates the consequence of AS 100 's decision: traffic originating from the External Client is directed by AS 100 towards Edge Router R1, precisely because AS 100 preferred the lower MED path.

In conclusion: The diagram accurately depicts the MED attribute influencing the inbound path selection of the directly connected ISP ( AS 100 ). It correctly shows the *effect* of the MED comparison (traffic routing via R1) without incorrectly implying that the MED attribute itself is transitively passed to further, non-adjacent ASes.

Attribute Types: Transitive vs. Non-Transitive

BGP attributes carry information about routes, influencing path selection. They are categorized based on whether BGP routers are required to pass them along to other peers, especially if the router doesn't fully understand or implement the specific attribute. This is crucial for ensuring information propagates correctly across different Autonomous Systems.

Transitive Attributes

Non-Transitive Attributes

Significance: This distinction is fundamental to how BGP operates across the diverse implementations on the internet. Transitivity ensures essential path information (like AS_PATH) and widely used optional information (like Communities) can traverse ASes that might not have the latest BGP features, while non-transitivity prevents misunderstood or locally-relevant information (like MED) from propagating unnecessarily.

Common BGP Scenarios & Traffic Engineering

Scenario: Influencing Outbound Traffic (Your Egress Choice)

Goal: Control which ISP or path your internal users take to reach external destinations.

Primary Tool: Local Preference (LP) . Set via Import Rules on routes learned from peers. Higher LP is preferred.

Mechanism: By assigning a higher LP value (e.g., 200) to routes learned from your preferred ISP (ISP-A) compared to the backup ISP (ISP-B, default 100), you tell all routers within your AS to use ISP-A as the exit point when both paths are available.

What to Look For: The question asks how to make *your network* prefer one path *out* over another. It involves comparing routes *received* from different peers and applying policy as routes enter your AS.

BGP Scenario: Influencing Outbound Traffic with Local Preference

Goal: Control which ISP link or path your internal users (within your Autonomous System - AS) prefer when sending traffic out towards external destinations.

Primary Tool: BGP LocalLP) . This is the standard and most effective attribute for this purpose within your own Autonomous System (AS).

Mechanism:

  1. Local Preference is typically set using Import Rules (or route maps/policies) applied to routes as they are received from your external BGP peers (e.g., your ISPs) at your edge routers.
  2. LP is a numerical value; higher values are preferred . The default is often 100 .
  3. Assign a higher LP value (e.g., 200 ) to routes learned from your preferred ISP (ISP-A).
  4. Assign a lower or default LP value (e.g., 100 ) to routes learned from your backup ISP (ISP-B).
  5. Your edge routers advertise these routes (with their assigned LP values) to your internal BGP (iBGP) routers .
  6. All iBGP routers within your AS compare the LP for routes to the same destination and choose the path associated with the highest LP as the best path.
  7. This selected path dictates which edge router (and therefore which ISP link) is used for sending outbound traffic.

Example Scenario:

Effect on Traffic Flow:

This directly controls the OUTBOUND path selection for your entire AS. It dictates which link *your* network uses to send traffic *out*.

Setting Local Preference within your AS has NO direct impact on how external networks choose to send traffic INBOUND to your network.

What to Look For in Questions:

The question asks how to make your network prefer one path out over another. It involves comparing routes received from different external peers and applying policy as those routes enter your AS.

Visualizing the Flow:

Common BGP Scenarios & Traffic Engineering

Scenario: Influencing Inbound Traffic (Neighbor's Ingress Choice)

Goal: Control which of your links external networks use to send traffic *to* your network.

Primary Tools:

  • AS Path Prepending: Set via Export Rules towards the *less* preferred peer(s). Shorter path length is preferred globally. Make the path look longer via the link you *don't* want traffic to enter through.
  • MED (Multi-Exit Discriminator): Set via Export Rules . Lower MED is preferred. Primarily effective between you and a *single adjacent AS* with multiple links between you. Less reliable globally.

Mechanism (Prepend): You advertise your prefixes to the backup ISP (ISP-B) with your AS number repeated several times (e.g., 65000 65000 65000 ). External networks see this longer path and prefer the shorter path advertised via your primary ISP (ISP-A, e.g., 65000 ).

Mechanism (MED): Advertise your prefix to the same neighbor ISP over two links, setting MED 100 on the primary link and MED 200 on the backup link. The neighbor ISP (if they honor MED) will prefer the link where they received the lower MED.

What to Look For: The question asks how to make *other networks* prefer sending traffic *to you* via one link over another. It involves modifying attributes on routes you *advertise*. Look for keywords like "inbound," "attract," "less preferred entry point."

Common BGP Scenarios & Traffic Engineering

Scenario: Using BGP Communities for Policy

Goal: Tag routes with specific values to signal policy intentions to BGP peers (or for internal use).

Primary Tool: Community Attribute (Optional Transitive). Set via Export Rules , matched via Import/Export Rules.

Mechanism: You attach a specific community value (e.g., well-known like no-export (FFFF:FF01), no-advertise (FFFF:FF03), local-as (FFFF:FF04) or custom values like `ASN:Value`) to a route advertisement. The receiving peer, if configured to recognize that community, performs a specific action (e.g., does not advertise the route further to eBGP peers, sets a specific local preference).

What to Look For: The question mentions tagging routes, signaling actions to peers, or preventing propagation based on agreed-upon signals/tags.

BGP NO-EXPORT
The no-export community is a well-known BGP attribute that instructs routers not to advertise the associated route to external BGP (eBGP) peers. This ensures that the route remains within the local AS or confederation, preventing its propagation to other ASes.

BGP NO-ADVERTISE
The no-advertise community is a well-known BGP attribute that instructs routers not to advertise the associated route to any BGP peers, including both internal (iBGP) and external (eBGP) peers. This confines the route to the local router

BGP local-as
The local-as community is a well-known BGP attribute used within BGP confederations. It prevents the advertisement of the associated route to peers outside the local sub-AS within the confederation.

Common BGP Scenarios & Traffic Engineering

Scenario: Conditional Route Advertisement

Goal: Advertise a prefix only if a specific condition is met, typically the existence of another route.

Primary Tool: Conditional Advertisement feature within Export Rules , using a filter (Prefix List or Route Map) defined as the "Non-Suppress Filter" (legacy VR term) or "Exist Map" (ARE term) .

Mechanism: You configure an Export Rule to allow advertisement of Prefix A. Within the rule, you enable Conditional Advertisement and select a filter that matches Prefix B. The firewall checks its routing table (BGP table or RIB depending on implementation details); if Prefix B exists and matches the filter, Prefix A is advertised. If Prefix B is not present or doesn't match, Prefix A is withdrawn or not advertised.

What to Look For: The question states a requirement to advertise something *only if* something else is present (e.g., advertise my network only if I have a default route, advertise a specific prefix only if the path via another ISP is down).

Common BGP Scenarios & Traffic Engineering

Scenario: Overriding BGP for Specific Traffic/Prefixes

Goal: Force traffic for a specific destination or traffic originating from the firewall itself down a path different from the BGP best path.

Primary Tools:

  • Static Routes: With a lower Administrative Distance (AD) than BGP (eBGP=20, iBGP=200). Default static route AD is 10.
  • Policy Based Forwarding (PBF): Can override routing table for specific flows based on source/destination/port etc. (Beyond BGP attributes, acts on traffic flow).
  • Import Rules: Setting high Local Preference or Weight for *specific* learned prefixes.

Mechanism (Static): A static route with AD 10 will always be preferred over an eBGP route (AD 20) or iBGP route (AD 200) for the same prefix, useful for forcing firewall-originated traffic or specific destination traffic down a non-BGP path.

Mechanism (Import LP/Weight): Make a specific prefix learned via a normally non-preferred path more attractive using a higher LP or Weight just for that prefix via an Import Rule.

What to Look For: The question involves overriding the normal BGP decision, handling specific destinations differently, or controlling traffic *from the firewall*. Mention of Administrative Distance often points towards Static Routes. Mention of specific application/port/source traffic points towards PBF.

iBGP Scalability: Confederations vs. Route Reflectors

The iBGP split-horizon rule (routes learned from one iBGP peer are not advertised to another iBGP peer) necessitates a full mesh of connections between all iBGP speakers within an AS. This doesn't scale well in large networks. Two primary solutions exist:

Route Reflector vs Full Mesh (Placeholder)
graph TD subgraph Full_Mesh [Full Mesh (4 Routers)] R1 --- R2; R1 --- R3; R1 --- R4; R2 --- R3; R2 --- R4; R3 --- R4; end subgraph Route_Reflector [Route Reflector (RR + 3 Clients)] RR1(RR); C1(Client 1); C2(Client 2); C3(Client 3); C1 --- RR1; C2 --- RR1; C3 --- RR1; end

Route Reflectors significantly reduce the number of required iBGP sessions compared to a full mesh.

Operational Aspects

Verification (CLI Commands)

Useful CLI commands for troubleshooting and verification (execute in operational mode):

Remember to use the correct Virtual Router context if multiple VRs exist: set system setting target-vsys before running VR-specific commands, or specify the VR in some commands (check command syntax).

Interactive BGP Quiz

Test your knowledge of Palo Alto BGP Concepts. Please answer all questions before submitting.

1. What is the default Administrative Distance (AD) for routes learned via eBGP on PAN-OS?

2. Which BGP attribute is primarily used within an Autonomous System (AS) to influence the outbound path selection (egress point)?

3. To set the Local Preference attribute for routes received from an eBGP peer (like an ISP), where would you typically configure this policy on a Palo Alto firewall (legacy VR)?

4. You want to make one of your internet links (ISP-B) less preferred for INBOUND traffic compared to your primary link (ISP-A). Which BGP technique is commonly used for this?

5. Which BGP attribute is evaluated FIRST in the best path selection algorithm (after next-hop reachability) but is NOT advertised to BGP peers?

6. To make routes learned from ISP-A the preferred outbound path for your entire AS over routes learned from ISP-B, you should configure an Import Rule that applies to routes from ISP-A to set a:

7. If you want to attach a BGP community value (e.g., 'no-export') to routes that you are advertising TO a specific eBGP peer, you would configure this "set community" action within which type of rule?

8. What is the final, desired BGP peer state indicating that the peering is fully operational and route updates can be exchanged?

9. Which two mechanisms are primarily used to overcome the iBGP full-mesh requirement for scalability?

10. What is the default BGP Hold Time on Palo Alto Networks firewalls?

11. The MED (Multi-Exit Discriminator) attribute is classified as which type of BGP attribute?

12. You receive a route from your ISP tagged with `65001:666`. Your ISP documentation states this tag means the route should not be advertised outside your own AS. What BGP attribute is being used here?

13. Which CLI command would you use to see the raw routes being sent *by* your BGP neighbor *before* any of your firewall's import policies have been applied?

14. All other attributes being equal (Weight, LP, Origin etc.), how does BGP choose between two eBGP paths to the same destination?

15. You need to establish an iBGP peering between two routers within your AS using their loopback interfaces, which are several router hops apart. What BGP peer option is essential to configure?

16. You have five iBGP peers that all require the same import/export policies and timers. What is the most efficient way to configure this on the firewall?

17. True or False: The BGP Weight attribute is advertised to iBGP peers.

18. The BGP Community attribute is classified as which type?

19. If two BGP paths are completely identical through all major attributes (Weight, LP, AS_PATH, Origin, MED, EBGP/IBGP preference, IGP metric), what is typically the *next* tie-breaker used in the best path selection?

20. To advertise routes learned via OSPF into your BGP process, you need to configure: