John Yassa's Blog

Home » Microsoft Azure » Configure a Static Internal IP Address for an Azure VM

Configure a Static Internal IP Address for an Azure VM

By default every VM will automatically receive an internal IP address from a range that you specify

But in some case you need to specify a static IP for your VM like (DNS , Domain controller , …….)

To assign a static IP to the VM , you have first to Install Azure Powershell

Before you specify a static IP address from your address pool, you may want to verify that the IP address has not been already assigned. In the example below, we’re checking to see whether the IP address 192.168.4.7 is available in the TestVNet virtual network.

Test-AzureStaticVNetIP –VNetName TestVNet –IPAddress 192.168.4.7

If you have already created the VM and just want to assign the the static IP

If you already set an IP address for the VM and you want to change it to a different IP address, you’ll need to remove the existing static IP address before running these cmdlets. See the instructions below to remove a static IP.

Get-AzureVM -ServiceName StaticDemo -Name VM2 | Set-AzureStaticVNetIP -IPAddress 192.168.4.7 | Update-AzureVM

If the VM is not yet created and you need to created with the static IP

New-AzureVMConfig -Name $vmname -ImageName $img –InstanceSize Small | Set-AzureSubnet –SubnetNames $sub | Set-AzureStaticVNetIP -IPAddress 192.168.4.7 | New-AzureVM –ServiceName $vmsvc1 –VNetName TestVNet

No how can your remove a static IP from a VM

When you remove a static IP address from a VM, the VM will automatically receive a new DIP after the VM restarts as part of the update process. In the example below, we remove the static IP from VM2, which is located in cloud service StaticDemo.

Get-AzureVM -ServiceName StaticDemo -Name VM2 | Remove-AzureStaticVNetIP | Update-AzureVM

Source: Azure MSDN


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: