title | description | services | author | ms.service | ms.topic | ms.date | ms.author | customer intent |
---|---|---|---|---|---|---|---|---|
Tutorial: Deploy and configure Azure Firewall in a hybrid network using the Azure portal |
In this tutorial, you learn how to deploy and configure Azure Firewall using Azure portal. |
firewall |
vhorne |
firewall |
tutorial |
03/24/2020 |
victorh |
As an administrator, I want to control network access from an on-premises network to an Azure virtual network. |
When you connect your on-premises network to an Azure virtual network to create a hybrid network, the ability to control access to your Azure network resources is an important part of an overall security plan.
You can use Azure Firewall to control network access in a hybrid network using rules that define allowed and denied network traffic.
For this tutorial, you create three virtual networks:
- VNet-Hub - the firewall is in this virtual network.
- VNet-Spoke - the spoke virtual network represents the workload located on Azure.
- VNet-Onprem - The on-premises virtual network represents an on-premises network. In an actual deployment, it can be connected by either a VPN or ExpressRoute connection. For simplicity, this tutorial uses a VPN gateway connection, and an Azure-located virtual network is used to represent an on-premises network.
In this tutorial, you learn how to:
[!div class="checklist"]
- Declare the variables
- Create the firewall hub virtual network
- Create the spoke virtual network
- Create the on-premises virtual network
- Configure and deploy the firewall
- Create and connect the VPN gateways
- Peer the hub and spoke virtual networks
- Create the routes
- Create the virtual machines
- Test the firewall
If you want to use Azure PowerShell instead to complete this procedure, see Deploy and configure Azure Firewall in a hybrid network using Azure PowerShell.
A hybrid network uses the hub-and-spoke architecture model to route traffic between Azure VNets and on-premise networks. The hub-and-spoke architecture has the following requirements:
-
Set AllowGatewayTransit when peering VNet-Hub to VNet-Spoke. In a hub-and-spoke network architecture, a gateway transit allows the spoke virtual networks to share the VPN gateway in the hub, instead of deploying VPN gateways in every spoke virtual network.
Additionally, routes to the gateway-connected virtual networks or on-premises networks will automatically propagate to the routing tables for the peered virtual networks using the gateway transit. For more information, see Configure VPN gateway transit for virtual network peering.
-
Set UseRemoteGateways when you peer VNet-Spoke to VNet-Hub. If UseRemoteGateways is set and AllowGatewayTransit on remote peering is also set, the spoke virtual network uses gateways of the remote virtual network for transit.
-
To route the spoke subnet traffic through the hub firewall, you can use a User Defined route (UDR) that points to the firewall with the Virtual network gateway route propagation option disabled. The Virtual network gateway route propagation disabled option prevents route distribution to the spoke subnets. This prevents learned routes from conflicting with your UDR. If you want to keep Virtual network gateway route propagation enabled, make sure to define specific routes to the firewall to override those that are published from on-premises over BGP.
-
Configure a UDR on the hub gateway subnet that points to the firewall IP address as the next hop to the spoke networks. No UDR is required on the Azure Firewall subnet, as it learns routes from BGP.
See the Create Routes section in this tutorial to see how these routes are created.
Note
Azure Firewall must have direct Internet connectivity. If your AzureFirewallSubnet learns a default route to your on-premises network via BGP, you must override this with a 0.0.0.0/0 UDR with the NextHopType value set as Internet to maintain direct Internet connectivity.
Azure Firewall can be configured to support forced tunneling. For more information, see Azure Firewall forced tunneling.
Note
Traffic between directly peered VNets is routed directly even if a UDR points to Azure Firewall as the default gateway. To send subnet to subnet traffic to the firewall in this scenario, a UDR must contain the target subnet network prefix explicitly on both subnets.
If you don't have an Azure subscription, create a free account before you begin.
First, create the resource group to contain the resources for this tutorial:
- Sign in to the Azure portal at https://portal.azure.com.
- On the Azure portal home page, select Resource groups > Add.
- For Resource group name, type FW-Hybrid-Test.
- For Subscription, select your subscription.
- For Region, select East US. All resources that you create later must be in the same location.
- Select Review + Create.
- Select Create.
Now, create the VNet:
Note
The size of the AzureFirewallSubnet subnet is /26. For more information about the subnet size, see Azure Firewall FAQ.
- From the Azure portal home page, select Create a resource.
- Under Networking, select Virtual network.
- For Name, type VNet-hub.
- For Address space, type 10.5.0.0/16.
- For Subscription, select your subscription.
- For Resource group, select FW-Hybrid-Test.
- For Location, select East US.
- Under Subnet, for Name type AzureFirewallSubnet. The firewall will be in this subnet, and the subnet name must be AzureFirewallSubnet.
- For Address range, type 10.5.0.0/26.
- Accept the other default settings, and then select Create.
- From the Azure portal home page, select Create a resource.
- Under Networking, select Virtual network.
- For Name, type VNet-Spoke.
- For Address space, type 10.6.0.0/16.
- For Subscription, select your subscription.
- For Resource group, select FW-Hybrid-Test.
- For Location, select the same location that you used previously.
- Under Subnet, for Name type SN-Workload.
- For Address range, type 10.6.0.0/24.
- Accept the other default settings, and then select Create.
- From the Azure portal home page, select Create a resource.
- Under Networking, select Virtual network.
- For Name, type VNet-OnPrem.
- For Address space, type 192.168.0.0/16.
- For Subscription, select your subscription.
- For Resource group, select FW-Hybrid-Test.
- For Location, select the same location that you used previously.
- Under Subnet, for Name type SN-Corp.
- For Address range, type 192.168.1.0/24.
- Accept the other default settings, and then select Create.
Now create a second subnet for the gateway.
- On the VNet-Onprem page, select Subnets.
- Select +Subnet.
- For Name, type GatewaySubnet.
- For Address range (CIDR block) type 192.168.2.0/24.
- Select OK.
Now deploy the firewall into the firewall hub virtual network.
-
From the Azure portal home page, select Create a resource.
-
In the left column, select Networking, and then select Firewall.
-
On the Create a Firewall page, use the following table to configure the firewall:
Setting Value Subscription <your subscription> Resource group FW-Hybrid-Test Name AzFW01 Location Select the same location that you used previously Choose a virtual network Use existing:
VNet-hubPublic IP address Create new:
Name - fw-pip. -
Select Review + create.
-
Review the summary, and then select Create to create the firewall.
This takes a few minutes to deploy.
-
After deployment completes, go to the FW-Hybrid-Test resource group, and select the AzFW01 firewall.
-
Note the private IP address. You'll use it later when you create the default route.
First, add a network rule to allow web traffic.
- On the AzFW01 page, Select Rules.
- Select the Network rule collection tab.
- Select Add network rule collection.
- For Name, type RCNet01.
- For Priority, type 100.
- For Action, select Allow.
- Under Rules, for Name, type AllowWeb.
- For Protocol, select TCP.
- For Source type, select IP address.
- For Source, type 192.168.1.0/24.
- For Destination address, type 10.6.0.0/16
- For Destination Ports, type 80.
Now add a rule to allow RDP traffic.
On the second rule row, type the following information:
- Name, type AllowRDP.
- For Protocol, select TCP.
- For Source type, select IP address.
- For Source, type 192.168.1.0/24.
- For Destination address, type 10.6.0.0/16
- For Destination Ports, type 3389.
- Select Add.
The hub and on-premises virtual networks are connected via VPN gateways.
Now create the VPN gateway for the hub virtual network. Network-to-network configurations require a RouteBased VpnType. Creating a VPN gateway can often take 45 minutes or more, depending on the selected VPN gateway SKU.
- From the Azure portal home page, select Create a resource.
- In the search text box, type virtual network gateway and press Enter.
- Select Virtual network gateway, and select Create.
- For Name, type GW-hub.
- For Region, select the same region that you used previously.
- For Gateway type, select VPN.
- For VPN type, select Route-based.
- For SKU, select Basic.
- For Virtual network, select VNet-hub.
- For Public IP address, select Create new, and type VNet-hub-GW-pip for the name.
- Accept the remaining defaults and then select Review + create.
- Review the configuration, then select Create.
Now create the VPN gateway for the on-premises virtual network. Network-to-network configurations require a RouteBased VpnType. Creating a VPN gateway can often take 45 minutes or more, depending on the selected VPN gateway SKU.
- From the Azure portal home page, select Create a resource.
- In the search text box, type virtual network gateway and press Enter.
- Select Virtual network gateway, and select Create.
- For Name, type GW-Onprem.
- For Region, select the same region that you used previously.
- For Gateway type, select VPN.
- For VPN type, select Route-based.
- For SKU, select Basic.
- For Virtual network, select VNet-Onprem.
- For Public IP address, select Create new, and type VNet-Onprem-GW-pip for the name.
- Accept the remaining defaults and then select Review + create.
- Review the configuration, then select Create.
Now you can create the VPN connections between the hub and on-premises gateways.
In this step, you create the connection from the hub virtual network to the on-premises virtual network. You'll see a shared key referenced in the examples. You can use your own values for the shared key. The important thing is that the shared key must match for both connections. Creating a connection can take a short while to complete.
- Open the FW-Hybrid-Test resource group and select the GW-hub gateway.
- Select Connections in the left column.
- Select Add.
- The the connection name, type Hub-to-Onprem.
- Select VNet-to-VNet for Connection type.
- For the Second virtual network gateway, select GW-Onprem.
- For Shared key (PSK), type AzureA1b2C3.
- Select OK.
Create the on-premises to hub virtual network connection. This step is similar to the previous one, except you create the connection from VNet-Onprem to VNet-hub. Make sure the shared keys match. The connection will be established after a few minutes.
- Open the FW-Hybrid-Test resource group and select the GW-Onprem gateway.
- Select Connections in the left column.
- Select Add.
- The the connection name, type Onprem-to-Hub.
- Select VNet-to-VNet for Connection type.
- For the Second virtual network gateway, select GW-hub.
- For Shared key (PSK), type AzureA1b2C3.
- Select OK.
After about five minutes or so, the status of both connections should be Connected.
Now peer the hub and spoke virtual networks.
- Open the FW-Hybrid-Test resource group and select the VNet-hub virtual network.
- In the left column, select Peerings.
- Select Add.
- For Name, type HubtoSpoke.
- For the Virtual network, select VNet-spoke
- For the name of the peering from VNetSpoke to VNet-hub, type SpoketoHub.
- Select Allow gateway transit.
- Select OK.
You'll need to enable the Allow forwarded traffic on the SpoketoHub peering.
- Open the FW-Hybrid-Test resource group and select the VNet-Spoke virtual network.
- In the left column, select Peerings.
- Select the SpoketoHub peering.
- Under Allow forwarded traffic from VNet-hub to VNet-Spoke, select Enabled.
- Select Save.
Next, create a couple routes:
- A route from the hub gateway subnet to the spoke subnet through the firewall IP address
- A default route from the spoke subnet through the firewall IP address
- From the Azure portal home page, select Create a resource.
- In the search text box, type route table and press Enter.
- Select Route table.
- Select Create.
- For the name, type UDR-Hub-Spoke.
- Select the FW-Hybrid-Test for the resource group.
- For Location, select the same location that you used previously.
- Select Create.
- After the route table is created, select it to open the route table page.
- Select Routes in the left column.
- Select Add.
- For the route name, type ToSpoke.
- For the address prefix, type 10.6.0.0/16.
- For next hop type, select Virtual appliance.
- For next hop address, type the firewall's private IP address that you noted earlier.
- Select OK.
Now associate the route to the subnet.
- On the UDR-Hub-Spoke - Routes page, select Subnets.
- Select Associate.
- Select Choose a virtual network.
- Select VNet-hub.
- Select GatewaySubnet.
- Select OK.
Now create the default route from the spoke subnet.
- From the Azure portal home page, select Create a resource.
- In the search text box, type route table and press Enter.
- Select Route table.
- Select Create.
- For the name, type UDR-DG.
- Select the FW-Hybrid-Test for the resource group.
- For Location, select the same location that you used previously.
- For Virtual network gateway route propagation, select Disabled.
- Select Create.
- After the route table is created, select it to open the route table page.
- Select Routes in the left column.
- Select Add.
- For the route name, type ToHub.
- For the address prefix, type 0.0.0.0/0.
- For next hop type, select Virtual appliance.
- For next hop address, type the firewall's private IP address that you noted earlier.
- Select OK.
Now associate the route to the subnet.
- On the UDR-DG - Routes page, select Subnets.
- Select Associate.
- Select Choose a virtual network.
- Select VNet-spoke.
- Select SN-Workload.
- Select OK.
Now create the spoke workload and on-premises virtual machines, and place them in the appropriate subnets.
Create a virtual machine in the spoke virtual network, running IIS, with no public IP address.
- From the Azure portal home page, select Create a resource.
- Under Popular, select Windows Server 2016 Datacenter.
- Enter these values for the virtual machine:
- Resource group - Select FW-Hybrid-Test.
- Virtual machine name: VM-Spoke-01.
- Region - Same region that you're used previously.
- User name: azureuser.
- Password: Azure123456!
- Select Next:Disks.
- Accept the defaults and select Next: Networking.
- Select VNet-Spoke for the virtual network and the subnet is SN-Workload.
- For Public IP, select None.
- For Public inbound ports, select Allow selected ports, and then select HTTP (80), and RDP (3389)
- Select Next:Management.
- For Boot diagnostics, Select Off.
- Select Review+Create, review the settings on the summary page, and then select Create.
-
From the Azure portal, open the Cloud Shell and make sure that it's set to PowerShell.
-
Run the following command to install IIS on the virtual machine and change the location if necessary:
Set-AzVMExtension ` -ResourceGroupName FW-Hybrid-Test ` -ExtensionName IIS ` -VMName VM-Spoke-01 ` -Publisher Microsoft.Compute ` -ExtensionType CustomScriptExtension ` -TypeHandlerVersion 1.4 ` -SettingString '{"commandToExecute":"powershell Add-WindowsFeature Web-Server; powershell Add-Content -Path \"C:\\inetpub\\wwwroot\\Default.htm\" -Value $($env:computername)"}' ` -Location EastUS
This is a virtual machine that you use to connect using Remote Desktop to the public IP address. From there, you then connect to the on-premises server through the firewall.
- From the Azure portal home page, select Create a resource.
- Under Popular, select Windows Server 2016 Datacenter.
- Enter these values for the virtual machine:
- Resource group - Select existing, and then select FW-Hybrid-Test.
- Virtual machine name - VM-Onprem.
- Region - Same region that you're used previously.
- User name: azureuser.
- Password: Azure123456!.
- Select Next:Disks.
- Accept the defaults and select Next:Networking.
- Select VNet-Onprem for virtual network and the subnet is SN-Corp.
- For Public inbound ports, select Allow selected ports, and then select RDP (3389)
- Select Next:Management.
- For Boot diagnostics, Select Off.
- Select Review+Create, review the settings on the summary page, and then select Create.
-
First, note the private IP address for VM-spoke-01 virtual machine.
-
From the Azure portal, connect to the VM-Onprem virtual machine.
-
Open a web browser on VM-Onprem, and browse to http://<VM-spoke-01 private IP>.
-
From the VM-Onprem virtual machine, open a remote desktop to VM-spoke-01 at the private IP address.
Your connection should succeed, and you should be able to sign in.
So now you've verified that the firewall rules are working:
- You can browse web server on the spoke virtual network.
- You can connect to the server on the spoke virtual network using RDP.
Next, change the firewall network rule collection action to Deny to verify that the firewall rules work as expected.
- Select the AzFW01 firewall.
- Select Rules.
- Select the Network rule collection tab and select the RCNet01 rule collection.
- For Action, select Deny.
- Select Save.
Close any existing remote desktops before testing the changed rules. Now run the tests again. They should all fail this time.
You can keep your firewall resources for the next tutorial, or if no longer needed, delete the FW-Hybrid-Test resource group to delete all firewall-related resources.
Next, you can monitor the Azure Firewall logs.
[!div class="nextstepaction"] Tutorial: Monitor Azure Firewall logs