Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure Firewall provides SNAT capability for all outbound traffic to public IP addresses. By default, Azure Firewall doesn't use SNAT with network rules when the destination IP address is in a private IP address range per IANA RFC 1918 or shared address space per IANA RFC 6598. Application rules always use SNAT through a transparent proxy regardless of the destination IP address.
This default behavior is suitable when routing traffic directly to the Internet. However, there are scenarios where you might need to override the default SNAT behavior:
- If you enable forced tunneling, Azure Firewall SNATs Internet-bound traffic to one of the firewall's private IP addresses in AzureFirewallSubnet, hiding the source from your on-premises firewall.
- If your organization uses registered IP address ranges outside of IANA RFC 1918 or IANA RFC 6598 for private networks, Azure Firewall SNATs the traffic to one of the firewall's private IP addresses in AzureFirewallSubnet. You can configure Azure Firewall to not SNAT your public IP address range. For example, specify an individual IP address as
x.x.x.xor a range of IP addresses asx.x.x.x/24.
You can change Azure Firewall SNAT behavior in the following ways:
- To configure Azure Firewall to never SNAT traffic processed by network rules regardless of the destination IP address, use 0.0.0.0/0 as your private IP address range. With this configuration, Azure Firewall can't route traffic directly to the Internet.
- To configure the firewall to always SNAT traffic processed by network rules regardless of the destination address, use 255.255.255.255/32 as your private IP address range.
- To configure Azure Firewall to automatically learn registered and private IP address ranges at regular intervals, enable auto-learn SNAT routes. Learned address ranges are treated as internal and traffic destined to these ranges isn't SNATed.
Important
- The private address range configuration only applies to network rules. Application rules always use SNAT.
- If you want to specify your own private IP address ranges and keep the default IANA RFC 1918 address ranges, make sure your custom list still includes the IANA RFC 1918 range.
The following table shows the supported configuration methods. Firewalls associated with a firewall policy must specify the range in the policy and not use AdditionalProperties.
| Method | Classic rules | Firewall policy |
|---|---|---|
| Azure PowerShell | Supported | Not supported |
| Azure CLI | Supported | Not supported |
| ARM template | Supported | Supported |
| Azure portal | Supported | Supported |
Configure SNAT private IP address ranges
Choose your configuration method. Azure PowerShell and Azure CLI only support classic rules. To configure SNAT ranges with a firewall policy, use an ARM template or the Azure portal.
Use Azure PowerShell to specify private IP address ranges for the firewall.
Note
The firewall PrivateRange property is ignored for firewalls associated with a Firewall Policy. You must use the SNAT property in firewallPolicies as described on the ARM template tab.
New firewall
For a new firewall that uses classic rules, create the firewall by using New-AzFirewall:
$azFw = @{
Name = '<fw-name>'
ResourceGroupName = '<resourcegroup-name>'
Location = '<location>'
VirtualNetworkName = '<vnet-name>'
PublicIpName = '<public-ip-name>'
PrivateRange = @("IANAPrivateRanges", "192.168.1.0/24", "192.168.1.10")
}
New-AzFirewall @azFw
Note
- Deploying Azure Firewall by using
New-AzFirewallrequires an existing virtual network and public IP address. For a full deployment guide, see Deploy and configure Azure Firewall using Azure PowerShell. IANAPrivateRangesexpands to the current defaults on Azure Firewall while the other ranges are added to it. To keep theIANAPrivateRangesdefault in your private range specification, it must remain in yourPrivateRangespecification as shown in the example.
Existing firewall
To configure an existing firewall that uses classic rules, get the firewall by using Get-AzFirewall and update it by using Set-AzFirewall:
$azfw = Get-AzFirewall -Name '<fw-name>' -ResourceGroupName '<resourcegroup-name>'
$azfw.PrivateRange = @("IANAPrivateRanges", "192.168.1.0/24", "192.168.1.10")
Set-AzFirewall -AzureFirewall $azfw
Auto-learn SNAT routes
You can configure Azure Firewall to auto-learn both registered and private ranges every 30 minutes. These learned address ranges are internal to the network, so traffic to destinations in the learned ranges isn't SNATed. Both virtual network (VNet) deployments and secured virtual hub (vHub) deployments support auto-learn SNAT routes.
Note
- Auto-learn SNAT requires Azure Firewall to be associated with Azure Route Server.
- For VNet deployments, you must deploy Azure Route Server in the same virtual network as Azure Firewall.
- For vHub deployments, Azure Route Server is already deployed and associated by default.
- For both deployment models, you must enable auto-learn SNAT in the Azure Firewall Policy after the association is complete.
- For more information about Azure Firewall architecture options, see What are the Azure Firewall Manager architecture options?
VNet firewall
For VNet deployments, you need to deploy and associate Azure Route Server before enabling auto-learn SNAT routes.
Prerequisites:
- A subnet named RouteServerSubnet in your firewall virtual network with a size of at least /27.
- Azure Route Server deployed in the same virtual network as your firewall. For deployment steps, see Quickstart: Create and configure Route Server by using the Azure portal.
In the following examples, replace the variable names ($azureFirewallName, $rgname, $location, etc.) with your own values.
Create a new firewall with a Route Server ID by using New-AzFirewall.
# Specify the Route Server resource ID $routeServerId="/subscriptions/your_sub/resourceGroups/testRG/providers/Microsoft.Network/virtualHubs/TestRS" # Create the firewall $azureFirewall = New-AzFirewall -Name $azureFirewallName ` -ResourceGroupName $rgname ` -Location $location ` -RouteServerId $routeServerId # Verify the Route Server ID is set Get-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgnameAssociate a Route Server with an existing firewall by using Get-AzFirewall and Set-AzFirewall.
# Specify the Route Server resource ID $routeServerId="/subscriptions/your_sub/resourceGroups/testRG/providers/Microsoft.Network/virtualHubs/TestRS" # Get the firewall $azFirewall = Get-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgname # Associate the Route Server and update the firewall $azFirewall.RouteServerId = $routeServerId Set-AzFirewall -AzureFirewall $azFirewall # Verify the Route Server ID is updated Get-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgnameCreate a new firewall policy with auto-learn enabled by using New-AzFirewallPolicySnat and New-AzFirewallPolicy.
# Include AutoLearnPrivateRange to enable auto-learn $snat = New-AzFirewallPolicySnat -PrivateRange $privateRange -AutoLearnPrivateRange # Create the firewall policy with SNAT configuration $azureFirewallPolicy = New-AzFirewallPolicy -Name $azureFirewallPolicyName ` -ResourceGroupName $rgname ` -Location $location ` -Snat $snat # Verify the firewall policy Get-AzFirewallPolicy -Name $azureFirewallPolicyName -ResourceGroupName $rgnameUpdate an existing firewall policy with SNAT by using New-AzFirewallPolicySnat and Set-AzFirewallPolicy.
$snat = New-AzFirewallPolicySnat -PrivateRange $privateRange2 -AutoLearnPrivateRange # Update the firewall policy $azureFirewallPolicy.Snat = $snat Set-AzFirewallPolicy -InputObject $azureFirewallPolicy # Verify the update Get-AzFirewallPolicy -Name $azureFirewallPolicyName -ResourceGroupName $rgnameVerify the learned prefixes by using Get-AzFirewallLearnedIpPrefix.
Get-AzFirewallLearnedIpPrefix -Name $azureFirewallName -ResourceGroupName $rgname
vHub firewall
For vHub deployments, Azure Route Server is already deployed and associated by default. You only need to enable auto-learn in your firewall policy.
In the following examples, replace the variable names ($azureFirewallName, $rgname, $location, etc.) with your own values.
Create a new firewall policy with auto-learn enabled by using New-AzFirewallPolicySnat and New-AzFirewallPolicy.
# Include AutoLearnPrivateRange to enable auto-learn $snat = New-AzFirewallPolicySnat -PrivateRange $privateRange -AutoLearnPrivateRange # Create the firewall policy with SNAT configuration $azureFirewallPolicy = New-AzFirewallPolicy -Name $azureFirewallPolicyName ` -ResourceGroupName $rgname ` -Location $location ` -Snat $snat # Verify the firewall policy Get-AzFirewallPolicy -Name $azureFirewallPolicyName -ResourceGroupName $rgnameUpdate an existing firewall policy with SNAT by using New-AzFirewallPolicySnat and Set-AzFirewallPolicy.
$snat = New-AzFirewallPolicySnat -PrivateRange $privateRange2 -AutoLearnPrivateRange # Update the firewall policy $azureFirewallPolicy.Snat = $snat Set-AzFirewallPolicy -InputObject $azureFirewallPolicy # Verify the update Get-AzFirewallPolicy -Name $azureFirewallPolicyName -ResourceGroupName $rgnameGet the virtual hub by using Get-AzVirtualHub and the firewall policy by using Get-AzFirewallPolicy.
$Hub = Get-AzVirtualHub -ResourceGroupName $rgname -Name $virtualHubName $azureFirewallPolicy = Get-AzFirewallPolicy -Name $azureFirewallPolicyName -ResourceGroupName $rgnameCreate a public IP configuration by using New-AzFirewallHubPublicIpAddress and New-AzFirewallHubIpAddress.
$azureFirewallPIPs = New-AzFirewallHubPublicIpAddress -Count 1 $azureFirewallHubIPs = New-AzFirewallHubIpAddress -PublicIP $azureFirewallPIPsCreate the vHub firewall with the auto-learn policy by using New-AzFirewall.
$azureFirewall = New-AzFirewall -Name $azureFirewallName ` -ResourceGroupName $rgname ` -Location $location ` -VirtualHubId $Hub.Id ` -FirewallPolicyId $azureFirewallPolicy.Id ` -SkuName "AZFW_Hub" ` -HubIPAddress $azureFirewallHubIPs ` -SkuTier $FirewallTierVerify the learned prefixes by using Get-AzFirewallLearnedIpPrefix.
Get-AzFirewallLearnedIpPrefix -Name $azureFirewallName -ResourceGroupName $rgname