title | description | services | author | ms.service | ms.custom | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|
Configure custom BGP communities for Azure ExpressRoute private peering |
Learn how to apply or update BGP community value for a new or an existing virtual network. |
expressroute |
duongau |
azure-expressroute |
devx-track-azurepowershell |
how-to |
09/05/2023 |
duau |
BGP communities are groupings of IP prefixes tagged with a community value. This value can be used to make routing decisions on the router's infrastructure. You can apply filters or specify routing preferences for traffic sent to your on-premises from Azure with BGP community tags. This article explains how to apply a custom BGP community value for your virtual networks using Azure PowerShell. Once configured, you can view the regional BGP community value and the custom community value of your virtual network. This value will be used for outbound traffic sent over ExpressRoute when originating from that virtual network.
-
Review the prerequisites, routing requirements, and workflows before you begin configuration.
-
You must have an active ExpressRoute circuit.
- Follow the instructions to create an ExpressRoute circuit and have the circuit enabled by your connectivity provider.
- Ensure that you have Azure private peering configured for your circuit. See the configure routing article for routing instructions.
- Ensure that Azure private peering gets configured and establishes BGP peering between your network and Microsoft for end-to-end connectivity.
[!INCLUDE updated-for-az]
[!INCLUDE expressroute-cloudshell]
-
To start the configuration, sign in to your Azure account and select the subscription that you want to use.
[!INCLUDE sign in]
-
Create a resource group to store the new virtual network.
$rg = @{ Name = 'myERRG' Location = 'WestUS' } New-AzResourceGroup @rg
-
Create a new virtual network with the
-BgpCommunity
flag to apply a BGP community value.$vnet = @{ Name = 'myVirtualNetwork' ResourceGroupName = 'myERRG' Location = 'WestUS' AddressPrefix = '10.0.0.0/16' BgpCommunity = '12076:20001' } New-AzVirtualNetwork @vnet
[!NOTE] The
12076:
is required before your custom community value. -
Retrieve your virtual network and review its properties. You'll notice a BgpCommunities section that contains a RegionalCommunity value and a VirtualNetworkCommunity value. The RegionalCommunity value is predefined based on the Azure region of the virtual network. The VirtualNetworkCommunity value should match your custom definition.
$virtualnetwork = @{ Name = 'myVirtualNetwork' ResourceGroupName = 'myERRG' } Get-AzVirtualNetwork @virtualnetwork
-
Get the virtual network you want to apply or update the BGP community value and store it to a variable.
$virtualnetwork = @{ Name = 'myVirtualNetwork' ResourceGroupName = 'myERRG' } $vnet = Get-AzVirtualNetwork @virtualnetwork
-
Update the
VirtualNetworkCommunity
value for your virtual network.$vnet.BgpCommunities = @{VirtualNetworkCommunity = '12076:20002'} $vnet | Set-AzVirtualNetwork
[!NOTE] The
12076:
is required before your custom community value. -
Retrieve your virtual network and review its updated properties. The RegionalCommunity value is predefined based on the Azure region of the virtual network; to view the regional BGP community values for private peering, see ExpressRoute routing requirements. The VirtualNetworkCommunity value should match your custom definition.
$virtualnetwork = @{ Name = 'myVirtualNetwork' ResourceGroupName = 'myERRG' } Get-AzVirtualNetwork @virtualnetwork