Normally, we uses cloud based VMs through SSH or RDP, so a network connection is necessary for connecting to the VM. But what if you accidentally disabled the NIC on your cloud VM? You may want to call Azure Support or find a previous snapshot for restoring VM. That's not necessary! Azure can help you restore your NIC by yourself in a few steps.
Experiment
I created a Windows Server 2019 VM on Azure, and disabled it's only NIC.
netsh interface set interface "Ethernet" disable
Boom, I lost my server.
Because the NIC is disconnected, so neither can I RDP into the VM nor using WinRM over PowerShell. It is just gone.
Restoring NIC using Serial Console
Actually, there's still a chance in situations like this. In Azure Portal, go to the VM's management screen, and click the "Serial console" menu.
"The Serial Console in the Azure portal provides access to a text-based console for virtual machines (VMs) and virtual machine scale set instances running either Linux or Windows. This serial connection connects to the ttyS0 or COM1 serial port of the VM or virtual machine scale set instance, providing access independent of the network or operating system state. "
Now, a console screen is shown on the Azure Portal, this is the Serial Console itself, not from the VM, we will use it to go to VM's cmd shell. Enter cmd
.
Now, a new channel named Cmd0001
is created.
Enter ch -si 1
to go to that channel.
Press Enter
to continue.
Login to your VM's with your VM's credential.
Now, this is the actual cmd
running on your VM. We can now enable the NIC.
netsh interface set interface "Ethernet" enable
I am now able to RDP into the VM again!
What About Linux
Well, Microsoft Loves Linux:
Mark
Thanks for this tech note. It is very helpful. Some other posts on this topic neglect to put the double quotes around the interface name. In my case I had to restore "Ethernet 2". There was another resource, "Ethernet 3", and it didn't work, but it didn't matter, "Ethernet 2" was back and RDP worked again. For interests sake, here is the Ethernet 3 error. It's a CISCO VPN adapter. C:\Windows\system32>netsh interface set interface "Ethernet 3" enable The system cannot find the file specified.
Microsoft itself is not very helpful here: they suggest changing IP adresses, making new NIC's etc none of which worked
Pratap
You saved the day. Thank you.
cloudswx
You save my day!!
Steph-FR
Thanks so much !
Gus
Thanks! Lifesafer.
Daniel
What an absolute HERO
Lucas-BO
Thank you genius. As another colleague at Microsoft said, there is no such thing as enabling the NIC. Love you.
Abraham
Great Blog , Helped a lot ...
Pink whale
You rock!!!! I accidentally disabled the NIC and this literally saved my ass. Step by step spot on!
Treble
Incredible! Super Thanks! You help us so much!
Shaukat
Thanks a lot for this detail step by step instructions. I mistakenly disabled ethernet on my VM and was struggling how to enable it as I could not RDP to it. Microsoft docs was not as much helpful as this is.
stu
I am the idiot that did this, and this was a lifesaver - thanks
Stu.
mathieu
what if VM has stopped and we can't restart it + when in serial console it says start vm before you can use serial console?