You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -105,36 +105,51 @@ A **DMZ** and **Private** subnet are needed for this tutorial. The **DMZ** subne
105
105
Create a resource group with [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup). The following example creates a resource group named *test-rg* for all resources created in this article.
Create a virtual network with [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork). The following example creates a virtual network named *vnet-1* with the address prefix *10.0.0.0/16*.
112
117
113
118
```azurepowershell-interactive
114
-
$virtualNetwork = New-AzVirtualNetwork `
115
-
-ResourceGroupName test-rg `
116
-
-Location EastUS `
117
-
-Name vnet-1 `
118
-
-AddressPrefix 10.0.0.0/16
119
+
$vnet = @{
120
+
ResourceGroupName = "test-rg"
121
+
Location = "EastUS2"
122
+
Name = "vnet-1"
123
+
AddressPrefix = "10.0.0.0/16"
124
+
}
125
+
126
+
$virtualNetwork = New-AzVirtualNetwork @vnet
119
127
```
120
128
121
129
Create three subnets by creating three subnet configurations with [New-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/new-azvirtualnetworksubnetconfig). The following example creates three subnet configurations for *Public*, *Private*, and *DMZ* subnets:
Write the subnet configurations to the virtual network with [Set-AzVirtualNetwork](/powershell/module/az.network/Set-azVirtualNetwork), which creates the subnets in the virtual network:
@@ -201,26 +216,31 @@ Network virtual appliances (NVAs) are virtual machines that help with network fu
201
216
202
217
### Create a network interface
203
218
204
-
Before creating a network interface, you have to retrieve the virtual network Id with [Get-AzVirtualNetwork](/powershell/module/az.network/get-azvirtualnetwork), then the subnet Id with [Get-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/get-azvirtualnetworksubnetconfig). Create a network interface with [New-AzNetworkInterface](/powershell/module/az.network/new-aznetworkinterface) in the *DMZ* subnet with IP forwarding enabled:
219
+
Before creating a network interface, you have to retrieve the virtual network Id with [Get-AzVirtualNetwork](/powershell/module/az.network/get-azvirtualnetwork), then the subnet Id with [Get-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/get-azvirtualnetworksubnetconfig). Create a network interface with [New-AzNetworkInterface](/powershell/module/az.network/new-aznetworkinterface) in the *DMZ* subnet:
205
220
206
221
```azurepowershell-interactive
207
222
# Retrieve the virtual network object into a variable.
Create the VM using the VM configuration with [New-AzVM](/powershell/module/az.compute/new-azvm). The following example creates a VM named *vm-nva*.
250
286
251
287
```azurepowershell-interactive
252
-
$vmNva = New-AzVM `
253
-
-ResourceGroupName test-rg `
254
-
-Location eastus2 `
255
-
-VM $vmConfig `
256
-
-AsJob
288
+
$vmNvaParams = @{
289
+
ResourceGroupName = "test-rg"
290
+
Location = "eastus2"
291
+
VM = $vmConfig
292
+
}
293
+
$vmNva = New-AzVM @vmNvaParams -AsJob
257
294
```
258
295
259
296
The `-AsJob` option creates the VM in the background, so you can continue to the next step.
@@ -365,26 +402,30 @@ The public virtual machine is used to simulate a machine in the public internet.
365
402
Create a VM in the *subnet-public* subnet with [New-AzVM](/powershell/module/az.compute/new-azvm). The following example creates a VM named *myVmPublic* in the *subnet-public* subnet of the *vnet-1* virtual network.
The VM takes a few minutes to create. Don't continue with the next step until the VM is created and Azure returns output to PowerShell.
@@ -423,6 +464,24 @@ In this section, you turn on IP forwarding for the network interface of the **vm
423
464
424
465
### [PowerShell](#tab/powershell)
425
466
467
+
Enable IP forwarding for the network interface of the **vm-nva** virtual machine with [Set-AzNetworkInterface](/powershell/module/az.network/set-aznetworkinterface). The following example enables IP forwarding for the network interface named *vm-nva313*.
468
+
469
+
```azurepowershell-interactive
470
+
$nicParams = @{
471
+
Name = "vm-nva313"
472
+
ResourceGroupName = "test-rg"
473
+
}
474
+
475
+
$nic = Get-AzNetworkInterface @nicParams
476
+
$nic.EnableIPForwarding = $true
477
+
478
+
$setNicParams = @{
479
+
InputObject = $nic
480
+
}
481
+
482
+
Set-AzNetworkInterface @setNicParams
483
+
```
484
+
426
485
### [CLI](#tab/cli)
427
486
428
487
---
@@ -510,7 +569,7 @@ In this section, create a route in the route table that you created in the previ
510
569
| Destination type| Select **IP Addresses**. |
511
570
| Destination IP addresses/CIDR ranges | Enter **10.0.2.0/24**. |
512
571
| Next hop type| Select **Virtual appliance**. |
513
-
| Next hop address | Enter **10.0.3.4**. </br>**_This is the IP address you of vm-nva you created in the earlier steps._**. |
572
+
| Next hop address | Enter **10.0.3.4**. </br>**_This is the IP address of the vm-nva you created in the earlier steps._**. |
514
573
515
574
:::image type="content" source="./media/tutorial-create-route-table-portal/add-route.png" alt-text="Screenshot of route creation in route table.":::
516
575
@@ -534,24 +593,31 @@ In this section, create a route in the route table that you created in the previ
534
593
Create a route table with [New-AzRouteTable](/powershell/module/az.network/new-azroutetable). The following example creates a route table named *route-table-public*.
Create a route by retrieving the route table object with [Get-AzRouteTable](/powershell/module/az.network/get-azroutetable), create a route with [Add-AzRouteConfig](/powershell/module/az.network/add-azrouteconfig), then write the route configuration to the route table with [Set-AzRouteTable](/powershell/module/az.network/set-azroutetable).
@@ -641,7 +707,10 @@ Test routing of network traffic from **vm-public** to **vm-private**. Test routi
641
707
When no longer needed, use [Remove-AzResourcegroup](/powershell/module/az.resources/remove-azresourcegroup) to remove the resource group and all of the resources it contains.
0 commit comments