VM in Azure not working on new IP

 If you have a VM in azure that once you update the IP using the web interface or for that matter in the code and it does not restart on the new IP, then this is for you.

In this instance I was moving the IP from 10.8.0.55 to 10.8.0.56, so lets begin.......

Stop the VM as you cannot do this with it powered on.

I updated this on the web interface under VM then Networking then Network Interface then IP Configuration, click the current IP and you get this:


Once you have updated the VM and you start it up, the VM shows on the boot diagnostics its ready for connections at the login screen, but its not on the network.

If you have the serial console enabled, start that session and once connected you need to follow the commands below:

cmd
ch -si 1
login with "local" account
Notice : Windows shell in c:\windows\system32
Run ipconfig /all

You will notice that the IP address listed here is not the same as the one on the web interface, this causes a mismatch

Revert the VM back to the IP that works using the web interface

To check if you have a problem with ghost network cards, which this will usually be, start compmgmt.msc and navigate to device manager, show hidden devices and look at the network card section, you should notice this:



This is an issue with the networks cards where you have multiple network cards that need to be removed.

Create a snapshot of the disk (for security and backup reasons)

Run this:

Invoke-Command {C:\windows\system32\RUNDLL32.exe c:\windows\system32\pnpclean.dll,RunDLL_PnpClean /Devices /Maxclean}

This will then clean up all the ghost network cards......like this.......


Once you have no more ghost network cards you can then update you IP to the new destination and this time it will work.