2.4 BGP & Custom Route Propagation
Key Takeaways
- Azure SDN selects the active route for packet forwarding using Longest Prefix Match (LPM) as the primary criteria; when prefix lengths are identical, route precedence is strictly: User-Defined Route (UDR) > BGP routes > Default System Routes.
- Disabling BGP Route Propagation (disableBgpRoutePropagation: true / Propagate gateway routes: Disabled) on a subnet route table blocks gateway-learned routes from populating that subnet, allowing default UDRs (0.0.0.0/0 -> Firewall) to intercept on-premises traffic.
- Azure Virtual Network Gateways and Azure Route Server use default Autonomous System Number (ASN) 65515; custom private ASNs must fall within 64512-65534 (16-bit) or 4200000000-4294967294 (32-bit).
- Between dynamic routing sources with identical prefix lengths, ExpressRoute BGP routes are preferred over VPN Gateway BGP routes; AS Path prepending can be used on-premises to engineer deterministic failover paths.
BGP & Custom Route Propagation
Dynamic routing in hybrid enterprise architectures relies on Border Gateway Protocol (BGP) to automatically exchange network reachability information between on-premises datacenters, SD-WAN fabrics, and Azure Virtual Networks. Understanding how Azure evaluates routing conflicts between dynamically learned BGP prefixes, static User-Defined Routes (UDRs), and platform system routes is critical for designing predictable, resilient enterprise networks.
The Longest Prefix Match (LPM) Rule
When a packet arrives at an Azure virtual network interface, the SDN routing engine evaluates all candidate routes in the subnet's Effective Route Table. The primary and most fundamental decision criteria in IP routing is Longest Prefix Match (LPM).
+-----------------------------------------------------------------------------------------+
| Longest Prefix Match (LPM) Evaluation |
| |
| Packet Destination: 10.1.4.55 |
| |
| Candidate Routes in Effective Table: |
| 1. 10.0.0.0/8 (System Route -> None) Prefix Length: /8 |
| 2. 10.1.0.0/16 (UDR -> Virtual Appliance 10.0.1.4) Prefix Length: /16 |
| 3. 10.1.4.0/24 (BGP Route -> VirtualNetworkGateway) Prefix Length: /24 |
| 4. 0.0.0.0/0 (UDR -> Internet) Prefix Length: /0 |
| |
| >>> WINNING ROUTE: Route 3 (10.1.4.0/24) because /24 is the longest (most specific) |
+-----------------------------------------------------------------------------------------+
The LPM Principle
Core Rule: A more specific route (longer subnet mask / higher CIDR prefix length) ALWAYS wins over a less specific route, regardless of whether the route originated from a UDR, BGP advertisement, or System Route.
Route Precedence for Identical Prefixes
When multiple routing sources advertise the exact same address prefix (e.g., both a UDR and a BGP advertisement specify 10.20.0.0/16), Azure resolves the tie using strict Administrative Precedence:
+-----------------------------------------------------------------------------+
| Route Precedence Hierarchy (Identical Prefixes) |
| |
| Rank 1 (Highest): User-Defined Route (UDR) |
| v |
| Rank 2: BGP Learned Routes (ExpressRoute > VPN) |
| v |
| Rank 3 (Lowest): Default System Routes |
+-----------------------------------------------------------------------------+
Detailed Priority Order
- User-Defined Route (UDR):
- Highest administrative priority.
- Explicitly designed to allow administrators to override dynamic routing behavior.
- BGP Learned Routes:
- Routes propagated dynamically via ExpressRoute, S2S VPN, or Azure Route Server.
- Dynamic Route Sub-Precedence:
- If the identical prefix is advertised over both ExpressRoute and VPN Gateway, ExpressRoute is preferred over VPN.
- If multiple BGP paths exist across the same connection type, the route with the shortest AS Path is selected.
- Default System Routes:
- Lowest priority.
- Overridden automatically by any matching UDR or BGP route.
Disabling BGP Route Propagation (DisableGatewaySubnetRoutes)
By default, when a Route Table is created, the property Propagate gateway routes is enabled (disableBgpRoutePropagation: false). This means all BGP routes learned by the Virtual Network Gateway are automatically injected into the subnet's effective route table.
The Enterprise Firewall Bypass Problem
Consider an enterprise hub-and-spoke network with an Azure Firewall in the hub and a default UDR 0.0.0.0/0 -> 10.0.1.4 on the spoke subnet. The on-premises network advertises specific branch subnets (e.g., 172.16.50.0/24) via BGP over ExpressRoute.
+-----------------------------------------------------------------------------------------+
| Scenario A: Propagate Gateway Routes ENABLED (Firewall Bypassed) |
| |
| Effective Routes on Spoke Subnet: |
| - 0.0.0.0/0 -> UDR: Azure Firewall (10.0.1.4) |
| - 172.16.50.0/24 -> BGP: VirtualNetworkGateway (Learned from On-Premises) |
| |
| Result: Packet to 172.16.50.10 matches 172.16.50.0/24 via LPM. |
| Traffic flows DIRECTLY to Gateway, completely bypassing Azure Firewall inspection! |
+-----------------------------------------------------------------------------------------+
vs.
+-----------------------------------------------------------------------------------------+
| Scenario B: Propagate Gateway Routes DISABLED (Enforced Inspection) |
| |
| Effective Routes on Spoke Subnet: |
| - 0.0.0.0/0 -> UDR: Azure Firewall (10.0.1.4) |
| (BGP route 172.16.50.0/24 is BLOCKED from entering the subnet route table) |
| |
| Result: Packet to 172.16.50.10 matches 0.0.0.0/0. |
| Traffic is forced through Azure Firewall (10.0.1.4) for full security inspection! |
+-----------------------------------------------------------------------------------------+
Implementation
To enforce security inspection, set disableBgpRoutePropagation: true on the spoke route table. This ensures that no learned BGP routes override your summary UDRs.
// Azure Bicep: Spoke Route Table with BGP Propagation Disabled
resource spokeRouteTable 'Microsoft.Network/routeTables@2023-05-01' = {
name: 'rt-spoke-isolated'
location: 'eastus'
properties: {
disableBgpRoutePropagation: true // Blocks learned BGP routes from injecting
routes: [
{
name: 'force-all-traffic-to-firewall'
properties: {
addressPrefix: '0.0.0.0/0'
nextHopType: 'VirtualAppliance'
nextHopIpAddress: '10.0.1.4'
}
}
]
}
}
Autonomous System Numbers (ASN) & BGP Configuration
BGP uses Autonomous System Numbers (ASNs) to identify routing domains and prevent routing loops.
Azure ASN Allocations & Constraints
| ASN Classification | ASN Range / Value | Rules & Usage in Azure |
|---|---|---|
| Azure Default ASN | 65515 | Default ASN assigned to Azure Virtual Network Gateways, VPN Gateways, and Azure Route Server. |
| Supported 16-Bit Private ASNs | 64512 – 65534 | Available for customer on-premises routers and custom Azure Gateway configurations. |
| Supported 32-Bit Private ASNs | 4200000000 – 4294967294 | Fully supported for 4-byte ASN dynamic peering in modern enterprise networks. |
| Reserved / Prohibited ASNs | 65515, 65520, 65535, 8075, 12076 | Cannot be used for customer on-premises ASNs. 8075 and 12076 are Microsoft public ASNs. |
BGP Peering Addresses
- Azure VPN Gateway: Assigns private IP addresses from the
GatewaySubnetas BGP peer addresses. It also supports APIPA (Automatic Private IP Addressing) addresses in the range169.254.21.0/24to169.254.22.255/24for multi-S2S tunnels. - Azure Route Server: Establishes eBGP peering sessions with third-party NVAs using standard VNet subnet IP addresses.
BGP Communities in Azure Networking
In ExpressRoute Microsoft Peering, Microsoft advertises public IP prefixes for Azure services (Storage, SQL, Cosmos DB). To allow customers to filter routes and control traffic paths, Microsoft tags prefixes with BGP Communities:
- Regional BGP Communities:
- Format:
12076:51004(East US),12076:51005(West US),12076:52001(North Europe). - Allows on-premises routers to prefer local regional Azure paths.
- Format:
- Service BGP Communities:
- Format:
12076:5010(Azure Storage),12076:5020(Azure SQL),12076:5050(Azure Cosmos DB),12076:5250(Azure Monitor). - Allows enterprises to accept routes only for specific approved cloud services over ExpressRoute.
- Format:
Comprehensive Azure Routing Decision Matrix
| Destination IP | Candidate Route A | Candidate Route B | Candidate Route C | Winning Route | Deterministic Reason |
|---|---|---|---|---|---|
10.5.1.20 | 10.5.0.0/16 (UDR -> NVA) | 10.5.1.0/24 (BGP -> Gateway) | 0.0.0.0/0 (UDR -> Internet) | Candidate B (10.5.1.0/24) | Longest Prefix Match (/24 > /16 > /0). |
10.2.0.10 | 10.2.0.0/16 (UDR -> NVA) | 10.2.0.0/16 (BGP -> Gateway) | 10.0.0.0/8 (System -> None) | Candidate A (10.2.0.0/16 UDR) | Identical prefix: UDR takes precedence over BGP. |
172.16.1.5 | 172.16.0.0/16 (BGP ExpressRoute) | 172.16.0.0/16 (BGP VPN) | 172.16.0.0/12 (System -> None) | Candidate A (ExpressRoute) | Identical prefix: ExpressRoute BGP beats VPN BGP. |
192.168.1.50 | 0.0.0.0/0 (UDR -> NVA) | 192.168.0.0/16 (BGP Gateway) | None (BGP Propagation Disabled) | Candidate A (0.0.0.0/0 UDR) | BGP propagation disabled; BGP route excluded from table. |
A virtual machine in a spoke subnet has an effective route table containing the following active entries:
When the VM transmits an IP packet destined for 10.0.4.88, which route will Azure SDN use to forward the packet?
An enterprise deploys an Azure Firewall in a central hub VNet and links a Route Table to all spoke subnets with a default route (0.0.0.0/0 -> Azure Firewall IP). However, security auditing discovers that spoke VMs are communicating directly with on-premises branch subnets (172.16.0.0/16) over ExpressRoute without passing through the firewall. What configuration change resolves this issue?
A network engineer is establishing dynamic BGP peering between an on-premises Cisco router and an Azure Virtual Network Gateway across a Site-to-Site VPN. Which Autonomous System Number (ASN) is reserved by Microsoft Azure for internal platform routing and CANNOT be assigned to the on-premises peer router?