Finds the Network Interface Card (NIC) and associated Network Security Group (NSG) for a VM given its public IP address.
Scanned 9/3/2026
Install to Claude Code
npx -y skills add fabioc-aloha/Alex_Skill_Mall --skill lookup-nsg --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Lookup Nsg?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/fabioc-aloha-lookup-nsg)More formats (shields.io, HTML) on the badges page.
---
name: lookup-nsg
description: "Finds the Network Interface Card (NIC) and associated Network Security Group (NSG) for a VM given its public IP address."
lastReviewed: 2026-04-30
---
# Skill: NSG Lookup
Finds the Network Interface Card (NIC) and associated Network Security Group (NSG) for a VM given its public IP address.
## Step 1 — Find the Public IP Resource
Run via PowerShell:
```powershell
Search-AzGraph -Query "resources | where type =~ 'microsoft.network/publicipaddresses' | where properties.ipAddress == '<IP_ADDRESS>' | project publicIpName=name, resourceGroup, subscriptionId, ipAddress=properties.ipAddress, attachedResource=properties.ipConfiguration.id"
```
Replace `<IP_ADDRESS>` with the user's IP. If no results, tell the user the IP was not found and ask them to verify.
## Step 2 — Look Up the NIC and NSG
Extract the NIC resource ID from `attachedResource` by removing the `/ipConfigurations/...` suffix. Then:
```powershell
Search-AzGraph -Query "resources | where type =~ 'microsoft.network/networkinterfaces' | where id == '<NIC_RESOURCE_ID>' | project nicName=name, nicNsgId=properties.networkSecurityGroup.id, subnetId=properties.ipConfigurations[0].properties.subnet.id"
```
## Step 3 — Present Results
Show a summary table:
| Property | Value |
|----------|-------|
| **Public IP** | (ip address) |
| **Public IP Resource** | (name) |
| **Resource Group** | (resource group) |
| **Subscription** | (subscription id) |
| **NIC Name** | (nic name) |
| **Associated NSG** | (nsg id, or "None") |
| **Subnet** | (subnet id) |
If the NIC has **no NSG**, warn the user it is unprotected.
Extract the **NSG name**, **resource group**, and **subscription ID** from the results to pass into the NSG Remediation skill.
Is this your skill, or is something wrong with this listing? . Author removals are honored within 72 hours.
No comments yet. Be the first to comment!