|
| 1 | +--- |
| 2 | +title: Create an Azure virtual machine with a dual-stack network - Azure portal |
| 3 | +titleSuffix: Azure Virtual Network |
| 4 | +description: In this article, learn how to use the Azure portal to create a virtual machine with a dual-stack virtual network in Azure. |
| 5 | +author: asudbring |
| 6 | +ms.author: allensu |
| 7 | +ms.service: virtual-network |
| 8 | +ms.subservice: ip-services |
| 9 | +ms.topic: how-to |
| 10 | +ms.date: 08/17/2022 |
| 11 | +ms.custom: template-how-to |
| 12 | +--- |
| 13 | + |
| 14 | +# Create an Azure Virtual Machine with a dual-stack network using the Azure portal |
| 15 | + |
| 16 | +In this article, you'll create a virtual machine in Azure with the Azure portal. The virtual machine is created along with the dual-stack network as part of the procedures. When completed, the virtual machine supports IPv4 and IPv6 communication. |
| 17 | + |
| 18 | +## Prerequisites |
| 19 | + |
| 20 | +- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). |
| 21 | + |
| 22 | +## Create a virtual network |
| 23 | + |
| 24 | +In this section, you'll create a dual-stack virtual network for the virtual machine. |
| 25 | + |
| 26 | +1. Sign-in to the [Azure portal](https://https://portal.azure.com). |
| 27 | + |
| 28 | +2. In the search box at the top of the portal, enter **Virtual network**. Select **Virtual networks** in the search results. |
| 29 | + |
| 30 | +3. Select **+ Create**. |
| 31 | + |
| 32 | +4. In the **Basics** tab of **Create virtual network**, enter or select the following information. |
| 33 | + |
| 34 | + | Setting | Value | |
| 35 | + | ------- | ----- | |
| 36 | + | **Project details** | | |
| 37 | + | Subscription | Select your subscription. | |
| 38 | + | Resource group | Select **Create new**. </br> In **Name**, enter **myResourceGroup**. </br> Select **OK**. | |
| 39 | + | **Instance details** | | |
| 40 | + | Name | Enter **myVNet**. | |
| 41 | + | Region | Select **East US 2**. | |
| 42 | + |
| 43 | +5. Select the **IP Addresses** tab, or **Next: IP Addresses**. |
| 44 | + |
| 45 | +6. Leave the default IPv4 address space of **10.1.0.0/16**. If the default is absent or different, enter an IPv4 address space of **10.1.0.0/16**. |
| 46 | + |
| 47 | +7. Select the **Add IPv6 address space** box. |
| 48 | + |
| 49 | +8. In **IPv6 address space**, edit the default address space and change its value to **2404:f800:8000:122::/63**. |
| 50 | + |
| 51 | +9. To add an IPv6 subnet, select **default** under **Subnet name**. If default is missing, select **+ Add subnet**. |
| 52 | + |
| 53 | +10. In **Subnet name**, enter **myBackendSubnet**. |
| 54 | + |
| 55 | +11. Leave the default IPv4 subnet of **10.1.0.0/24** in **Subnet address range**. Enter **10.1.0.0/24** if missing. |
| 56 | + |
| 57 | +12. Select the box next to **Add IPv6 address space**. |
| 58 | + |
| 59 | +13. In **IPv6 address range**, enter **2404:f800:8000:122::/64**. |
| 60 | + |
| 61 | +14. Select **Save**. If creating a subnet, select **Add**. |
| 62 | + |
| 63 | +15. Select the **Review + create**. |
| 64 | + |
| 65 | +16. Select **Create**. |
| 66 | + |
| 67 | +## Create public IP addresses |
| 68 | + |
| 69 | +You'll create two public IP addresses in this section, IPv4 and IPv6. |
| 70 | + |
| 71 | +1. In the search box at the top of the portal, enter **Public IP address**. Select **Public IP addresses** in the search results. |
| 72 | + |
| 73 | +2. Select **+ Create**. |
| 74 | + |
| 75 | +3. Enter or select the following information in **Create public IP address**. |
| 76 | + |
| 77 | + | Setting | Value | |
| 78 | + | ------- | ----- | |
| 79 | + | IP version | Select **Both**. | |
| 80 | + | SKU | Leave the default of **Standard**. | |
| 81 | + | **Ipv4 IP Address Configuration** | | |
| 82 | + | Name | Enter **myPublicIP-IPv4**. | |
| 83 | + | Routing preference | Leave the default of **Microsoft network**. | |
| 84 | + | Idle timeout (minutes) | Leave the default of **4**. | |
| 85 | + | **IPv6 IP Address Configuration** | | |
| 86 | + | Name | Enter **myPublicIP-IPv6**. | |
| 87 | + | Idle timeout (minutes) | Leave the default of **4**. | |
| 88 | + | Subscription | Select your subscription. | |
| 89 | + | Resource group | Select **myResourceGroup**. | |
| 90 | + | Location | Select **East US 2**. | |
| 91 | + | Availability zone | Select **Zone redundant**. | |
| 92 | + |
| 93 | +4. Select **Create**. |
| 94 | + |
| 95 | +## Create network security group |
| 96 | + |
| 97 | +You'll create a network security group to allow SSH connections to the virtual machine. |
| 98 | + |
| 99 | +1. In the search box at the top of the portal, enter **Network security group**. Select **Network security groups** in the search results. |
| 100 | + |
| 101 | +2. Select **+Create**. |
| 102 | + |
| 103 | +3. Enter or select the following information in the **Basics** tab. |
| 104 | + |
| 105 | + | Setting | Value | |
| 106 | + | ------- | ----- | |
| 107 | + | **Project details** | | |
| 108 | + | Subscription | Select your subscription. | |
| 109 | + | Resource group | Select **myResourceGroup**. | |
| 110 | + | **Instance details** | | |
| 111 | + | Name | Enter **myNSG**. | |
| 112 | + | Region | Select **East US 2**. | |
| 113 | + |
| 114 | +4. Select **Review + create**. |
| 115 | + |
| 116 | +5. Select **Create**. |
| 117 | + |
| 118 | +### Create network security group rules |
| 119 | + |
| 120 | +In this section, you'll create the inbound rule. |
| 121 | + |
| 122 | +1. In the search box at the top of the portal, enter **Network security group**. Select **Network security groups** in the search results. |
| 123 | + |
| 124 | +2. In **Network security groups**, select **myNSG**. |
| 125 | + |
| 126 | +3. In **Settings**, select **Inbound security rules**. |
| 127 | + |
| 128 | +4. Select **+ Add**. |
| 129 | + |
| 130 | +5. In **Add inbound security rule**, enter or select the following information. |
| 131 | + |
| 132 | + | Setting | Value | |
| 133 | + | ------- | ----- | |
| 134 | + | Source | Leave the default of **Any**. | |
| 135 | + | Source port ranges | Leave the default of *. | |
| 136 | + | Destination | Leave the default of **Any**. | |
| 137 | + | Service | Select **SSH**. | |
| 138 | + | Action | Leave the default of **Allow**. | |
| 139 | + | Priority | Enter **200**. | |
| 140 | + | Name | Enter **myNSGRuleSSH**. | |
| 141 | + |
| 142 | +6. Select **Add**. |
| 143 | + |
| 144 | +## Create virtual machine |
| 145 | + |
| 146 | +In this section, you'll create the virtual machine and its supporting resources. |
| 147 | + |
| 148 | +### Create network interface |
| 149 | + |
| 150 | +You'll create a network interface and attach the public IP addresses you created previously. |
| 151 | + |
| 152 | +1. In the search box at the top of the portal, enter **Network interface**. Select **Network interfaces** in the search results. |
| 153 | + |
| 154 | +2. Select **+ Create**. |
| 155 | + |
| 156 | +3. In the **Basics** tab of **Create network interface, enter or select the following information. |
| 157 | + |
| 158 | + | Setting | Value | |
| 159 | + | ------- | ----- | |
| 160 | + | **Project details** | | |
| 161 | + | Subscription | Select your subscription. | |
| 162 | + | Resource group | Select **myResourceGroup**. | |
| 163 | + | **Instance details** | | |
| 164 | + | Name | Enter **myNIC1**. | |
| 165 | + | Region | Select **East US 2**. | |
| 166 | + | Virtual network | Select **myVNet**. | |
| 167 | + | Subnet | Select **myBackendSubnet (10.1.0.0/24,2404:f800:8000:122:/64)**. | |
| 168 | + | Network security group | Select **myNSG**. | |
| 169 | + | Private IP address (IPv6) | Select the box. | |
| 170 | + | IPv6 name | Enter **Ipv6config**. | |
| 171 | + |
| 172 | +4. Select **Review + create**. |
| 173 | + |
| 174 | +5. Select **Create**. |
| 175 | + |
| 176 | +### Associate public IP addresses |
| 177 | + |
| 178 | +You'll associate the IPv4 and IPv6 addresses you created previously to the network interface. |
| 179 | + |
| 180 | +1. In the search box at the top of the portal, enter **Network interface**. Select **Network interfaces** in the search results. |
| 181 | + |
| 182 | +2. Select **myNIC1**. |
| 183 | + |
| 184 | +3. Select **IP configurations** in **Settings**. |
| 185 | + |
| 186 | +4. In **IP configurations**, select **Ipv4config**. |
| 187 | + |
| 188 | +5. In **Ipv4config**, select **Associate** in **Public IP address**. |
| 189 | + |
| 190 | +6. Select **myPublicIP-IPv4** in **Public IP address**. |
| 191 | + |
| 192 | +7. Select **Save**. |
| 193 | + |
| 194 | +8. Close **Ipv4config**. |
| 195 | + |
| 196 | +9. In **IP configurations**, select **ipconfig-ipv6**. |
| 197 | + |
| 198 | +10. In **Ipv6config**, select **Associate** in **Public IP address**. |
| 199 | + |
| 200 | +11. Select **myPublicIP-IPv6** in **Public IP address**. |
| 201 | + |
| 202 | +12. Select **Save**. |
| 203 | + |
| 204 | +### Create virtual machine |
| 205 | + |
| 206 | +1. In the search box at the top of the portal, enter **Virtual machine**. Select **Virtual machines** in the search results. |
| 207 | + |
| 208 | +2. Select **+ Create** then **Azure virtual machine**. |
| 209 | + |
| 210 | +3. In the **Basics** tab, enter or select the following information. |
| 211 | + |
| 212 | + | Setting | Value | |
| 213 | + | ------- | ----- | |
| 214 | + | **Project details** | | |
| 215 | + | Subscription | Select your subscription. | |
| 216 | + | Resource group | Select **myResourceGroup**. | |
| 217 | + | **Instance details** | | |
| 218 | + | Virtual machine name | Enter **myVM**. | |
| 219 | + | Region | Select **East US 2**. | |
| 220 | + | Availability options | Select **No infrastructure redundancy required**. | |
| 221 | + | Security type | Select **Standard**. | |
| 222 | + | Image | Select **Ubuntu Server 20.04 LTS - Gen2**. | |
| 223 | + | Size | Select the default size. | |
| 224 | + | **Administrator account** | | |
| 225 | + | Authentication type | Select **SSH public key**. | |
| 226 | + | Username | Enter a username. | |
| 227 | + | SSH public key source | Select **Generate new key pair**. | |
| 228 | + | Key pair name | Enter **mySSHKey**. | |
| 229 | + | **Inbound port rules** | | |
| 230 | + | Public inbound ports | Select **None**. | |
| 231 | + |
| 232 | +4. Select the **Networking** tab, or **Next: Disks** then **Next: Networking**. |
| 233 | + |
| 234 | +5. Enter or select the following information in the **Networking** tab. |
| 235 | + |
| 236 | + | Setting | Value | |
| 237 | + | ------- | ----- | |
| 238 | + | **Network interface** | | |
| 239 | + | Virtual network | Select **myVNet**. | |
| 240 | + | Subnet | Select **myBackendSubnet (10.1.0.0/24,2404:f800:8000:122:/64)**. | |
| 241 | + | Public IP | Select **None**. | |
| 242 | + | NIC network security group | Select **None**. | |
| 243 | + |
| 244 | +6. Select **Review + create**. |
| 245 | + |
| 246 | +7. Select **Create**. |
| 247 | + |
| 248 | +8. **Generate new key pair** will appear. Select **Download private key and create resource**. |
| 249 | + |
| 250 | +9. The private key will download to your local computer. Copy the private key to a directory on your computer. In the following example, it's **~/.ssh**. |
| 251 | + |
| 252 | +10. In the search box at the top of the portal, enter **Virtual machine**. Select **Virtual machines** in the search results. |
| 253 | + |
| 254 | +11. Select **myVM**. |
| 255 | + |
| 256 | +12. Stop **myVM**. |
| 257 | + |
| 258 | +### Network interface configuration |
| 259 | + |
| 260 | +A network interface is automatically created and attached to the chosen virtual network during creation. In this section, you'll remove this default network interface and attach the network interface you created previously. |
| 261 | + |
| 262 | +1. In the search box at the top of the portal, enter **Virtual machine**. Select **Virtual machines** in the search results. |
| 263 | + |
| 264 | +2. Select **myVM**. |
| 265 | + |
| 266 | +3. Select **Networking** in **Settings**. |
| 267 | + |
| 268 | +4. Select **Attach network interface**. |
| 269 | + |
| 270 | +5. Select **myNIC1** that you created previously. |
| 271 | + |
| 272 | +6. Select **OK**. |
| 273 | + |
| 274 | +7. Select **Detach network interface**. |
| 275 | + |
| 276 | +8. The name of your default network interface will be **myvmxx**, with xx a random number. In this example, it's **myvm281**. Select **myvm281** in **Detach network interface**. |
| 277 | + |
| 278 | +9. Select **OK**. |
| 279 | + |
| 280 | +10. Return to the **Overview** of **myVM** and start the virtual machine. |
| 281 | + |
| 282 | +11. The default network interface can be safely deleted. |
| 283 | + |
| 284 | +## Test SSH connection |
| 285 | + |
| 286 | +You'll connect to the virtual machine with SSH to test the IPv4 public IP address. |
| 287 | + |
| 288 | +1. In the search box at the top of the portal, enter **Public IP address**. Select **Public IP addresses** in the search results. |
| 289 | + |
| 290 | +2. Select **myPublicIP-IPv4**. |
| 291 | + |
| 292 | +3. The public IPv4 address is in the **Overview** in **IP address**. In this example it's, **20.22.46.19**. |
| 293 | + |
| 294 | +4. Open an SSH connection to the virtual machine by using the following command. Replace the IP address with the IP address of your virtual machine. Replace **`azureuser`** with the username you chose during virtual machine creation. The **`-i`** is the path to the private key that you downloaded earlier. In this example, it's **~/.ssh/mySSHKey.pem**. |
| 295 | + |
| 296 | +```bash |
| 297 | +ssh -i ~/.ssh/mySSHkey.pem [email protected] |
| 298 | +``` |
| 299 | + |
| 300 | +## Clean up resources |
| 301 | + |
| 302 | +When your finished with the resources created in this article, delete the resource group and all of the resources it contains: |
| 303 | + |
| 304 | +1. In the search box at the top of the portal, enter **myResourceGroup**. Select **myResourceGroup** in the search results in **Resource groups**. |
| 305 | + |
| 306 | +2. Select **Delete resource group**. |
| 307 | + |
| 308 | +3. Enter **myResourceGroup** for **TYPE THE RESOURCE GROUP NAME** and select **Delete**. |
| 309 | + |
| 310 | +## Next steps |
| 311 | + |
| 312 | +In this article, you learned how to create an Azure Virtual machine with a dual-stack network. |
| 313 | + |
| 314 | +For more information about IPv6 and IP addresses in Azure, see: |
| 315 | + |
| 316 | +- [Overview of IPv6 for Azure Virtual Network.](ipv6-overview.md) |
| 317 | + |
| 318 | +- [What is Azure Virtual Network IP Services?](ip-services-overview.md) |
| 319 | + |
| 320 | + |
0 commit comments