6

How to Restore Connection After Accidentally Disabled NIC on Azure VM

 3 years ago
source link: https://edi.wang/post/2020/8/2/how-to-restore-connection-after-accidentally-disabled-nic-on-azure-vm
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How to Restore Connection After Accidentally Disabled NIC on Azure VM

Sunday, August 2, 2020 China Standard Time - 214 Reads

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
img-1836c624-78fa-4de3-bd00-bbf889714db3.png

Boom, I lost my server.

img-4711dc37-a93a-460f-ab17-26014b00f773.png

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. " 

img-1af9be76-0aa2-4248-875d-b487bb74e541.png

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.

img-3133193a-5cea-4062-a116-7cfc749494f1.png

Now, a new channel named Cmd0001 is created.

img-031fe4c8-bf62-4b26-9163-a9cc4a446c1b.png

Enter ch -si 1 to go to that channel.

img-c7df986d-c3b4-45b5-8389-41af07b2e32e.png

Press Enter to continue.

img-79134b71-80f4-49aa-9a7e-007cb58dd187.png

Login to your VM's with your VM's credential.

img-f7f4a2b3-1068-4521-83bc-c6f999d550cb.png

Now, this is the actual cmd running on your VM. We can now enable the NIC.

netsh interface set interface "Ethernet" enable
img-96753006-6fcb-45f8-bbf6-03a6bd217def.png

I am now able to RDP into the VM again!

What About Linux

Well, Microsoft Loves Linux:

img-e67ca204-1f13-4731-b813-7e415a86a151.png

Reference: https://channel9.msdn.com/Shows/Azure-Friday/Troubleshoot-and-diagnose-Azure-Virtual-Machines-with-Serial-Console


This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License



About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK