Skip to content

Commit d9947b3

Browse files
committed
finished cli command additions
1 parent 3c4e350 commit d9947b3

File tree

1 file changed

+164
-0
lines changed

1 file changed

+164
-0
lines changed

articles/virtual-network/tutorial-create-route-table-portal.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,66 @@ az group create \
210210
--location eastus2
211211
```
212212

213+
Create a virtual network with one subnet with [az network vnet create](/cli/azure/network/vnet).
214+
215+
```azurecli-interactive
216+
az network vnet create \
217+
--name vnet-1 \
218+
--resource-group test-rg \
219+
--address-prefix 10.0.0.0/16 \
220+
--subnet-name subnet-1 \
221+
--subnet-prefix 10.0.0.0/24
222+
```
223+
224+
Create two more subnets with [az network vnet subnet create](/cli/azure/network/vnet/subnet).
225+
226+
```azurecli-interactive
227+
# Create a bastion subnet.
228+
az network vnet subnet create \
229+
--vnet-name vnet-1 \
230+
--resource-group test-rg \
231+
--name AzureBastionSubnet \
232+
--address-prefix 10.0.1.0/24
233+
234+
# Create a private subnet.
235+
az network vnet subnet create \
236+
--vnet-name vnet-1 \
237+
--resource-group test-rg \
238+
--name subnet-private \
239+
--address-prefix 10.0.2.0/24
240+
241+
# Create a DMZ subnet.
242+
az network vnet subnet create \
243+
--vnet-name vnet-1 \
244+
--resource-group test-rg \
245+
--name subnet-dmz \
246+
--address-prefix 10.0.3.0/24
247+
```
248+
249+
### Create Azure Bastion
250+
251+
Create a public IP address for the Azure Bastion host with [az network public-ip create](/cli/azure/network/public-ip). The following example creates a public IP address named *public-ip-bastion* in the *vnet-1* virtual network.
252+
253+
```azurecli-interactive
254+
az network public-ip create \
255+
--resource-group test-rg \
256+
--name public-ip-bastion \
257+
--location eastus2 \
258+
--allocation-method Static \
259+
--sku Standard
260+
```
261+
262+
Create an Azure Bastion host with [az network bastion create](/cli/azure/network/bastion). The following example creates an Azure Bastion host named *bastion* in the *AzureBastionSubnet* subnet of the *vnet-1* virtual network. Azure Bastion is used to securely connect Azure virtual machines without exposing them to the public internet.
263+
264+
```azurecli-interactive
265+
az network bastion create \
266+
--resource-group test-rg \
267+
--name bastion \
268+
--vnet-name vnet-1 \
269+
--public-ip-address public-ip-bastion \
270+
--location eastus2
271+
```
272+
213273
---
214274

215275
## Create an NVA virtual machine
@@ -291,6 +351,35 @@ New-AzVM @vmParams
291351

292352
### [CLI](#tab/cli)
293353

354+
Create a VM to be used as the NVA in the *subnet-dmz* subnet with [az vm create](/cli/azure/vm). When you create a VM, Azure creates and assigns a network interface *vm-nvaVMNic* and a subnet-public IP address to the VM, by default. The `--public-ip-address ""` parameter instructs Azure not to create and assign a subnet-public IP address to the VM, since the VM doesn't need to be connected to from the internet.
355+
356+
```azurecli-interactive
357+
az vm create \
358+
--resource-group test-rg \
359+
--name vm-nva \
360+
--image Ubuntu2204 \
361+
--public-ip-address "" \
362+
--subnet subnet-dmz \
363+
--vnet-name vnet-1 \
364+
--admin-username azureuser \
365+
--authentication-type password
366+
```
367+
368+
The VM takes a few minutes to create. Don't continue to the next step until Azure finishes creating the VM and returns output about the VM.
369+
370+
Within the VM, the operating system, or an application running within the VM, must also be able to forward network traffic. We use the `sysctl` command to enable the Linux kernel to forward packets. To run this command without logging onto the VM, we use the [Custom Script extension](/azure/virtual-machines/extensions/custom-script-linux) [az vm extension set](/cli/azure/vm/extension):
371+
372+
```azurecli-interactive
373+
az vm extension set \
374+
--resource-group test-rg \
375+
--vm-name vm-nva \
376+
--name customScript \
377+
--publisher Microsoft.Azure.Extensions \
378+
--settings '{"commandToExecute":"sudo sysctl -w net.ipv4.ip_forward=1"}'
379+
```
380+
381+
The command might take up to a minute to execute. This change won't persist after a VM reboot, so if the NVA VM is rebooted for any reason, the script will need to be repeated.
382+
294383
---
295384

296385
## Create public and private virtual machines
@@ -443,6 +532,32 @@ The VM takes a few minutes to create. Don't continue with the next step until th
443532

444533
### [CLI](#tab/cli)
445534

535+
Create a VM in the *subnet-1* subnet with [az vm create](/cli/azure/vm). The `--no-wait` parameter enables Azure to execute the command in the background so you can continue to the next command.
536+
537+
```azurecli-interactive
538+
az vm create \
539+
--resource-group test-rg \
540+
--name vm-public \
541+
--image Ubuntu2204 \
542+
--vnet-name vnet-1 \
543+
--subnet subnet-1 \
544+
--admin-username azureuser \
545+
--authentication-type password \
546+
--no-wait
547+
```
548+
549+
Create a VM in the *subnet-private* subnet.
550+
551+
```azurecli-interactive
552+
az vm create \
553+
--resource-group test-rg \
554+
--name vm-private \
555+
--image Ubuntu2204 \
556+
--vnet-name vnet-1 \
557+
--subnet subnet-private \
558+
--admin-username azureuser \
559+
--authentication-type password
560+
```
446561
---
447562

448563
## Enable IP forwarding
@@ -491,6 +606,15 @@ Set-AzNetworkInterface -NetworkInterface $nic
491606

492607
### [CLI](#tab/cli)
493608

609+
Enable IP forwarding for the network interface of the **vm-nva** virtual machine with [az network nic update](/cli/azure/network/nic). The following example enables IP forwarding for the network interface named *vm-nvaVMNic*.
610+
611+
```azurecli-interactive
612+
az network nic update \
613+
--name vm-nvaVMNic \
614+
--resource-group test-rg \
615+
--ip-forwarding true
616+
```
617+
494618
---
495619

496620
## Enable IP forwarding in the operating system
@@ -647,6 +771,37 @@ Set-AzVirtualNetworkSubnetConfig @subnetParams | Set-AzVirtualNetwork
647771

648772
### [CLI](#tab/cli)
649773

774+
Create a route table with [az network route-table create](/cli/azure/network/route-table#az-network-route-table-create). The following example creates a route table named *route-table-public*.
775+
776+
```azurecli-interactive
777+
# Create a route table
778+
az network route-table create \
779+
--resource-group test-rg \
780+
--name route-table-public
781+
```
782+
783+
Create a route in the route table with [az network route-table route create](/cli/azure/network/route-table/route#az-network-route-table-route-create).
784+
785+
```azurecli-interactive
786+
az network route-table route create \
787+
--name to-private-subnet \
788+
--resource-group test-rg \
789+
--route-table-name route-table-public \
790+
--address-prefix 10.0.2.0/24 \
791+
--next-hop-type VirtualAppliance \
792+
--next-hop-ip-address 10.0.3.4
793+
```
794+
795+
Associate the *route-table-subnet-public* route table to the *subnet-1* subnet with [az network vnet subnet update](/cli/azure/network/vnet/subnet).
796+
797+
```azurecli-interactive
798+
az network vnet subnet update \
799+
--vnet-name vnet-1 \
800+
--name subnet-1 \
801+
--resource-group test-rg \
802+
--route-table route-table-public
803+
```
804+
650805
---
651806

652807
## Test the routing of network traffic
@@ -740,6 +895,15 @@ Remove-AzResourceGroup @rgParams -Force
740895
741896
### [CLI](#tab/cli)
742897
898+
When no longer needed, use [az group delete](/cli/azure/group) to remove the resource group and all of the resources it contains.
899+
900+
```azurecli-interactive
901+
az group delete \
902+
--name test-rg \
903+
--yes \
904+
--no-wait
905+
```
906+
743907
---
744908
745909
## Next steps

0 commit comments

Comments
 (0)