0

AzureVM Static IP Does Not Persist

It is possible to configure a “static” IP on your Azure IAAS VMs.  This is something that we looked at in a previous post.  One thing worth pointing out is that there is a little wrinkle with the current implementation, and you may run into unexpected results. 

Static IP assignment in Azure VMs is not the same as configuring a typical static IP for a server in your on-premises network.  When you statically assign an IP address to the Azure VM, it is not entered into the VMs machine’s TCP/IP configuration property sheet .  Rather a reservation is created, so that DHCP hands out the desired address to the VM.  If you look at the VM’s NIC, it is still set as a DHCP client, but the DHCP server will honour the reservation that you configured. 

Well, sometimes. 

Setting a static IP onto an Azure VM may not work as expected, and another VM on the same virtual network could grab the static IP address which was previously assigned to another VM.

One common issue is that the Update-AzureVM cmdlet is omitted when configuring the static IP.  This cmdlet is a requirement.  Some examples of syntax include:

  • $VM | Set-AzureStaticVNetIP 10.00.5 | Update-AzureVM
  • Set-AzureStaticVNetIP -VM(Get-AzureVM -ServiceName "Tailspintoys-Canada" -Name Tail-CA-DC-1) -IPAddress 10.0.0.4 | Update-AzureVM
  • Get-AzureVM -ServiceName "Rmilne-Tailspintoys-Canada" -Name Tail-CA-DC-1 | Set-AzureStaticVNetIP -IPAddress 10.0.0.4 | Update-AzureVM

Note that in the first example, $VM contains a reference to the Azure VM which is being modified.

  

Holly Lab Setup, Buddy!

<super tenuous link to Weezer’s Buddy holy> *

In the below cloud service there are several VMs.  Two of the VMs have been configured with static IP addresses using Set-AzureStaticVMNetIP.  These two machines are Tail-CA-DC-1 and Tail-CA-DC-2.  They were assigned IP addresses 10.0.0.4 and 10.0.0.5 respectively.   Tail-CA-DC-1 is already running.  Regardless if we configured a static IP, it would have received 10.0.0.4 anyway as that is the first valid IP in the subnet. 

Cloud Service With Single VM Running - Note IP Address is 10.0.0.4

Let’s check the configuration of the second DC to ensure it has a static IP.  And let us also check the ADFS server to see how that is configured. 

Get-AzureVM -ServiceName rmilne-tailspintoys-canada  -Name Tail-CA-DC-2 | Get-AzureStaticVNetIP

Get-AzureVM -ServiceName rmilne-tailspintoys-canada  -Name Tail-CA-STS | Get-AzureStaticVNetIP

Checking IP Configuration

As you can see DC-2 has 10.0.0.5 set as its static IP, and the STS server does not have a static address.    

Lets power up the STS server.  What IP would you expect it to get?  Since 10.0.0.6 is the next valid IP in the range, would that be a good assumption? 

 

Start Me Up!

<courtesy link to the Rolling Stones Start Me Up and Window 95 launch commercial

Starting up the STS VM we see that the IP address of the second domain controller has been taken by the STS server. Oh my!

Azure VM Does Not Use Static IP Assigned To It

Did we not confirm that the second DC was meant to get the IPAddress 10.0.0.5?  Why has that been taken by the STS server?

 

Good Times Bad Times

<courtesy link to Eddie Brickell Good Times>

At the time of writing there is currently an issue where not all of the Azure VMs on the same virtual network are set with static addresses.  Remember in the above example, only two VMs had static IPs assigned. 

To workaround the issue, if you are assigning static addresses, then you should assign static addresses to ALL of the VMs on that virtual network to ensure you get the desired results. 

In the below screenshot, all of the VMs were updated to use a static IP address.  There are 8 VMs on the virtual network, and now there are 8 static IP addresses assigned.

All VMs Are Not Set With Static IP Address

 

Since all the VMs on the virtual network were assigned a static IP address, let’s see what happens this time when powering up the STS server.  Does it get the correct statically assigned IP?

Static Azure Addreses Working When All VMs Set To Use Static Addresses

Yes it does!  If all of your VMs were configured with static addresses from the start, then you will not have seen this issue.  In the above example the DCs were intended to be the only machines with a static IP.  

 

Cheers,

Rhoderick

* – Since it’s now 20 years since Windows 95 went RTM, thought it would be fun to feature the music videos from the original Windows 95 CD.  Alas they were cut from the OSR media due to space issues….

** – For bonus retro action, you could also listen to the Windows XP setup music….

Rhoderick Milne [MSFT]

Leave a Reply

Your email address will not be published. Required fields are marked *