|
2 | 2 | title: "Tutorial: Filter network traffic with a network security group (NSG) - Azure portal"
|
3 | 3 | titlesuffix: Azure Virtual Network
|
4 | 4 | description: In this tutorial, you learn how to filter network traffic to a subnet, with a network security group (NSG), using the Azure portal.
|
5 |
| -services: virtual-network |
6 | 5 | author: asudbring
|
7 | 6 | ms.service: azure-virtual-network
|
8 | 7 | ms.topic: tutorial
|
@@ -576,47 +575,47 @@ Add the network interface of each VM to one of the application security groups y
|
576 | 575 | Use [Get-AzNetworkInterface](/powershell/module/az.network/get-aznetworkinterface) to retrieve the network interface of the virtual machine, and then use [Get-AzApplicationSecurityGroup](/powershell/module/az.network/get-azapplicationsecuritygroup) to retrieve the application security group. Finally, use [Set-AzNetworkInterface](/powershell/module/az.network/set-aznetworkinterface) to associate the application security group with the network interface. The following example associates the _asg-web_ application security group with the _vm-web-nic_ network interface:
|
577 | 576 |
|
578 | 577 | ```azurepowershell-interactive
|
579 |
| -$params = @{ |
| 578 | +$params1 = @{ |
580 | 579 | Name = "vm-web-nic"
|
581 | 580 | ResourceGroupName = "test-rg"
|
582 | 581 | }
|
583 |
| -$nic = Get-AzNetworkInterface @params |
| 582 | +$nic = Get-AzNetworkInterface @params1 |
584 | 583 |
|
585 |
| -$params = @{ |
| 584 | +$params2 = @{ |
586 | 585 | Name = "asg-web"
|
587 | 586 | ResourceGroupName = "test-rg"
|
588 | 587 | }
|
589 |
| -$asg = Get-AzApplicationSecurityGroup @params |
| 588 | +$asg = Get-AzApplicationSecurityGroup @params2 |
590 | 589 |
|
591 | 590 | $nic.IpConfigurations[0].ApplicationSecurityGroups = @($asg)
|
592 | 591 |
|
593 |
| -$params = @{ |
| 592 | +$params3 = @{ |
594 | 593 | NetworkInterface = $nic
|
595 | 594 | }
|
596 |
| -Set-AzNetworkInterface @params |
| 595 | +Set-AzNetworkInterface @params3 |
597 | 596 | ```
|
598 | 597 |
|
599 | 598 | Repeat the command to associate the _asg-mgmt_ application security group with the _vm-mgmt-nic_ network interface.
|
600 | 599 |
|
601 | 600 | ```azurepowershell-interactive
|
602 |
| -$params = @{ |
| 601 | +$params1 = @{ |
603 | 602 | Name = "vm-mgmt-nic"
|
604 | 603 | ResourceGroupName = "test-rg"
|
605 | 604 | }
|
606 |
| -$nic = Get-AzNetworkInterface @params |
| 605 | +$nic = Get-AzNetworkInterface @params1 |
607 | 606 |
|
608 |
| -$params = @{ |
| 607 | +$params2 = @{ |
609 | 608 | Name = "asg-mgmt"
|
610 | 609 | ResourceGroupName = "test-rg"
|
611 | 610 | }
|
612 |
| -$asg = Get-AzApplicationSecurityGroup @params |
| 611 | +$asg = Get-AzApplicationSecurityGroup @params2 |
613 | 612 |
|
614 | 613 | $nic.IpConfigurations[0].ApplicationSecurityGroups = @($asg)
|
615 | 614 |
|
616 |
| -$params = @{ |
| 615 | +$params3 = @{ |
617 | 616 | NetworkInterface = $nic
|
618 | 617 | }
|
619 |
| -Set-AzNetworkInterface @params |
| 618 | +Set-AzNetworkInterface @params3 |
620 | 619 | ```
|
621 | 620 |
|
622 | 621 | ### [CLI](#tab/cli)
|
@@ -686,17 +685,15 @@ $params = @{
|
686 | 685 | Name = "public-ip-vm-mgmt"
|
687 | 686 | ResourceGroupName = "test-rg"
|
688 | 687 | }
|
689 |
| -Get-AzPublicIpAddress @params | Select IpAddress |
| 688 | +$publicIP = Get-AzPublicIpAddress @params | Select IpAddress |
690 | 689 | ```
|
691 | 690 |
|
692 |
| -Use the following command to create a remote desktop session with the _vm-mgmt_ VM from your local computer. Replace `<publicIpAddress>` with the IP address returned from the previous command. |
| 691 | +Use the following command to create a remote desktop session with the _vm-mgmt_ VM from your local computer. |
693 | 692 |
|
694 | 693 | ```
|
695 |
| -mstsc /v:<publicIpAddress> |
| 694 | +mstsc /v:$publicIP |
696 | 695 | ```
|
697 | 696 |
|
698 |
| -Open the downloaded RDP file. If prompted, select **Connect**. |
699 |
| - |
700 | 697 | Enter the user name and password you specified when creating the VM (you may need to select **More choices**, then **Use a different account**, to specify the credentials you entered when you created the VM), then select **OK**. You may receive a certificate warning during the sign-in process. Select **Yes** to proceed with the connection.
|
701 | 698 |
|
702 | 699 | The connection succeeds, because port 3389 is allowed inbound from the internet to the _asg-mgmt_ application security group that the network interface attached to the _vm-mgmt_ VM is in.
|
|
0 commit comments