Dela via


How to restrict unwanted IPs to access your site in Azure environment?

This is a very frequently asked question, not just in the Azure world!

How to restrict unwanted IPs to access your site in Azure environment?

There are two parts to it, as listed below:

1. Static IP Restriction - where you know the list of IPs that you would like to restrict.

Follow this blog - https://www.iis.net/ConfigReference/system.webServer/security/ipSecurity  

Command script to enable static IPSecurity on Azure role:
@echo off
@echo
Installing "IPv4 Address and Domain Restrictions" feature

%windir%\System32\ServerManagerCmd.exe -install Web-IP-Security
@echo
Unlocking configuration for "IPv4 Address and Domain Restrictions" feature

%windir%\system32\inetsrv\AppCmd.exe unlock config
-section:system.webServer/security/ipSecurity

2. Dynamic IP Restriction - where you would be able to monitor the unwanted IPs actively and then apply the restriction

Follow this blog - https://learn.iis.net/page.aspx/548/using-dynamic-ip-restrictions