Configure private IP addresses for a virtual machine (Classic) using the Azure portal

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.

Important

Azure currently has two deployment models: Azure Resource Manager and classic. Make sure you understand deployment models and tools before you work with any Azure resource. To view the documentation for different tools, select the tabs at the beginning of this article.

This article covers the classic deployment model. You can also manage a static private IP address in the Resource Manager deployment model.

Scenario

To better illustrate how to configure a static IP address for a VM, this document uses this scenario:

Virtual network scenario: Front-end and back-end subnets, with a static IP address for the front-end subnet

In this scenario, you create a VM named DNS01 in the FrontEnd subnet, and then set it to use a static IP address of 192.168.1.101.

The sample steps that follow expect a simple environment already created. If you want to run the steps as they are displayed in this document, first build the test environment described in create a vnet.

How to specify a static private IP address when creating a VM

To create a VM named DNS01 in the FrontEnd subnet of a VNet named TestVNet with a static private IP of 192.168.1.101, complete the following steps:

  1. From a browser, navigate to https://portal.azure.com and, if necessary, sign in with your Azure account.

  2. Select NEW > Compute > Windows Server 2012 R2 Datacenter, notice that the Select a deployment model list already shows Classic, and then select Create.

    Screenshot that shows the Azure portal with the New > Compute > Windows Server 2012 R2 Datacenter tile highlighted.

  3. Under Create VM, enter the name of the VM to be created (DNS01 in the scenario), the local administrator account, and password.

    Screenshot that shows how to create a VM by entering the name of the VM, local administrator user name, and password.

  4. Select Optional Configuration > Network > Virtual Network, and then select TestVNet. If TestVNet is not available, make sure you are using the Central US location and have created the test environment described at the beginning of this article.

    Screenshot that shows the Optional Configuration > Network > Virtual Network > TestVNet option highlighted.

  5. Under Network, make sure the subnet currently selected is FrontEnd, then select IP addresses, under IP address assignment select Static, and then enter 192.168.1.101 for IP Address as seen below.

    Screenshot that highlights the IP Adresses field where you type the static IP address.

  6. Select OK under IP addresses, select OK under Network, and then select OK under Optional config.

  7. Under Create VM, select Create. Notice the tile below displayed in your dashboard:

    Screenshot that shows the Creating Windows Server 2012 R2 Datacenter tile.

How to retrieve static private IP address information for a VM

To view the static private IP address information for the VM created with the steps above, execute the steps below.

  1. From the Azure portal, select BROWSE ALL > Virtual machines (classic) > DNS01 > All settings > IP addresses and notice the IP address assignment and IP address as seen below.

    Create VM in Azure portal

How to remove a static private IP address from a VM

Under IP addresses, select Dynamic to the right of IP address assignment, select Save, and then select Yes, as shown in the following picture:

Screenshot that shows how to remove the static private IP address from a VM by selecting Dynamic to the right of the IP address assignment label.

How to add a static private IP address to an existing VM

  1. Under IP addresses, shown previously, select Static to the right of IP address assignment.
  2. Type 192.168.1.101 for IP address, select Save, and then select Yes.

Set IP addresses within the operating system

It’s recommended that you do not statically assign the private IP assigned to the Azure virtual machine within the operating system of a VM, unless necessary. If you do manually set the private IP address within the operating system, ensure that it is the same address as the private IP address assigned to the Azure VM, or you can lose connectivity to the virtual machine. You should never manually assign the public IP address assigned to an Azure virtual machine within the virtual machine's operating system.

Next steps