Skip to content

Commit 274cc19

Browse files
authored
Merge pull request #242793 from halkazwini/vm-nsg-test
Virtual machines: New release: Network security group test (how-to)
2 parents 36902ed + f8c6724 commit 274cc19

File tree

7 files changed

+125
-0
lines changed

7 files changed

+125
-0
lines changed

articles/virtual-machines/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,6 +1534,8 @@
15341534
href: ../virtual-network/tutorial-filter-network-traffic-powershell.md?toc=/azure/virtual-machines/toc.json
15351535
- name: Azure CLI
15361536
href: ../virtual-network/tutorial-filter-network-traffic-cli.md?toc=/azure/virtual-machines/toc.json
1537+
- name: Network security group test
1538+
href: network-security-group-test.md
15371539
- name: Create VM - static public IP
15381540
items:
15391541
- name: Azure portal
43.7 KB
Loading
74.4 KB
Loading
43.9 KB
Loading
79.8 KB
Loading
98.2 KB
Loading
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
---
2+
title: Network security group test
3+
description: Learn how to check if a security rule is blocking traffic to or from your virtual machine (VM) using network security group test in the Azure portal.
4+
author: halkazwini
5+
ms.author: halkazwini
6+
ms.service: virtual-machines
7+
ms.topic: how-to
8+
ms.date: 07/17/2023
9+
ms.custom: template-how-to, engagement-fy23
10+
---
11+
12+
# Network security group test
13+
14+
You can use [network security groups](../virtual-network/network-security-groups-overview.md) to filter and control inbound and outbound network traffic to and from your virtual machines (VMs). You can also use [Azure Virtual Network Manager](../virtual-network-manager/overview.md) to apply admin security rules to your VMs to control network traffic.
15+
16+
In this article, you learn how to use **Network security group test** to check if a security rule is blocking traffic to or from your virtual machine by checking what security rules are applied to your VM traffic.
17+
18+
## Prerequisites
19+
20+
- An Azure account with an active subscription. If you don't have one, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
21+
22+
- Sign in to the [Azure portal](https://portal.azure.com/?WT.mc_id=A261C142F) with your Azure account.
23+
24+
- An Azure virtual machine (VM). If you don't have one, create [a Linux VM](./linux/quick-create-portal.md) or [a Windows VM](./windows/quick-create-portal.md).
25+
26+
## Test inbound connections
27+
28+
In this section, you test if RDP connections are allowed to your VM from a remote IP address.
29+
30+
1. In the search box at the top of the portal, enter *virtual machines*. Select **Virtual machines** from the search results.
31+
32+
:::image type="content" source="./media/network-security-group-test/virtual-machines-portal-search.png" alt-text="Screenshot of searching for virtual machines in the Azure portal." lightbox="./media/network-security-group-test/virtual-machines-portal-search.png":::
33+
34+
1. Select the VM that you want to test.
35+
36+
1. Under **Help**, select **Network security group test**.
37+
38+
> [!NOTE]
39+
> The virtual machine must be in running state.
40+
41+
1. Select **Inbound connections**. The following options are available for **Inbound** tests:
42+
43+
| Setting | Value |
44+
| --- | --- |
45+
| Source type | - **My IP address**: your public IP address that you're using to access the Azure portal. <br> - **Any IP address**: any source IP address. <br> - **Other IP address/CIDR**: Source IP address or address prefix. <br> - **Service tag**: Source [service tag](../virtual-network/service-tags-overview.md). |
46+
| IP address/CIDR | The IP address or address prefix that you want to use as the source. <br><br> **Note**: You see this option if you select **Other IP address/CIDR** for **Source type**. |
47+
| Service tag | The service tag that you want to use as the source. <br><br> **Note**: You see this option if you select **Service tag** for **Source type**. |
48+
| Service type | List of predefined services available for the test. <br><br> **Notes**:<br> - If you select a predefined service, the service port number and protocol are automatically selected. <br> - If you don't see the port and protocol information that you want, select **Custom**, and then enter the port number and select the protocol that you want. |
49+
| Port | VM port number. <br><br> **Note**: If you select one of the predefined services, the correct port number is automatically selected. <br>Manually enter the port number when you select **Custom** for **Service type**. |
50+
| Protocol | Connection protocol. Available options are: **Any**, **TCP**, and **UDP**. <br><br> **Note**: If you select one of the predefined services, the correct protocol used by the service is automatically selected. <br>Manually select the protocol when you select **Custom** for **Service type**. |
51+
52+
1. To test if RDP connection is allowed to the VM from a remote IP address, select the following values:
53+
54+
| Setting | Value |
55+
| --- | --- |
56+
| Source type | Select **My IP address**. |
57+
| Service type | Select **RDP**. |
58+
| Port | Leave the default of **3389**. |
59+
| Protocol | Leave the default of **TCP**. |
60+
61+
:::image type="content" source="./media/network-security-group-test/inbound-test.png" alt-text="Screenshot of inbound network security group test in the Azure portal." lightbox="./media/network-security-group-test/inbound-test.png":::
62+
63+
1. Select **Run test**.
64+
65+
After a few seconds, you see the details of the test:
66+
- If RDP connections are allowed to the VM from the remote IP address, you see **Traffic status: Allowed**.
67+
- If RDP connections are blocked, you see **Traffic status: Denied**. In the Summary section, you see the security rules that are blocking the traffic.
68+
69+
:::image type="content" source="./media/network-security-group-test/inbound-test-result.png" alt-text="Screenshot of inbound network security group test result." lightbox="./media/network-security-group-test/inbound-test-result.png":::
70+
71+
To allow the RDP connection to the VM from the remote IP address, add to the network security group a security rule that allows RDP connections from the remote IP address. This security rule must have a higher priority than the one that's blocking the traffic. For more information, see [Create, change, or delete a network security group](../virtual-network/manage-network-security-group.md).
72+
73+
## Test outbound connections
74+
75+
In this section, you test your VM can have connect to the internet.
76+
77+
1. In the search box at the top of the portal, enter *virtual machines*. Select **Virtual machines** from the search results.
78+
79+
:::image type="content" source="./media/network-security-group-test/virtual-machines-portal-search.png" alt-text="Screenshot of searching for virtual machines in the Azure portal." lightbox="./media/network-security-group-test/virtual-machines-portal-search.png":::
80+
81+
1. Select the VM you want to test.
82+
83+
1. Under **Help**, select **Network security group test**.
84+
85+
> [!NOTE]
86+
> The virtual machine must be in running state.
87+
88+
1. Select **Outbound connections**. The following options are available for **Outbound** tests:
89+
90+
| Setting | Value |
91+
| --- | --- |
92+
| Service type | List of predefined services available for the test. <br><br> **Notes**:<br> - If you select a predefined service, the service port number and protocol are automatically selected. <br> - If you don't see the port and protocol information that you want, select **Custom**, and then enter the port number and select the protocol that you want. |
93+
| Port | VM port number. <br><br> **Note**: If you select one of the predefined services, the correct port number is automatically selected. <br>Manually enter the port number when you select **Custom** for **Service type**. |
94+
| Protocol | Connection protocol. Available options are: **Any**, **TCP**, and **UDP**. <br><br> **Note**: If you select one of the predefined services, the correct protocol used by the service is automatically selected. <br>Manually select the protocol when you select **Custom** for **Service type**. |
95+
| Destination type | - **My IP address**: your public IP address that you're using to access the Azure portal. <br> - **Any IP address**: any source IP address. <br> - **Other IP address/CIDR**: Source IP address or address prefix. <br> - **Service tag**: Source [service tag](../virtual-network/service-tags-overview.md). |
96+
| IP address/CIDR | The IP address or address prefix that you want to use as the destination. <br><br> **Note**: You see this option if you select **Other IP address/CIDR** for **Source type**. |
97+
| Service tag | The service tag that you want to use as the destination. <br><br> **Note**: You see this option if you select **Service tag** for **Source type**. |
98+
99+
1. To test if the VM can connect to the internet, select the following values:
100+
101+
| Setting | Value |
102+
| --- | --- |
103+
| Service type | Select **Custom**. |
104+
| Port | Leave the default of **50000**. |
105+
| Protocol | Leave the default of **Any**. |
106+
| Destination type | Select **Any IP address**. |
107+
108+
:::image type="content" source="./media/network-security-group-test/outbound-test.png" alt-text="Screenshot of outbound network security group test in the Azure portal." lightbox="./media/network-security-group-test/outbound-test.png":::
109+
110+
1. Select **Run test**.
111+
112+
After a few seconds, you see the details of the test:
113+
- If connections to the internet are allowed from the VM, you see **Traffic status: Allowed**.
114+
- If connections to the internet are blocked, you see **Traffic status: Denied**. In the Summary section, you see the security rules that are blocking the traffic.
115+
116+
:::image type="content" source="./media/network-security-group-test/outbound-test-result.png" alt-text="Screenshot of outbound network security group test result." lightbox="./media/network-security-group-test/outbound-test-result.png":::
117+
118+
To allow internet connections from the VM, add to the network security group a security rule that allows connections to the internet service tag. This security rule must have a higher priority than the one that's blocking the traffic. For more information, see [Create, change, or delete a network security group](../virtual-network/manage-network-security-group.md).
119+
120+
## Next steps
121+
122+
- To learn how to troubleshoot VM connections, see [Troubleshoot connections with Azure Network Watcher](../network-watcher/network-watcher-connectivity-portal.md).
123+
- To learn more about network security groups, see [Network security groups overview](../virtual-network/network-security-groups-overview.md).

0 commit comments

Comments
 (0)