Skip to content

Commit fd62880

Browse files
authored
Merge pull request #57313 from ShawnJackson/firewall-hybrid-ps
QualityReviewPilot: firewall-hybrid-ps
2 parents 4a2e02d + 8072454 commit fd62880

File tree

1 file changed

+63
-63
lines changed

1 file changed

+63
-63
lines changed

articles/firewall/tutorial-hybrid-ps.md

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,45 @@
11
---
2-
title: Deploy and configure Azure Firewall in a hybrid network using Azure PowerShell
2+
title: 'Tutorial: Deploy and configure Azure Firewall in a hybrid network using Azure PowerShell'
33
description: In this tutorial, you learn how to deploy and configure Azure Firewall using the Azure portal.
44
services: firewall
55
author: vhorne
66
ms.service: firewall
77
ms.topic: tutorial
88
ms.date: 10/27/2018
99
ms.author: victorh
10-
#Customer intent: As an administrator, I want to deploy and configure Azure Firewall in a hybrid network so that I can control access from an on-premise network to an Azure VNet.
10+
#Customer intent: As an administrator, I want to control network access from an on-premises network to an Azure virtual network.
1111
---
1212
# Tutorial: Deploy and configure Azure Firewall in a hybrid network using Azure PowerShell
1313

14+
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.
15+
16+
You can use Azure Firewall to control network access in a hybrid network using rules that define allowed and denied network traffic.
17+
18+
For this tutorial, you create three virtual networks:
19+
20+
- **VNet-Hub** - the firewall is in this virtual network.
21+
- **VNet-Spoke** - the spoke virtual network represents the workload located on Azure.
22+
- **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 Express Route connection. For simplicity, this tutorial uses a VPN gateway connection, and an Azure-located virtual network is used to represent an on-premises network.
23+
24+
![Firewall in a hybrid network](media/tutorial-hybrid-ps/hybrid-network-firewall.png)
25+
1426
In this tutorial, you learn how to:
1527

1628
> [!div class="checklist"]
17-
> * Set up the network environment
29+
> * Declare the variables
30+
> * Create the firewall hub virtual network
31+
> * Create the spoke virtual network
32+
> * Create the on-premises virtual network
1833
> * Configure and deploy the firewall
34+
> * Create and connect the VPN gateways
35+
> * Peer the hub and spoke virtual networks
1936
> * Create the routes
2037
> * Create the virtual machines
2138
> * Test the firewall
2239
23-
For this tutorial, you create three VNets:
24-
- **VNet-Hub** - the firewall is in this VNet.
25-
- **VNet-Spoke** - the spoke VNet represents the workload located on Azure.
26-
- **VNet-Onprem** - The OnPrem VNet represents an on-premise network. In an actual deployment, it can be connected by either a VPN or Express Route connection. For simplicity, this tutorial uses a VPN gateway connection, and an Azure-located VNet is used to represent an on-premise network.
27-
28-
![Firewall in a hybrid network](media/tutorial-hybrid-ps/hybrid-network-firewall.png)
40+
## Prerequisites
2941

30-
## Key requirements
42+
This tutorial requires that you run PowerShell locally. You must have Azure PowerShell module version 6.12.0 or later installed. Run `Get-Module -ListAvailable AzureRM` to find the version. If you need to upgrade, see [Install Azure PowerShell module](https://docs.microsoft.com/powershell/azure/install-azurerm-ps). After you verify the PowerShell version, run `Login-AzureRmAccount` to create a connection with Azure.
3143

3244
There are three key requirements for this scenario to work correctly:
3345

@@ -40,11 +52,9 @@ See the [Create Routes](#create-routes) section in this tutorial to see how thes
4052

4153
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
4254

43-
[!INCLUDE [cloud-shell-powershell.md](../../includes/cloud-shell-powershell.md)]
44-
4555
## Declare the variables
4656

47-
The following example declares the variables using the values for this tutorial. In most cases, you should replace the values with your own. However, you can use these variables if you are running through the steps to become familiar with this type of configuration. Modify the variables if needed, then copy and paste them into your PowerShell console.
57+
The following example declares the variables using the values for this tutorial. In some cases, you might need to replace some values with your own to work in your subscription. Modify the variables if needed, then copy and paste them into your PowerShell console.
4858

4959
```azurepowershell
5060
$RG1 = "FW-Hybrid-Test"
@@ -62,15 +72,15 @@ $GWHubpipName = "VNet-hub-GW-pip"
6272
$GWIPconfNameHub = "GW-ipconf-hub"
6373
$ConnectionNameHub = "hub-to-Onprem"
6474
65-
# Variables for the spoke VNet
75+
# Variables for the spoke virtual network
6676
6777
$VnetNameSpoke = "VNet-Spoke"
6878
$SNnameSpoke = "SN-Workload"
6979
$VNetSpokePrefix = "10.6.0.0/16"
7080
$SNSpokePrefix = "10.6.0.0/24"
7181
$SNSpokeGWPrefix = "10.6.1.0/24"
7282
73-
# Variables for the OnPrem VNet
83+
# Variables for the on-premises virtual network
7484
7585
$VNetnameOnprem = "Vnet-Onprem"
7686
$SNNameOnprem = "SN-Corp"
@@ -85,70 +95,69 @@ $GWOnprempipName = "VNet-Onprem-GW-pip"
8595
$SNnameGW = "GatewaySubnet"
8696
```
8797

88-
## Create a resource group
8998

90-
Create a resource group to contain all the resources required for this tutorial:
99+
## Create the firewall hub virtual network
100+
101+
First, create the resource group to contain the resources for this tutorial:
91102

92103
```azurepowershell
93104
New-AzureRmResourceGroup -Name $RG1 -Location $Location1
94105
```
95106

96-
## Create and configure the firewall hub Vnet
97-
98-
Define the subnets to be included in the VNet:
107+
Define the subnets to be included in the virtual network:
99108

100109
```azurepowershell
101110
$FWsub = New-AzureRmVirtualNetworkSubnetConfig -Name $SNnameHub -AddressPrefix $SNHubPrefix
102111
$GWsub = New-AzureRmVirtualNetworkSubnetConfig -Name $SNnameGW -AddressPrefix $SNGWHubPrefix
103112
```
104113

105-
Now, create the firewall hub VNet:
114+
Now, create the firewall hub virtual network:
106115

107116
```azurepowershell
108117
$VNetHub = New-AzureRmVirtualNetwork -Name $VNetnameHub -ResourceGroupName $RG1 `
109118
-Location $Location1 -AddressPrefix $VNetHubPrefix -Subnet $FWsub,$GWsub
110119
```
111120

112-
Request a public IP address to be allocated to the VPN gateway you will create for your VNet. Notice that the *AllocationMethod* is **Dynamic**. You cannot specify the IP address that you want to use. It's dynamically allocated to your VPN gateway.
121+
Request a public IP address to be allocated to the VPN gateway you will create for your virtual network. Notice that the *AllocationMethod* is **Dynamic**. You cannot specify the IP address that you want to use. It's dynamically allocated to your VPN gateway.
113122

114123
```azurepowershell
115124
$gwpip1 = New-AzureRmPublicIpAddress -Name $GWHubpipName -ResourceGroupName $RG1 `
116125
-Location $Location1 -AllocationMethod Dynamic
117126
```
118127

119-
## Create and configure the spoke Vnet
128+
## Create the spoke virtual network
120129

121-
Define the subnets to be included in the spoke VNet:
130+
Define the subnets to be included in the spoke virtual network:
122131

123132
```azurepowershell
124133
$Spokesub = New-AzureRmVirtualNetworkSubnetConfig -Name $SNnameSpoke -AddressPrefix $SNSpokePrefix
125134
$GWsubSpoke = New-AzureRmVirtualNetworkSubnetConfig -Name $SNnameGW -AddressPrefix $SNSpokeGWPrefix
126135
```
127136

128-
Create the spoke VNet:
137+
Create the spoke virtual network:
129138

130139
```azurepowershell
131140
$VNetSpoke = New-AzureRmVirtualNetwork -Name $VnetNameSpoke -ResourceGroupName $RG1 `
132141
-Location $Location1 -AddressPrefix $VNetSpokePrefix -Subnet $Spokesub,$GWsubSpoke
133142
```
134143

135-
## Create and configure the OnPrem VNet
144+
## Create the on-premises virtual network
136145

137-
Define the subnets to be included in the VNet:
146+
Define the subnets to be included in the virtual network:
138147

139148
```azurepowershell
140149
$Onpremsub = New-AzureRmVirtualNetworkSubnetConfig -Name $SNNameOnprem -AddressPrefix $SNOnpremPrefix
141150
$GWOnpremsub = New-AzureRmVirtualNetworkSubnetConfig -Name $SNnameGW -AddressPrefix $SNGWOnpremPrefix
142151
```
143152

144-
Now, create the OnPrem VNet:
153+
Now, create the on-premises virtual network:
145154

146155
```azurepowershell
147156
$VNetOnprem = New-AzureRmVirtualNetwork -Name $VNetnameOnprem -ResourceGroupName $RG1 `
148157
-Location $Location1 -AddressPrefix $VNetOnpremPrefix -Subnet $Onpremsub,$GWOnpremsub
149158
```
150159

151-
Request a public IP address to be allocated to the gateway you will create for the VNet. Notice that the *AllocationMethod* is **Dynamic**. You cannot specify the IP address that you want to use. It's dynamically allocated to your gateway.
160+
Request a public IP address to be allocated to the gateway you will create for the virtual network. Notice that the *AllocationMethod* is **Dynamic**. You cannot specify the IP address that you want to use. It's dynamically allocated to your gateway.
152161

153162
```azurepowershell
154163
$gwOnprempip = New-AzureRmPublicIpAddress -Name $GWOnprempipName -ResourceGroupName $RG1 `
@@ -157,7 +166,7 @@ Request a public IP address to be allocated to the gateway you will create for t
157166

158167
## Configure and deploy the firewall
159168

160-
Now deploy the firewall into the hub VNet.
169+
Now deploy the firewall into the hub virtual network.
161170

162171
```azurepowershell
163172
# Get a Public IP for the firewall
@@ -193,9 +202,9 @@ Set-AzureRmFirewall -AzureFirewall $Azfw
193202

194203
## Create and connect the VPN gateways
195204

196-
The hub and OnPrem VNets are connected via VPN gateways.
205+
The hub and on-premises virtual networks are connected via VPN gateways.
197206

198-
### Create a VPN gateway for the hub VNet
207+
### Create a VPN gateway for the hub virtual network
199208

200209
Create the VPN gateway configuration. The VPN gateway configuration defines the subnet and the public IP address to use.
201210

@@ -206,15 +215,15 @@ Create the VPN gateway configuration. The VPN gateway configuration defines the
206215
-Subnet $subnet1 -PublicIpAddress $gwpip1
207216
```
208217

209-
Now create the VPN gateway for the hub VNet. VNet-to-VNet configurations require a RouteBased VpnType. Creating a VPN gateway can often take 45 minutes or more, depending on the selected VPN gateway SKU.
218+
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.
210219

211220
```azurepowershell
212221
New-AzureRmVirtualNetworkGateway -Name $GWHubName -ResourceGroupName $RG1 `
213222
-Location $Location1 -IpConfigurations $gwipconf1 -GatewayType Vpn `
214223
-VpnType RouteBased -GatewaySku basic
215224
```
216225

217-
### Create a VPN gateway for the OnPrem VNet
226+
### Create a VPN gateway for the on-premises virtual network
218227

219228
Create the VPN gateway configuration. The VPN gateway configuration defines the subnet and the public IP address to use.
220229

@@ -225,7 +234,7 @@ $gwipconf2 = New-AzureRmVirtualNetworkGatewayIpConfig -Name $GWIPconfNameOnprem
225234
-Subnet $subnet2 -PublicIpAddress $gwOnprempip
226235
```
227236

228-
Now create the VPN gateway for the OnPrem VNet. VNet-to-VNet configurations require a RouteBased VpnType. Creating a VPN gateway can often take 45 minutes or more, depending on the selected VPN gateway SKU.
237+
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.
229238

230239
```azurepowershell
231240
New-AzureRmVirtualNetworkGateway -Name $GWOnpremName -ResourceGroupName $RG1 `
@@ -235,7 +244,7 @@ New-AzureRmVirtualNetworkGateway -Name $GWOnpremName -ResourceGroupName $RG1 `
235244

236245
### Create the VPN connections
237246

238-
Now you can create the VPN connections between the hub and OnPrem gateways
247+
Now you can create the VPN connections between the hub and on-premises gateways
239248

240249
#### Get the VPN gateways
241250

@@ -246,14 +255,14 @@ $vnetOnpremgw = Get-AzureRmVirtualNetworkGateway -Name $GWOnpremName -ResourceGr
246255

247256
#### Create the connections
248257

249-
In this step, you create the connection from the hub VNet to the OnPrem VNet. 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.
258+
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.
250259

251260
```azurepowershell
252261
New-AzureRmVirtualNetworkGatewayConnection -Name $ConnectionNameHub -ResourceGroupName $RG1 `
253262
-VirtualNetworkGateway1 $vnetHubgw -VirtualNetworkGateway2 $vnetOnpremgw -Location $Location1 `
254263
-ConnectionType Vnet2Vnet -SharedKey 'AzureA1b2C3'
255264
```
256-
Create the OnPrem to hub VNet 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.
265+
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.
257266

258267
```azurepowershell
259268
New-AzureRmVirtualNetworkGatewayConnection -Name $ConnectionNameOnprem -ResourceGroupName $RG1 `
@@ -278,9 +287,9 @@ After the cmdlet finishes, view the values. In the following example, the connec
278287
"egressBytesTransferred": 4142431
279288
```
280289

281-
## Peer the hub and spoke VNets
290+
## Peer the hub and spoke virtual networks
282291

283-
Now peer the spoke and hub VNets.
292+
Now peer the hub and spoke virtual networks.
284293

285294
```azurepowershell
286295
# Peer hub to spoke
@@ -290,15 +299,15 @@ Add-AzureRmVirtualNetworkPeering -Name HubtoSpoke -VirtualNetwork $VNetHub -Remo
290299
Add-AzureRmVirtualNetworkPeering -Name SpoketoHub -VirtualNetwork $VNetSpoke -RemoteVirtualNetworkId $VNetHub.Id -AllowForwardedTraffic -UseRemoteGateways
291300
```
292301

293-
## Create routes
302+
## Create the routes
294303

295304
Next, create a couple routes:
296305

297306
- A route from the hub gateway subnet to the spoke subnet through the firewall IP address
298307
- A default route from the spoke subnet through the firewall IP address
299308

300309
> [!NOTE]
301-
> Azure Firewall learns your on-premise networks using BGP. This may include a default route, which will route Internet traffic back through your on-premise network. If instead you want Internet traffic to be sent directly from the firewall to the Internet, add a user-defined default route (0.0.0.0/0) on the AzureFirewallSubnet with next hop type **Internet**. Your on-premise destined traffic is still forced-tunneled through the VPN/ExpressRoute gateway using the more specific routes learned from BGP.
310+
> Azure Firewall learns your on-premises networks using BGP. This may include a default route, which routes Internet traffic back through your on-premises network. In a production deployment, you might want Internet traffic to be sent directly from the firewall to the Internet. You could add a user-defined default route (0.0.0.0/0) on the AzureFirewallSubnet with next hop type **Internet**. Your on-premises destined traffic is still forced-tunneled through the VPN/ExpressRoute gateway using the more specific routes learned from BGP.
302311
303312
```azurepowershell
304313
#Create a route table
@@ -359,11 +368,11 @@ Set-AzureRmVirtualNetwork
359368

360369
## Create virtual machines
361370

362-
Now create the spoke workload and OnPrem virtual machines, and place them in the appropriate subnets.
371+
Now create the spoke workload and on-premises virtual machines, and place them in the appropriate subnets.
363372

364373
### Create the workload virtual machine
365374

366-
Create a virtual machine in the spoke VNet, running IIS, with no public IP address, and allows pings in.
375+
Create a virtual machine in the spoke virtual network, running IIS, with no public IP address, and allows pings in.
367376
When prompted, type a user name and password for the virtual machine.
368377

369378
```azurepowershell
@@ -411,9 +420,9 @@ Set-AzureRmVMExtension `
411420
-SettingString '{"commandToExecute":"powershell New-NetFirewallRule –DisplayName “Allow ICMPv4-In” –Protocol ICMPv4"}' `
412421
-Location $Location1--->
413422

414-
### Create the OnPrem virtual machine
423+
### Create the on-premises virtual machine
415424

416-
This is a simple virtual machine that you can connect to using Remote Desktop to the public IP address. From there, you can then connect to the OnPrem server through the firewall. When prompted, type a user name and password for the virtual machine.
425+
This is a simple 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. When prompted, type a user name and password for the virtual machine.
417426

418427
```azurepowershell
419428
New-AzureRmVm `
@@ -428,29 +437,29 @@ New-AzureRmVm `
428437

429438
## Test the firewall
430439

431-
First, get and note the private IP address for **VM-spoke-01** virtual machine.
440+
First, get and then note the private IP address for **VM-spoke-01** virtual machine.
432441

433442
```azurepowershell
434443
$NIC.IpConfigurations.privateipaddress
435444
```
436445

437-
1. From the Azure portal, connect to the **VM-Onprem** virtual machine.
446+
From the Azure portal, connect to the **VM-Onprem** virtual machine.
438447
<!---2. Open a Windows PowerShell command prompt on **VM-Onprem**, and ping the private IP for **VM-spoke-01**.
439448
440449
You should get a reply.--->
441-
2. Open a web browser on **VM-Onprem**, and browse to http://\<VM-spoke-01 private IP\>
450+
Open a web browser on **VM-Onprem**, and browse to http://\<VM-spoke-01 private IP\>.
442451

443-
You should see the Internet Information Services default page.
452+
You should see the Internet Information Services default page.
444453

445-
3. From **VM-Onprem**, open a remote desktop to **VM-spoke-01** at the private IP address.
454+
From **VM-Onprem**, open a remote desktop to **VM-spoke-01** at the private IP address.
446455

447-
Your connection should succeed, and you should be able to sign in using your chosen username and password.
456+
Your connection should succeed, and you should be able to sign in using your chosen username and password.
448457

449458
So now you have verified that the firewall rules are working:
450459

451460
<!---- You can ping the server on the spoke VNet.--->
452-
- You can browse web server on the spoke VNet.
453-
- You can connect to the server on the spoke VNet using RDP.
461+
- You can browse web server on the spoke virtual network.
462+
- You can connect to the server on the spoke virtual network using RDP.
454463

455464
Next, change the firewall network rule collection action to **Deny** to verify that the firewall rules work as expected. Run the following script to change the rule collection action to **Deny**.
456465

@@ -469,15 +478,6 @@ You can keep your firewall resources for the next tutorial, or if no longer need
469478

470479
## Next steps
471480

472-
In this tutorial, you learned how to:
473-
474-
> [!div class="checklist"]
475-
> * Set up the network environment
476-
> * Configure and deploy the firewall
477-
> * Create the routes
478-
> * Create the virtual machines
479-
> * Test the firewall
480-
481481
Next, you can monitor the Azure Firewall logs.
482482

483483
> [!div class="nextstepaction"]

0 commit comments

Comments
 (0)