Skip to content

Commit ab8db30

Browse files
author
Michael Bender
committed
merge articles
1 parent e6d1c1c commit ab8db30

File tree

1 file changed

+220
-4
lines changed

1 file changed

+220
-4
lines changed

articles/virtual-network/ip-services/add-dual-stack-ipv6-vm-portal.md

Lines changed: 220 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
title: Add a dual-stack network to an existing virtual machine - Azure portal
2+
title: Add a dual-stack network to an existing virtual machine
33
titleSuffix: Azure Virtual Network
4-
description: Learn how to add a dual stack network to an existing virtual machine using the Azure portal.
4+
description: Learn how to add a dual stack network to an existing virtual machine using the Azure portal, Azure CLI, or Azure PowerShell.
55
author: mbender-ms
66
ms.author: mbender
77
ms.service: virtual-network
@@ -11,12 +11,14 @@ ms.date: 08/24/2023
1111
ms.custom: template-how-to
1212
---
1313

14-
# Add a dual-stack network to an existing virtual machine using the Azure portal
14+
# Add a dual-stack network to an existing virtual machine
1515

16-
In this article, you add IPv6 support to an existing virtual network. You configure an existing virtual machine with both IPv4 and IPv6 addresses. When completed, the existing virtual network supports private IPv6 addresses. The existing virtual machine network configuration contains a public and private IPv4 and IPv6 address.
16+
In this article, you add IPv6 support to an existing virtual network. You configure an existing virtual machine with both IPv4 and IPv6 addresses. When completed, the existing virtual network supports private IPv6 addresses. The existing virtual machine network configuration contains a public and private IPv4 and IPv6 address. You will choose from the Azure Portal, Azure CLI or Azure PowerShell to complete the steps in this article.
1717

1818
## Prerequisites
1919

20+
# [Azure portal](#tab/azureportal)
21+
2022
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
2123

2224
- An existing virtual network, public IP address and virtual machine in your subscription that is configured for IPv4 support only. For more information about creating a virtual network, public IP address and a virtual machine, see [Quickstart: Create a Linux virtual machine in the Azure portal](../../virtual-machines/linux/quick-create-portal.md).
@@ -27,8 +29,44 @@ In this article, you add IPv6 support to an existing virtual network. You config
2729

2830
- The example public IP address used in this article is named **myPublicIP**. Replace this value with the name of your public IP address.
2931

32+
# [Azure CLI](#tab/azurecli/)
33+
34+
- An Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
35+
36+
[!INCLUDE [azure-cli-prepare-your-environment-no-header.md](~/reusable-content/azure-cli/azure-cli-prepare-your-environment-no-header.md)]
37+
38+
- This tutorial requires version 2.0.28 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
39+
40+
- An existing virtual network, public IP address and virtual machine in your subscription that is configured for IPv4 support only. For more information about creating a virtual network, public IP address and a virtual machine, see [Quickstart: Create a Linux virtual machine with the Azure CLI](../../virtual-machines/linux/quick-create-cli.md).
41+
42+
- The example virtual network used in this article is named **myVNet**. Replace this value with the name of your virtual network.
43+
44+
- The example virtual machine used in this article is named **myVM**. Replace this value with the name of your virtual machine.
45+
46+
- The example public IP address used in this article is named **myPublicIP**. Replace this value with the name of your public IP address.
47+
48+
# [Azure PowerShell](#tab/azurepowershell/)
49+
50+
- An Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
51+
52+
- Azure PowerShell installed locally or Azure Cloud Shell
53+
54+
If you choose to install and use PowerShell locally, this article requires the Azure PowerShell module version 5.4.1 or later. Run `Get-Module -ListAvailable Az` to find the installed version. If you need to upgrade, see [Install Azure PowerShell module](/powershell/azure/install-azure-powershell). If you're running PowerShell locally, you also need to run `Connect-AzAccount` to create a connection with Azure.
55+
56+
- An existing virtual network, public IP address and virtual machine in your subscription that is configured for IPv4 support only. For more information about creating a virtual network, public IP address and a virtual machine, see [Quickstart: Create a Linux virtual machine in Azure with PowerShell](../../virtual-machines/linux/quick-create-powershell.md).
57+
58+
- The example virtual network used in this article is named **myVNet**. Replace this value with the name of your virtual network.
59+
60+
- The example virtual machine used in this article is named **myVM**. Replace this value with the name of your virtual machine.
61+
62+
- The example public IP address used in this article is named **myPublicIP**. Replace this value with the name of your public IP address.
63+
64+
---
65+
3066
## Add IPv6 to virtual network
3167

68+
# [Azure portal](#tab/azureportal)
69+
3270
In this section, you add an IPv6 address space and subnet to your existing virtual network.
3371

3472
1. Sign in to the [Azure portal](https://portal.azure.com).
@@ -53,8 +91,82 @@ In this section, you add an IPv6 address space and subnet to your existing virtu
5391

5492
11. Select **Save**.
5593

94+
# [Azure CLI](#tab/azurecli/)
95+
96+
In this section, you add an IPv6 address space and subnet to your existing virtual network.
97+
98+
Use [az network vnet update](/cli/azure/network/vnet#az-network-vnet-update) to update the virtual network.
99+
100+
```azurecli-interactive
101+
az network vnet update \
102+
--address-prefixes 10.0.0.0/16 2404:f800:8000:122::/63 \
103+
--resource-group myResourceGroup \
104+
--name myVNet
105+
```
106+
107+
Use [az network vnet subnet update](/cli/azure/network/vnet/subnet#az-network-vnet-subnet-update) to create the subnet.
108+
109+
```azurecli-interactive
110+
az network vnet subnet update \
111+
--address-prefixes 10.0.0.0/24 2404:f800:8000:122::/64 \
112+
--name myBackendSubnet \
113+
--resource-group myResourceGroup \
114+
--vnet-name myVNet
115+
```
116+
117+
# [Azure PowerShell](#tab/azurepowershell/)
118+
119+
In this section, you add an IPv6 address space and subnet to your existing virtual network.
120+
121+
Use [Set-AzVirtualNetwork](/powershell/module/az.network/set-azvirtualnetwork) to update the virtual network.
122+
123+
```azurepowershell-interactive
124+
## Place your virtual network into a variable. ##
125+
$net = @{
126+
Name = 'myVNet'
127+
ResourceGroupName = 'myResourceGroup'
128+
}
129+
$vnet = Get-AzVirtualNetwork @net
130+
131+
## Place address space into a variable. ##
132+
$IPAddressRange = '2404:f800:8000:122::/63'
133+
134+
## Add the address space to the virtual network configuration. ##
135+
$vnet.AddressSpace.AddressPrefixes.Add($IPAddressRange)
136+
137+
## Save the configuration to the virtual network. ##
138+
Set-AzVirtualNetwork -VirtualNetwork $vnet
139+
```
140+
141+
Use [Set-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/set-azvirtualnetworksubnetconfig) to add the new IPv6 subnet to the virtual network.
142+
143+
```azurepowershell-interactive
144+
## Place your virtual network into a variable. ##
145+
$net = @{
146+
Name = 'myVNet'
147+
ResourceGroupName = 'myResourceGroup'
148+
}
149+
$vnet = Get-AzVirtualNetwork @net
150+
151+
## Create the subnet configuration. ##
152+
$sub = @{
153+
Name = 'myBackendSubnet'
154+
AddressPrefix = '10.0.0.0/24','2404:f800:8000:122::/64'
155+
VirtualNetwork = $vnet
156+
}
157+
Set-AzVirtualNetworkSubnetConfig @sub
158+
159+
## Save the configuration to the virtual network. ##
160+
Set-AzVirtualNetwork -VirtualNetwork $vnet
161+
```
162+
163+
---
164+
56165
## Create IPv6 public IP address
57166

167+
# [Azure portal](#tab/azureportal)
168+
169+
58170
In this section, you create a IPv6 public IP address for the virtual machine.
59171

60172
1. In the search box at the top of the portal, enter **Public IP address**. Select **Public IP addresses** in the search results.
@@ -77,8 +189,46 @@ In this section, you create a IPv6 public IP address for the virtual machine.
77189

78190
4. Select **Create**.
79191

192+
# [Azure CLI](#tab/azurecli/)
193+
194+
In this section, you create a IPv6 public IP address for the virtual machine.
195+
196+
Use [az network public-ip create](/cli/azure/network/public-ip#az-network-public-ip-create) to create the public IP address.
197+
198+
```azurecli-interactive
199+
az network public-ip create \
200+
--resource-group myResourceGroup \
201+
--name myPublicIP-Ipv6 \
202+
--sku Standard \
203+
--version IPv6 \
204+
--zone 1 2 3
205+
```
206+
207+
# [Azure PowerShell](#tab/azurepowershell/)
208+
209+
In this section, you create a IPv6 public IP address for the virtual machine.
210+
211+
Use [New-AzPublicIpAddress](/powershell/module/az.network/new-azpublicipaddress) to create the public IP address.
212+
213+
```azurepowershell-interactive
214+
$ip6 = @{
215+
Name = 'myPublicIP-IPv6'
216+
ResourceGroupName = 'myResourceGroup'
217+
Location = 'eastus2'
218+
Sku = 'Standard'
219+
AllocationMethod = 'Static'
220+
IpAddressVersion = 'IPv6'
221+
Zone = 1,2,3
222+
}
223+
New-AzPublicIpAddress @ip6
224+
```
225+
226+
---
227+
80228
## Add IPv6 configuration to virtual machine
81229

230+
# [Azure portal](#tab/azureportal)
231+
82232
The virtual machine must be stopped to add the IPv6 configuration to the existing virtual machine. You stop the virtual machine and add the IPv6 configuration to the existing virtual machine's network interface.
83233

84234
1. In the search box at the top of the portal, enter **Virtual machine**. Select **Virtual machines** in the search results.
@@ -110,6 +260,72 @@ The virtual machine must be stopped to add the IPv6 configuration to the existin
110260

111261
10. Start **myVM**.
112262

263+
# [Azure CLI](#tab/azurecli/)
264+
265+
Use [az network nic ip-config create](/cli/azure/network/nic/ip-config#az-network-nic-ip-config-create) to create the IPv6 configuration for the NIC. The **`--nic-name`** used in the example is **myvm569**. Replace this value with the name of the network interface in your virtual machine.
266+
267+
```azurecli-interactive
268+
az network nic ip-config create \
269+
--resource-group myResourceGroup \
270+
--name Ipv6config \
271+
--nic-name myvm569 \
272+
--private-ip-address-version IPv6 \
273+
--vnet-name myVNet \
274+
--subnet myBackendSubnet \
275+
--public-ip-address myPublicIP-IPv6
276+
```
277+
278+
279+
# [Azure PowerShell](#tab/azurepowershell/)
280+
281+
Use [New-AzNetworkInterfaceIpConfig](/powershell/module/az.network/new-aznetworkinterfaceipconfig) to create the IPv6 configuration for the NIC. The **`-Name`** used in the example is **myvm569**. Replace this value with the name of the network interface in your virtual machine.
282+
283+
```azurepowershell-interactive
284+
## Place your virtual network into a variable. ##
285+
$net = @{
286+
Name = 'myVNet'
287+
ResourceGroupName = 'myResourceGroup'
288+
}
289+
$vnet = Get-AzVirtualNetwork @net
290+
291+
## Place your virtual network subnet into a variable. ##
292+
$sub = @{
293+
Name = 'myBackendSubnet'
294+
VirtualNetwork = $vnet
295+
}
296+
$subnet = Get-AzVirtualNetworkSubnetConfig @sub
297+
298+
## Place the IPv6 public IP address you created previously into a variable. ##
299+
$pip = @{
300+
Name = 'myPublicIP-IPv6'
301+
ResourceGroupName = 'myResourceGroup'
302+
}
303+
$publicIP = Get-AzPublicIPAddress @pip
304+
305+
## Place the network interface into a variable. ##
306+
$net = @{
307+
Name = 'myvm569'
308+
ResourceGroupName = 'myResourceGroup'
309+
}
310+
$nic = Get-AzNetworkInterface @net
311+
312+
## Create the configuration for the network interface. ##
313+
$ipc = @{
314+
Name = 'Ipv6config'
315+
Subnet = $subnet
316+
PublicIpAddress = $publicIP
317+
PrivateIpAddressVersion = 'IPv6'
318+
}
319+
$ipconfig = New-AzNetworkInterfaceIpConfig @ipc
320+
321+
## Add the IP configuration to the network interface. ##
322+
$nic.IpConfigurations.Add($ipconfig)
323+
324+
## Save the configuration to the network interface. ##
325+
$nic | Set-AzNetworkInterface
326+
```
327+
---
328+
113329
## Next steps
114330

115331
In this article, you learned how to add a dual stack IP configuration to an existing virtual network and virtual machine.

0 commit comments

Comments
 (0)