|
1 | 1 | ---
|
2 |
| -title: Configure private IP addresses for VMs - Azure portal |
3 |
| -description: Learn how to configure private IP addresses for virtual machines using the Azure portal. |
4 |
| -services: virtual-network |
5 |
| -documentationcenter: na |
6 |
| -author: KumudD |
7 |
| -manager: twooley |
8 |
| - |
9 |
| -tags: azure-resource-manager |
10 |
| - |
11 |
| -ms.assetid: 11245645-357d-4358-9a14-dd78e367b494 |
| 2 | +title: Create a VM with a static private IP address - Azure portal |
| 3 | +description: Learn how to create a virtual machine with a static private IP address using the Azure portal. |
| 4 | +author: asudbring |
| 5 | +ms.author: allensu |
12 | 6 | ms.service: virtual-network
|
13 | 7 | ms.subservice: ip-services
|
14 |
| -ms.devlang: na |
15 | 8 | ms.topic: how-to
|
16 |
| -ms.tgt_pltfrm: na |
17 |
| -ms.workload: infrastructure-services |
18 |
| -ms.date: 02/07/2020 |
19 |
| -ms.author: kumud |
20 |
| - |
| 9 | +ms.date: 10/01/2021 |
| 10 | +ms.custom: template-how-to |
21 | 11 | ---
|
22 |
| -# Configure a private IP address for a VM using the Azure portal |
23 | 12 |
|
24 |
| -[!INCLUDE [virtual-networks-static-private-ip-intro-include](../../../includes/virtual-networks-static-private-ip-intro-include.md)] |
| 13 | +# Create a virtual machine with a static private IP address using the Azure portal |
| 14 | + |
| 15 | +A virtual machine (VM) is automatically assigned a private IP address from a range that you specify, based on the subnet in which the VM is deployed. The VM retains the address until the VM is deleted. Azure dynamically assigns the next available private IP address from the subnet you create a VM in. If you want a specific IP address from the subnet assigned to the VM, assign a static IP address. |
25 | 16 |
|
26 |
| -[!INCLUDE [virtual-networks-static-ip-scenario-include](../../../includes/virtual-networks-static-ip-scenario-include.md)] |
| 17 | +## Prerequisites |
27 | 18 |
|
28 |
| -The following sample steps expect a simple environment to already be created. If you want to run the steps as they're displayed in this document, first [create a virtual network](../../virtual-network/quick-create-portal.md#create-a-virtual-network). However, in step 3, use these values instead: |
| 19 | +- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). |
29 | 20 |
|
30 |
| -| Setting | Value | |
31 |
| -| ------- | ----- | |
32 |
| -| Name | *TestVNet* | |
33 |
| -| Address space | *192.168.0.0/16* | |
34 |
| -| Resource group | **TestRG** (if necessary, select **Create new** to create it) | |
35 |
| -| Subnet - Name | *FrontEnd* | |
36 |
| -| Subnet - Address range | *192.168.1.0/24* | |
| 21 | +## Create virtual machine |
37 | 22 |
|
38 |
| -## Create a VM for testing static private IP addresses |
39 |
| -When you create a VM in Resource Manager deployment mode, you can't set a static private IP address using the Azure portal. Instead, you create the VM first. Then you can set its private IP to be static. |
| 23 | +An Azure virtual machine can have a static or dynamic private IP address. Use the following steps to create a virtual machine, virtual network, and subnet. |
40 | 24 |
|
41 |
| -To create a VM named *DNS01* in the *FrontEnd* subnet of a virtual network named *TestVNet*, follow these steps: |
| 25 | +1. Sign in to the [Azure portal](https://portal.azure.com). |
42 | 26 |
|
43 |
| -1. From the [Azure portal](https://portal.azure.com) menu, select **Create a resource**. |
| 27 | +2. In the search box at the top of the portal, enter **Virtual machine**. Select **Virtual machines** in the search results. |
44 | 28 |
|
45 |
| -  |
46 |
| -2. Select **Compute** > **Virtual machine**. |
| 29 | +3. Select **+ Create**, then **+ Virtual machine** in **Virtual machines**. |
47 | 30 |
|
48 |
| -  |
49 |
| -3. In **Basics**, specify values for items as described in the following table. Then select **Next : Disks** and then **Next : Networking**. |
| 31 | +4. In **Create a virtual machine**, enter or select the following information: |
50 | 32 |
|
51 |
| - | Item | Value | |
52 |
| - | --- | --- | |
53 |
| - | **Subscription** | Your current subscription | |
54 |
| - | **Resource group** | **TestRG** (select from dropdown list) | |
55 |
| - | **Virtual machine name** | *DNS01* | |
56 |
| - | **Region** | **(US) East US** | |
57 |
| - | **Image** | **Windows Server 2019 Datacenter** | |
58 |
| - | **Size** | **VM Size** of **B1ls**, **Offering** of **Standard** | |
59 |
| - | **Username** | The user name of your administrator account | |
60 |
| - | **Password** | The password for your administrator account's user name | |
61 |
| - | **Confirm password** | The password again | |
| 33 | + | Setting | Value | |
| 34 | + | ------- | ----- | |
| 35 | + | **Project details** | | |
| 36 | + | Subscription | Select your subscription. | |
| 37 | + | Resource group | Select **Create new**. </br> Enter **myResourceGroup** in **Name**. </br> Select **OK**. | |
| 38 | + | **Instance details** | | |
| 39 | + | Virtual machine name | Enter **myVM**. | |
| 40 | + | Region | Select **(US) East US 2**. | |
| 41 | + | Availability options | Select **No infrastructure redundancy required**. | |
| 42 | + | Image | Select **Windows Server 2019 Datacenter - Gen2**. | |
| 43 | + | Azure Spot instance | Leave unchecked. | |
| 44 | + | Size | Select a size. | |
| 45 | + | **Administrator account** | | |
| 46 | + | Username | Enter a username. | |
| 47 | + | Password | Enter a password. | |
| 48 | + | Confirm password | Re-enter password. | |
| 49 | + | Public inbound ports | Select **Allow selected ports**. | |
| 50 | + | Select inbound ports | Select **RDP (3389)** | |
62 | 51 |
|
63 |
| -  |
64 |
| -4. In **Networking**, specify values for items as described in the following table, and then select **Next**. |
| 52 | + :::image type="content" source="./media/virtual-networks-static-private-ip-arm-pportal/create-vm.png" alt-text="Screenshot of create virtual machine."::: |
65 | 53 |
|
66 |
| - | Item | Value | |
67 |
| - | --- | --- | |
68 |
| - | **Virtual network** | **TestVNet** | |
69 |
| - | **Subnet** | **FrontEnd** | |
| 54 | + > [!WARNING] |
| 55 | + > Portal 3389 is selected, to enable remote access to the Windows Server virtual machine from the internet. Opening port 3389 to the internet is not recommended to manage production workloads. </br> For secure access to Azure virtual machines, see **[What is Azure Bastion?](../../bastion/bastion-overview.md)** |
70 | 56 |
|
71 |
| -  |
72 |
| -5. In **Management**, under **Diagnostics storage account**, choose **vnetstorage**. If that storage account doesn't appear in the list, select **Create new**, specify a **Name** of *vnetstorage*, and select **OK**. Finally, select **Review + create**. |
| 57 | +3. Select the **Networking** tab, or select **Next: Disks**, then **Next: Networking**. |
| 58 | + |
| 59 | +4. In the Networking tab, select or enter: |
73 | 60 |
|
74 |
| -  |
75 |
| -6. In **Review + create**, review the overview information, and then select **Create**. |
| 61 | + | Setting | Value | |
| 62 | + |-|-| |
| 63 | + | **Network interface** | | |
| 64 | + | Virtual network | Accept the default network name. | |
| 65 | + | Subnet | Accept the default subnet configuration. | |
| 66 | + | Public IP | Accept the default public IP configuration. | |
| 67 | + | NIC network security group | Select **Basic** | |
| 68 | + | Public inbound ports | Select **Allow selected ports**. | |
| 69 | + | Select inbound ports | Select **RDP (3389)** | |
76 | 70 |
|
77 |
| -  |
| 71 | +5. Select **Review + create**. |
| 72 | + |
| 73 | +6. Review the settings, and then select **Create**. |
78 | 74 |
|
79 |
| -The following message appears once the VM is created. |
| 75 | +[!INCLUDE [ephemeral-ip-note.md](../../../includes/ephemeral-ip-note.md)] |
80 | 76 |
|
81 |
| - |
| 77 | +## Change private IP address to static |
82 | 78 |
|
83 |
| -## Retrieve private IP address information for a VM |
84 |
| -To view the private IP address information for your new VM: |
| 79 | +In this section, you'll change the private IP address from **dynamic** to **static** for the virtual machine you created previously. |
85 | 80 |
|
86 |
| -1. Go to the [Azure portal](https://portal.azure.com) to find your VM. Search for and select **Virtual machines**. |
| 81 | +1. In the search box at the top of the portal, enter **Virtual machine**. Select **Virtual machines** in the search results. |
87 | 82 |
|
88 |
| -  |
| 83 | +2. In **Virtual machines**, select **myVM**. |
89 | 84 |
|
90 |
| -2. Select the name of your new VM (**DNS01**). |
| 85 | +3. Select **Networking** in **Settings** in **myVM**. |
91 | 86 |
|
92 |
| -  |
| 87 | +4. In **Networking**, select the name of the network interface next to **Network interface**. In this example the name of the NIC is **myvm472**. |
93 | 88 |
|
94 |
| -3. Choose **Networking**, and select the sole network interface listed. |
| 89 | + :::image type="content" source="./media/virtual-networks-static-private-ip-arm-pportal/select-nic.png" alt-text="Screenshot of select network interface."::: |
95 | 90 |
|
96 |
| -  |
| 91 | +5. In the network interface properties, select **IP configurations** in **Settings**. |
97 | 92 |
|
98 |
| -4. Choose **IP configurations**, and select the IP configuration listed in the table. |
| 93 | +6. Select **ipconfig1** in the **IP configurations** page. |
99 | 94 |
|
100 |
| -  |
| 95 | + :::image type="content" source="./media/virtual-networks-static-private-ip-arm-pportal/select-ip-configuration.png" alt-text="Screenshot of select ip configuration."::: |
101 | 96 |
|
102 |
| -5. In **Private IP address settings**, under the **TestVNet/FrontEnd** virtual network/subnet, note the **Assignment** value (**Dynamic** or **Static**) and the **IP address**. |
| 97 | +7. Select **Static** in **Assignment**. Select **Save**. |
103 | 98 |
|
104 |
| -  |
| 99 | + :::image type="content" source="./media/virtual-networks-static-private-ip-arm-pportal/select-static-assignment.png" alt-text="Screenshot of select static assignment."::: |
105 | 100 |
|
106 |
| -## Add a static private IP address to an existing VM |
107 |
| -To add a static private IP address to your new VM: |
| 101 | + > [!NOTE] |
| 102 | + > If you notice after selecting **Save** that the assignment is still set to **Dynamic**, the IP address you typed is already in use. Try another IP address. |
108 | 103 |
|
109 |
| -1. In the IP configuration page, set the assignment for your private IP address to **Static**. |
110 |
| -2. Change your private **IP address** to *192.168.1.101*, and then select **Save**. |
111 |
| - |
112 |
| -  |
| 104 | +To change the IP address back to dynamic set the assignment for your private IP address to **Dynamic**, and then select **Save**. |
113 | 105 |
|
114 |
| -> [!NOTE] |
115 |
| -> If you notice after selecting **Save** that the assignment is still set to **Dynamic**, the IP address you typed is already in use. Try another IP address. |
| 106 | +> [!WARNING] |
| 107 | +> From within the operating system of a VM, you shouldn't statically assign the *private* IP that's assigned to the Azure VM. Only do static assignment of a private IP when it's necessary, such as when [assigning many IP addresses to VMs](virtual-network-multiple-ip-addresses-portal.md). |
| 108 | +> |
| 109 | +>If you manually set the private IP address within the operating system, make sure it matches the private IP address assigned to the Azure [network interface](virtual-network-network-interface-addresses.md#change-ip-address-settings). Otherwise, you can lose connectivity to the VM. Learn more about [private IP address](virtual-network-network-interface-addresses.md#private) settings. |
116 | 110 |
|
117 |
| -## Remove a static private IP address from a VM |
118 |
| -To remove the static private IP address from your VM: |
| 111 | +## Clean up resources |
119 | 112 |
|
120 |
| -In the IP configuration page, set the assignment for your private IP address to **Dynamic**, and then select **Save**. |
| 113 | +When no longer needed, delete the resource group and all of the resources it contains: |
121 | 114 |
|
122 |
| -## Set IP addresses within the operating system |
| 115 | +1. Enter **myResourceGroup** in the **Search** box at the top of the portal. When you see **myResourceGroup** in the search results, select it. |
123 | 116 |
|
124 |
| -From within the operating system of a VM, you shouldn't statically assign the *private* IP that's assigned to the Azure VM. Only do static assignment of a private IP when it's necessary, such as when [assigning many IP addresses to VMs](virtual-network-multiple-ip-addresses-portal.md). If you manually set the private IP address within the operating system, make sure it matches the private IP address assigned to the Azure [network interface](virtual-network-network-interface-addresses.md#change-ip-address-settings). Otherwise, you can lose connectivity to the VM. Learn more about [private IP address](virtual-network-network-interface-addresses.md#private) settings. |
| 117 | +2. Select **Delete resource group**. |
125 | 118 |
|
126 |
| -Also, you should never manually assign the *public* IP address assigned to an Azure virtual machine within the virtual machine's operating system. |
| 119 | +3. Enter **myResourceGroup** for **TYPE THE RESOURCE GROUP NAME:** and select **Delete**. |
127 | 120 |
|
128 | 121 | ## Next steps
|
129 | 122 |
|
130 |
| -Learn about managing [IP address settings](virtual-network-network-interface-addresses.md). |
| 123 | +- Learn more about [static public IP addresses](public-ip-addresses.md#ip-address-assignment). |
| 124 | + |
| 125 | +- Learn more about [public IP addresses](public-ip-addresses.md#public-ip-addresses) in Azure. |
| 126 | + |
| 127 | +- Learn more about all [public IP address settings](virtual-network-public-ip-address.md#create-a-public-ip-address). |
| 128 | + |
| 129 | +- Learn more about [private IP addresses](private-ip-addresses.md) and assigning a [static private IP address](virtual-network-network-interface-addresses.md#add-ip-addresses) to an Azure virtual machine. |
| 130 | + |
0 commit comments