Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
When you create a virtual machine (VM), it's automatically assigned a private IP address from a range that you specify. This IP address is based on the subnet in which the VM is deployed, and the VM keeps this 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 to assign a specific IP address in this subnet for your VM, use a static IP address.
Prerequisites
- An Azure account with an active subscription. You can create an account for free.
Create a resource group and a virtual machine
Create a resource group
Sign in to the Azure portal.
In the portal, search for and select Resource groups.
Select + Create.
On the Basics tab, enter or select the following values:
Setting Value Subscription Select your subscription Resource group Enter myResourceGroup Region Select (US) East US Select Review + create, and then select Create.
Create a virtual network
In the portal, search for and select Virtual networks.
Select + Create.
On the Basics tab of Create virtual network, enter or select the following values:
Setting Value Subscription Select your subscription Resource group Select myResourceGroup Virtual network name Enter myVNet Region Select (US) East US Select Review + create, and then select Create.
Create a virtual machine
In the portal, search for and select Virtual machines.
Select Create > Azure virtual machine.
On the Basics tab of the Create a virtual machine screen, enter or select the following values:
Setting Value Subscription Select your subscription Resource group Select myResourceGroup Virtual machine name Enter myVM Region Select (US) East US 2 Availability options Select No infrastructure redundancy required Security type Select Standard Image Select Ubuntu Server 22.04 LTS - x64 Gen2 Size Accept the default, or drop down and select a size Authentication type Select SSH public key Username Enter azureuser SSH public key source Select Generate new key pair Key pair name Enter mySSHKey Public inbound ports Select None Select the Networking tab at the top of the page.
On the Networking page, enter or select the following values:
- Virtual network: Select myVNet.
- Subnet: Select default if not already selected.
- Public IP: Select None.
Select Review + create. Review the settings, and then select Create.
Note
The virtual machine is created without a public IP address and with no public inbound ports. To connect to the virtual machine, use Azure Bastion. For more information, see Quickstart: Deploy Azure Bastion with default settings.
Change private IP address to static
In the following steps, you change the private IP address static for the VM created previously:
In the portal, search for and select Virtual machines.
In Virtual machines, select myVM from the list.
On the myVM page, select Network settings under Networking.
On the Network settings page, select the name of the network interface next to Network interface.
On the Network interface page, under Settings, select IP configurations.
In IP configurations, select ipconfig1 in the list.
Under Assignment, select Static. Change the private IP address if you want a different one, and then select Save.
Warning
If you change the private IP address, the VM associated with the network interface will be restarted to utilize the new IP address.
From within the operating system of a VM, avoid associating a static private IP address on an Azure VM. Only assign a static private IP when it's necessary, such as when assigning many IP addresses to VMs.
If you manually set the private IP address within the operating system, make sure it matches the private IP address assigned to the Azure network interface. Otherwise, you can lose connectivity to the VM. For more information, see private IP address settings.
Clean up resources
When all the resources are no longer need, delete the resource group and all of the resources it contains:
In the portal, search for and select myResourceGroup.
From the myResourceGroup screen, select Delete resource group.
Enter myResourceGroup for Enter resource group name to confirm deletion, and then select Delete.
Next steps
Learn more about static public IP addresses in Azure.
Learn more about public IP addresses in Azure.
Learn more about Azure public IP address settings.
Learn more about private IP addresses and assigning a static private IP address to an Azure VM.