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:
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
You saved the day. Thank you.
You save my day!!
Thanks so much !
Thanks! Lifesafer.
What an absolute HERO
Thank you genius. As another colleague at Microsoft said, there is no such thing as enabling the NIC. Love you.
Great Blog , Helped a lot ...
You rock!!!! I accidentally disabled the NIC and this literally saved my ass. Step by step spot on!