Other Articles

Virtual Machine – Protect From Direct Internet Traffic

This check ensures that Azure Virtual Machines are not directly exposed to the public internet. Virtual Machines should not have unrestricted public IP access and must be protected using Network Security Groups (NSGs), Azure Bastion, VPN, or private networking controls.

Check Details

  • Resource: Azure Virtual Machine
  • Check: Ensure Protection From Direct Internet Traffic
  • Risk: Virtual Machines exposed directly to the internet through a public IP address and open inbound ports (such as SSH 22 or RDP 3389) are vulnerable to brute-force attacks, port scanning, credential theft, and unauthorized remote access.

Remediation via Azure Portal

  1. Log in to the Azure Portal. Azure Portal dashboard
  2. Navigate to Virtual Machines and select the affected VM. Azure Virtual Machines list
  3. In the left-hand menu, select Networking. Virtual Machine networking settings
  4. Review whether a Public IP address is associated with the VM.
  5. If a Public IP is attached:
    • Disassociate or remove the Public IP address. Virtual Machine disable public ip
    • Ensure inbound rules do not allow 0.0.0.0/0 access to management ports.
    • Use Azure Bastion or VPN for secure remote access.
  6. Click Save after applying the necessary configuration changes.

Remediation via Azure CLI

  1. Open Azure Cloud Shell or a local terminal with Azure CLI installed. Azure Cloud Shell
  2. Check if the Virtual Machine has a Public IP associated:
    az vm list-ip-addresses \
     --resource-group <resource-group> \
     --name <vm-name>
    
  3. Remove the Public IP address from the VM network interface:
    az network nic ip-config update \
     --resource-group <resource-group> \
     --nic-name <nic-name> \
     --name ipconfig1 \
     --remove publicIpAddress
    
  4. Verify that the Public IP is removed:
    az vm list-ip-addresses \
     --resource-group <resource-group> \
     --name <vm-name> \
     --query "[].virtualMachine.network.publicIpAddresses"
    

Replace <resource-group>, <vm-name>, and <nic-name> with your actual values.