How to restrict virtual directory access to specific IP IIS7.5

I checked google but couldn't find anything about that. How is it possible to restrict virtual directory access to specific IP Address on iis7.5?


In IIS 7.0 a "security" element was added to the web.config schema. It has a child element "ipSecurity" which allows IP-based restrictions. An address to block is listed with the "add" element, or you can set "allowUnlisted" to false (default is true) and the effect is reversed to allow the listed addresses. The following placed in the directory you want to protect will restrict access to localhost and the 192.168.0.0/24 network:

   <system.webServer>
      <security>
         <ipSecurity allowUnlisted="false">
            <clear />
            <add ipAddress="127.0.0.1" />
            <add ipAddress="192.168.0.1" subnetMask="255.255.255.0" />
         </ipSecurity>
      </security>
   </system.webServer>

Note that using this feature requires the "IP and Domain Restrictions" IIS role service to be installed. For more details, see the IIS Configuration Reference.