Search code examples
azureazure-nsg

How to block internet for everyone except for one single IP in Azure VM


I have a requirement on Azure VM wherein I want to block internet access to all the IP's except for 1 single IP(which would be mine).

I'm able to block internet access for everyone by creating a Deny OutBound rule for everyone. However, when I'm creating an Allow rule with my public address with a higher priority, I'm still unable to access Internet. My understanding is that the first rule will block internet for everyone and the second rule(with higher priority) will only allow my IP to have internet access.

Can someone please check and let me know what I'm doing wrong here?

I'm attaching the screenshot of my OutBound rules.

enter image description here


Solution

  • In the outbound port rule section, the source address is the IP address of your Azure VM and destination is the target you want to reach, so add your IP address there (in the images below the target IP would be 142.250.185.110)

    enter image description here

    By the way, a nice tool to check your connectivity in Azure is "Network Watcher" - search for it in the Azure Portal, then go to "IP flow verify", enter your target VM and the destination (remote) target you want to reach. Network watcher tells you if the request would go through and if not, which rule is blocking it:

    enter image description here