| title | Assign multiple IP addresses to virtual machines - Azure portal | |||
|---|---|---|---|---|
| description | Learn how to assign multiple IP addresses to a virtual machine using the Azure portal. | |||
| services | virtual-network | |||
| ms.date | 02/06/2024 | |||
| ms.author | mbender | |||
| author | mbender-ms | |||
| ms.service | azure-virtual-network | |||
| ms.subservice | ip-services | |||
| ms.topic | how-to | |||
| ms.custom |
|
An Azure Virtual Machine (VM) has one or more network interfaces (NIC) attached to it. Any NIC can have one or more static or dynamic public and private IP addresses assigned to it.
Assigning multiple IP addresses to a VM enables the following capabilities:
- Hosting multiple websites or services with different IP addresses and TLS/SSL certificates on a single server.
- Serve as a network virtual appliance, such as a firewall or load balancer.
- The ability to add any (primary or secondary) private IP addresses of the NICs to an Azure Load Balancer backend pool. For more information about load balancing multiple IP configurations, see Load balancing multiple IP configurations and Outbound rules.
Every NIC attached to a VM has one or more IP configurations associated to it. Each configuration is assigned one static or dynamic private IP address. Each configuration may also have one public IP address resource associated to it. To learn more about IP addresses in Azure, see IP addresses in Azure.
Note
All IP configurations on a single NIC must be associated to the same subnet. If multiple IPs on different subnets are desired, multiple NICs on a VM can be used. To learn more about multiple NICs on a VM in Azure, see Create VM with Multiple NICs.
There's a limit to how many private IP addresses can be assigned to a NIC. There's also a limit to how many public IP addresses that can be used in an Azure subscription. See the Azure limits article for details.
This article explains how to add multiple IP addresses to a virtual machine using the Azure portal.
Note
If you want to create a virtual machine with multiple IP addresses, or a static private IP address, you must create it using PowerShell or the Azure CLI.
-
An Azure account with an active subscription. Create an account for free.
-
An existing Azure virtual machine with a Public IP. For more information about creating a virtual machine, see Create a Windows VM or Create a Linux VM.
- The example used in this article is named myVM. Replace this value with your virtual machine name.
- Windows Server virtual machines require port 3389 to be open for Remote Desktop Protocol (RDP) connections. Linux virtual machines require port 22 to be open for Secure Shell (SSH) connections.
-
An Azure Bastion instance deployed for VM management in the same subnet as your virtual machine. For more information, see Deploy Azure Bastion automatically
Note
Though the steps in this article assign all IP configurations to a single NIC, you can also assign multiple IP configurations to any NIC in a multi-NIC VM. To learn how to create a VM with multiple NICs, see Create a VM with multiple NICs.
:::image type="content" source="./media/virtual-network-multiple-ip-addresses-portal/multiple-ipconfigs.png" alt-text="Diagram of network configuration resources created in How-to article.":::
Figure: Diagram of network configuration resources created in this How-to article.
Important
Avoid breaking connectivity when adding IP addresses
When adding additional IP configurations to a VM, you do not need to convert the existing (primary) private IP address from Dynamic to Static.
Changing the primary IP allocation type can disrupt RDP/SSH connectivity and may require recovery steps such as adding a temporary IP address. This is unnecessary when your goal is only to add secondary IP addresses.
Recommended approach:
- Leave the primary private IP configuration unchanged.
- Add new secondary IP configurations (static or dynamic) directly to the NIC.
- Only change the primary IP to Static if a fixed primary address is explicitly required and you understand the impact.
You can add a private and public IP address to an Azure network interface by completing the following steps.
-
Sign in to the Azure portal.
-
In the search box at the top of the portal, enter Virtual machine. Select Virtual machines in the search results.
-
In Virtual machines, select myVM or the name of your virtual machine.
-
Select Network settings under Networking.
-
In Network settings, Select the name of the network interface and IP configuration of the virtual machine in the Network interface / IP configuration dropdown menu. The existing IP configuration is displayed. In this example, it's named myvm138_z1 (primary) / ipconfig1 (primary).
:::image type="content" source="./media/virtual-network-multiple-ip-addresses-portal/select-nic.png" alt-text="Screenshot of myVM networking and network interface selection.":::
-
In IP configurations, select + Add to create a new secondary IP configuration.
-
In Add IP configuration, enter or select the following information.
Setting Value Name Enter ipconfig2. Private IP address settings Allocation Select Static. Private IP address Enter an unused address in the network for your virtual machine.
For the 10.1.0.0/24 subnet in the example, an IP would be 10.1.0.5.Public IP address Select Associate public IP address Public IP address Select Create a public IP address.
Enter public-ip-02 in Name.
Select Standard in SKU.
Select OK. -
Select OK.
Note
When adding a static IP address, specify an unused and valid address in the subnet.
This applies only to the new secondary IP configuration. The primary IP configuration does not need to be changed.
Important
Restarting the VM is required for the operating system to recognize newly added IP addresses.
Adding secondary IP configurations does not require changing the primary IP allocation and does not inherently break existing connectivity.
You can add a private IP address to a virtual machine by completing the following steps.
-
Sign in to the Azure portal.
-
In the search box at the top of the portal, enter Virtual machine. Select Virtual machines in the search results.
-
In Virtual machines, select myVM or the name of your virtual machine.
-
Select Networking in Settings.
-
Select the name of the network interface of the virtual machine. In this example, it's named myvm889_z1.
:::image type="content" source="./media/virtual-network-multiple-ip-addresses-portal/select-nic.png" alt-text="Screenshot of myVM networking and network interface selection.":::
-
In the network interface, select IP configurations in Settings.
-
The existing IP configuration is displayed. This configuration is created when the virtual machine is created. To add a private and public IP address to the virtual machine, select + Add.
-
In Add IP configuration, enter or select the following information.
Setting Value Name Enter ipconfig3. Private IP address settings Allocation Select Static. IP address Enter an unused address in the network for your virtual machine.
For the 10.1.0.0/24 subnet in the example, an IP would be 10.1.0.6. -
Select OK.
Note
When adding a static IP address, specify an unused and valid address in the subnet.
This applies only to the new secondary IP configuration. The primary IP configuration does not need to be changed.
Important
Restarting the VM is required for the operating system to recognize newly added IP addresses.
Adding secondary IP configurations does not require changing the primary IP allocation and does not inherently break existing connectivity.
[!INCLUDE virtual-network-multiple-ip-addresses-os-config.md]
- Learn more about public IP addresses in Azure.
- Learn more about private IP addresses in Azure.
- Learn how to Configure IP addresses for an Azure network interface.