iis , security , aspnet ,

IP Security - Configure IP address restrictions in Web.Config on IIS

Abhith Rajan Abhith Rajan FollowJanuary 09, 2018 · 2 min read · Last Updated:
Share this

When your website is using some kind of proxy/firewall just like Sucuri to increase the security, you need to make sure that only the allowed ones are accessing the site directly, so that all the requests to the site is going through the firewall.

To ensure this, we use the IP security feature in IIS, in which we can configure which IP's are allowed.

<system.webServer>
   ...
    <security>
      <ipSecurity allowUnlisted="false">
        <clear />
        <add ipAddress="-.-.-.-" subnetMask="-.-.-.-" allowed="true" />
        <add ipAddress="-.-.-.-" subnetMask="-.-.-.-" allowed="true" />
        <add ipAddress="-.-.-.-" subnetMask="-.-.-.-" allowed="true" />
        <add ipAddress="-.-.-.-" subnetMask="-.-.-.-" allowed="true" />
      </ipSecurity>
      ...
    </security
  </system.webServer>

In the above code, we set allowUnlisted attribute to false to prevent access to all IP address unless they are listed. And then we add the allowed IP addresses one by one. eg.

<add ipAddress="192.168.134.0" subnetMask="255.255.254.0" allowed="true" />

Additional Resource

Abhith Rajan
Written by Abhith Rajan FollowBuy me a coffee
Abhith Rajan is an aspiring software engineer with more than 6 years of experience and proven successful track record of delivering technology-based products and services.

Related Stories

Related Services

SmarterASP.net - Unlimited ASP.NET Web Hosting

In hosting, sql-server, aspnet,
ASP.NET Hosting by SmarterASP.net. Unlimited ASP.NET Hosting Plans Starting at $2.95 a month.