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
You open a port, or create an endpoint, to a virtual machine (VM) in Azure by creating a network filter on a subnet or a VM network interface. You place these filters, which control both inbound and outbound traffic, on a network security group attached to the resource that receives the traffic.
18
18
19
+
The example in this article demonstrates how to create a network filter that uses the standard TCP port 80 (it's assumed you've already started the appropriate services and opened any OS firewall rules on the VM).
20
+
21
+
After you've created a VM that's configured to serve web requests on the standard TCP port 80, you can:
22
+
23
+
1. Create a network security group.
24
+
25
+
2. Create an inbound security rule allowing traffic and assign values to the following settings:
26
+
27
+
-**Destination port ranges**: 80
28
+
29
+
-**Source port ranges**: * (allows any source port)
30
+
31
+
-**Priority value**: Enter a value that is less than 65,500 and higher in priority than the default catch-all deny inbound rule.
32
+
33
+
3. Associate the network security group with the VM network interface or subnet.
34
+
35
+
Although this example uses a simple rule to allow HTTP traffic, you can also use network security groups and rules to create more complex network configurations.
19
36
20
37
21
38
### [CLI](#tab/cli)
@@ -28,7 +45,7 @@ To create a Network Security Group and rules you need the latest [Azure CLI](/cl
28
45
In the following examples, replace example parameter names with your own values. Example parameter names include *myResourceGroup*, *myNetworkSecurityGroup*, and *myVnet*.
29
46
30
47
31
-
## Quickly open a port for a VM
48
+
**Quickly open a port for a VM**
32
49
If you need to quickly open a port for a VM in a dev/test scenario, you can use the [az vm open-port](/cli/azure/vm) command. This command creates a Network Security Group, adds a rule, and applies it to a VM or subnet. The following example opens port *80* on the VM named *myVM* in the resource group named *myResourceGroup*.
33
50
34
51
```azurecli
@@ -38,7 +55,7 @@ az vm open-port --resource-group myResourceGroup --name myVM --port 80
38
55
For more control over the rules, such as defining a source IP address range, continue with the additional steps in this article.
39
56
40
57
41
-
## Create a Network Security Group and rules
58
+
**Create a Network Security Group and rules**
42
59
Create the network security group with [az network nsg create](/cli/azure/network/nsg). The following example creates a network security group named *myNetworkSecurityGroup* in the *eastus* location:
43
60
44
61
```azurecli
@@ -81,15 +98,9 @@ az network vnet subnet update \
81
98
```
82
99
83
100
84
-
The quick commands here allow you to get up and running with traffic flowing to your VM. Network Security Groups provide many great features and granularity for controlling access to your resources. You can read more about [creating a Network Security Group and ACL rules here](tutorial-virtual-network.md#secure-network-traffic).
85
-
86
-
For highly available web applications, you should place your VMs behind an Azure Load Balancer. The load balancer distributes traffic to VMs, with a Network Security Group that provides traffic filtering. For more information, see [How to load balance Linux virtual machines in Azure to create a highly available application](tutorial-load-balancer.md).
87
-
88
101
89
102
### [PowerShell](#tab/poweshell)
90
103
91
-
To create a Network Security Group and ACL rules you need [the latest version of Azure PowerShell installed](/powershell/azure/). You can also [perform these steps using the Azure portal](nsg-quickstart-portal.md).
92
-
93
104
Log in to your Azure account:
94
105
95
106
```powershell
@@ -203,6 +214,6 @@ Your final step is to associate your network security group with a subnet or a s
203
214
---
204
215
## Next steps
205
216
206
-
-The quick commands here allow you to get up and running with traffic flowing to your VM. Network Security Groups provide many great features and granularity for controlling access to your resources. You can read more about [creating a Network Security Group and ACL rules here](tutorial-virtual-network.md#secure-network-traffic).
217
+
The quick commands here allow you to get up and running with traffic flowing to your VM. Network Security Groups provide many great features and granularity for controlling access to your resources. For more information, see [Filter network traffic with a network security group](../virtual-network/tutorial-filter-network-traffic.md).
207
218
208
-
-For highly available web applications, you should place your VMs behind an Azure Load Balancer. The load balancer distributes traffic to VMs, with a Network Security Group that provides traffic filtering. For more information, see [How to load balance virtual machines in Azure to create a highly available application](tutorial-load-balancer.md).
219
+
For highly available web applications, you should place your VMs behind an Azure Load Balancer. The load balancer distributes traffic to VMs, with a Network Security Group that provides traffic filtering. For more information, see [Create a public load balancer to load balance VMs](../load-balancer/quickstart-load-balancer-standard-public-cli.md).
0 commit comments