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
Create a security rule with [az network nsg rule create](/cli/azure/network/nsg/rule). The following example creates a rule that allows traffic inbound from the internet to the *asg-web-servers* application security group over ports 80 and 443:
442
+
Create a security rule with [az network nsg rule create](/cli/azure/network/nsg/rule). The following example creates a rule that allows traffic inbound from the internet to the *asg-web* application security group over ports 80 and 443:
443
443
444
444
```azurecli-interactive
445
445
az network nsg rule create \
@@ -452,11 +452,11 @@ az network nsg rule create \
452
452
--priority 100 \
453
453
--source-address-prefix Internet \
454
454
--source-port-range "*" \
455
-
--destination-asgs "asg-web-servers" \
455
+
--destination-asgs "asg-web" \
456
456
--destination-port-range 80 443
457
457
```
458
458
459
-
The following example creates a rule that allows traffic inbound from the Internet to the *asg-mgmt-servers* application security group over port 22:
459
+
The following example creates a rule that allows traffic inbound from the Internet to the *asg-mgmt* application security group over port 22:
460
460
461
461
```azurecli-interactive
462
462
az network nsg rule create \
@@ -469,7 +469,7 @@ az network nsg rule create \
469
469
--priority 110 \
470
470
--source-address-prefix Internet \
471
471
--source-port-range "*" \
472
-
--destination-asgs "asg-mgmt-servers" \
472
+
--destination-asgs "asg-mgmt" \
473
473
--destination-port-range 22
474
474
```
475
475
@@ -667,7 +667,7 @@ The virtual machine takes a few minutes to create. Don't continue with the next
667
667
668
668
Create two VMs in the virtual network so you can validate traffic filtering in a later step.
669
669
670
-
Create a VM with [az vm create](/cli/azure/vm). The following example creates a VM that serves as a web server. The `--asgs asg-web-servers` option causes Azure to make the network interface it creates for the VM a member of the *asg-web-servers* application security group. The `--nsg ""` option is specified to prevent Azure from creating a default network security group for the network interface Azure creates when it creates the VM. The command prompts you to create a password for the VM. SSH keys aren't used in this example to facilitate the later steps in this article. In a production environment, use SSH keys for security.
670
+
Create a VM with [az vm create](/cli/azure/vm). The following example creates a VM that serves as a web server. The `--asgs asg-web` option causes Azure to make the network interface it creates for the VM a member of the *asg-web* application security group. The `--nsg ""` option is specified to prevent Azure from creating a default network security group for the network interface Azure creates when it creates the VM. The command prompts you to create a password for the VM. SSH keys aren't used in this example to facilitate the later steps in this article. In a production environment, use SSH keys for security.
671
671
672
672
```azurecli-interactive
673
673
az vm create \
@@ -697,7 +697,7 @@ The VM takes a few minutes to create. After the VM is created, output similar to
697
697
}
698
698
```
699
699
700
-
Create a VM with [az vm create](/cli/azure/vm). The following example creates a VM that serves as a management server. The `--asgs asg-mgmt-servers` option causes Azure to make the network interface it creates for the VM a member of the *asg-mgmt-servers* application security group.
700
+
Create a VM with [az vm create](/cli/azure/vm). The following example creates a VM that serves as a management server. The `--asgs asg-mgmt` option causes Azure to make the network interface it creates for the VM a member of the *asg-mgmt* application security group.
701
701
702
702
The following example creates a VM and adds a user account. The `--generate-ssh-keys` parameter causes the CLI to look for an available ssh key in `~/.ssh`. If one is found, that key is used. If not, one is generated and stored in `~/.ssh`. Finally, we deploy the latest `Ubuntu 22.04` image.
Use [az network nic update](/cli/azure/network/nic) to associate the network interface with the application security group. The following example associates the *asg-web-servers* application security group with the *vm-web-nic* network interface:
789
+
Use [az network nic update](/cli/azure/network/nic) to associate the network interface with the application security group. The following example associates the *asg-web* application security group with the *vm-web-nic* network interface:
790
790
791
791
```azurecli-interactive
792
792
# Retrieve the network interface name associated with the virtual machine
@@ -796,10 +796,10 @@ nic_name=$(az vm show --resource-group test-rg --name vm-web --query 'networkPro
796
796
az network nic update \
797
797
--resource-group test-rg \
798
798
--name $nic_name \
799
-
--application-security-groups asg-web-servers
799
+
--application-security-groups asg-web
800
800
```
801
801
802
-
Repeat the command to associate the *asg-mgmt-servers* application security group with the *vm-mgmt-nic* network interface.
802
+
Repeat the command to associate the *asg-mgmt* application security group with the *vm-mgmt-nic* network interface.
803
803
804
804
```azurecli-interactive
805
805
# Retrieve the network interface name associated with the virtual machine
@@ -809,7 +809,7 @@ nic_name=$(az vm show --resource-group test-rg --name vm-mgmt --query 'networkPr
809
809
az network nic update \
810
810
--resource-group test-rg \
811
811
--name $nic_name \
812
-
--application-security-groups asg-mgmt-servers
812
+
--application-security-groups asg-mgmt
813
813
```
814
814
815
815
---
@@ -938,15 +938,15 @@ export IP_ADDRESS=$(az vm show --show-details --resource-group test-rg --name vm
The connection succeeds because the network interface attached to the *vm-mgmt* VM is in the *asg-mgmt-servers* application security group, which allows port 22 inbound from the Internet.
941
+
The connection succeeds because the network interface attached to the *vm-mgmt* VM is in the *asg-mgmt* application security group, which allows port 22 inbound from the Internet.
942
942
943
943
Use the following command to SSH to the *vm-web* VM from the *vm-mgmt* VM:
944
944
945
945
```bash
946
946
ssh -o StrictHostKeyChecking=no azureuser@vm-web
947
947
```
948
948
949
-
The connection succeeds because a default security rule within each network security group allows traffic over all ports between all IP addresses within a virtual network. You can't SSH to the *vm-web* VM from the Internet because the security rule for the *asg-web-servers* doesn't allow port 22 inbound from the Internet.
949
+
The connection succeeds because a default security rule within each network security group allows traffic over all ports between all IP addresses within a virtual network. You can't SSH to the *vm-web* VM from the Internet because the security rule for the *asg-web* doesn't allow port 22 inbound from the Internet.
950
950
951
951
Use the following commands to install the nginx web server on the *vm-web* VM:
952
952
@@ -964,7 +964,7 @@ The *vm-web* VM is allowed outbound to the Internet to retrieve nginx because a
964
964
curl vm-web
965
965
```
966
966
967
-
Sign out of the *vm-mgmt* VM. To confirm that you can access the *vm-web* web server from outside of Azure, enter `curl <publicIpAddress>` from your own computer. The connection succeeds because the *asg-web-servers* application security group, which the network interface attached to the *vm-web* VM is in, allows port 80 inbound from the Internet.
967
+
Sign out of the *vm-mgmt* VM. To confirm that you can access the *vm-web* web server from outside of Azure, enter `curl <publicIpAddress>` from your own computer. The connection succeeds because the *asg-web* application security group, which the network interface attached to the *vm-web* VM is in, allows port 80 inbound from the Internet.
0 commit comments