Add a dual-stack network to an existing virtual machine
Article
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 choose from the Azure portal, Azure CLI, or Azure PowerShell to complete the steps in this article.
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.
The example virtual network used in this article is named myVNet. Replace this value with the name of your virtual network.
The example virtual machine used in this article is named myVM. Replace this value with the name of your virtual machine.
The example public IP address used in this article is named myPublicIP. Replace this value with the name of your public IP address.
If you prefer to run CLI reference commands locally, install the Azure CLI. If you're running on Windows or macOS, consider running Azure CLI in a Docker container. For more information, see How to run the Azure CLI in a Docker container.
If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For other sign-in options, see Sign in with the Azure CLI.
When you're prompted, install the Azure CLI extension on first use. For more information about extensions, see Use extensions with the Azure CLI.
Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade.
This tutorial requires version 2.0.28 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.
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.
The example virtual network used in this article is named myVNet. Replace this value with the name of your virtual network.
The example virtual machine used in this article is named myVM. Replace this value with the name of your virtual machine.
The example public IP address used in this article is named myPublicIP. Replace this value with the name of your public IP address.
Azure PowerShell installed locally or Azure Cloud Shell
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. If you're running PowerShell locally, you also need to run Connect-AzAccount to create a connection with Azure.
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.
The example virtual network used in this article is named myVNet. Replace this value with the name of your virtual network.
The example virtual machine used in this article is named myVM. Replace this value with the name of your virtual machine.
The example public IP address used in this article is named myPublicIP. Replace this value with the name of your public IP address.
## Place your virtual network into a variable. ##
$net = @{
Name = 'myVNet'
ResourceGroupName = 'myResourceGroup'
}
$vnet = Get-AzVirtualNetwork @net
## Place address space into a variable. ##
$IPAddressRange = '2404:f800:8000:122::/63'
## Add the address space to the virtual network configuration. ##
$vnet.AddressSpace.AddressPrefixes.Add($IPAddressRange)
## Save the configuration to the virtual network. ##
Set-AzVirtualNetwork -VirtualNetwork $vnet
In this section, you will configure your virtual machine’s network interface to include both a private and a public IPv6 address.
In the search box at the top of the portal, enter Virtual machine. Select Virtual machines in the search results.
Select myVM or your existing virtual machine name.
Select Networking in Settings.
Select your network interface name next to Network Interface:. In this example, the network interface is named myvm404.
Select IP configurations in Settings of the network interface.
In IP configurations, select + Add.
Enter or select the following information in Add IP configuration.
Setting
Value
Name
Enter Ipv6config.
IP version
Select IPv6.
Private IP address settings
Allocation
Leave the default of Dynamic.
Public IP address
Select Associate.
Public IP address
Select myPublic-IPv6.
Select OK.
Use az network nic ip-config create to create the IPv6 configuration for the network interface. The --nic-name used in the example is myvm569. Replace this value with the name of the network interface in your virtual machine.
Use New-AzNetworkInterfaceIpConfig to create the IPv6 configuration for the network interface. The -Name used in the example is myvm569. Replace this value with the name of the network interface in your virtual machine.
## Place your virtual network into a variable. ##
$net = @{
Name = 'myVNet'
ResourceGroupName = 'myResourceGroup'
}
$vnet = Get-AzVirtualNetwork @net
## Place your virtual network subnet into a variable. ##
$sub = @{
Name = 'myBackendSubnet'
VirtualNetwork = $vnet
}
$subnet = Get-AzVirtualNetworkSubnetConfig @sub
## Place the IPv6 public IP address you created previously into a variable. ##
$pip = @{
Name = 'myPublicIP-IPv6'
ResourceGroupName = 'myResourceGroup'
}
$publicIP = Get-AzPublicIPAddress @pip
## Place the network interface into a variable. ##
$net = @{
Name = 'myvm569'
ResourceGroupName = 'myResourceGroup'
}
$nic = Get-AzNetworkInterface @net
## Create the configuration for the network interface. ##
$ipc = @{
Name = 'Ipv6config'
Subnet = $subnet
PublicIpAddress = $publicIP
PrivateIpAddressVersion = 'IPv6'
}
$ipconfig = New-AzNetworkInterfaceIpConfig @ipc
## Add the IP configuration to the network interface. ##
$nic.IpConfigurations.Add($ipconfig)
## Save the configuration to the network interface. ##
$nic | Set-AzNetworkInterface
Next steps
In this article, you learned how to add a dual stack IP configuration to an existing virtual network and virtual machine.
For more information about IPv6 and IP addresses in Azure, see: