IIS Dynamic IP Restrictions (DIPR) is a built-in IIS module that automatically blocks IP addresses based on request rate and concurrent connections. It operates at the IIS kernel level, blocking abusive traffic before any application code runs. This protects all resources including pages, APIs, static assets, images, CSS, and JavaScript files.
The Contensive upgrade script configures Dynamic IP Restrictions automatically for every IIS site during installation and upgrades.
If Dynamic IP Restrictions is causing problems after installation, run this PowerShell command on the server to immediately disable it for a site. Replace YourSiteName with the IIS site name (which is the Contensive app name).
Import-Module WebAdministration
$siteName = "YourSiteName"
Set-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName" -filter "system.webServer/security/dynamicIpSecurity/denyByRequestRate" -name "enabled" -value "False"
Set-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName" -filter "system.webServer/security/dynamicIpSecurity/denyByConcurrentRequests" -name "enabled" -value "False"
This takes effect immediately with no IIS restart required. All traffic will be allowed through as it was before the upgrade. To disable it for every site on the server at once:
Import-Module WebAdministration
Get-Website | ForEach-Object {
$s = $_.Name
Set-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$s" -filter "system.webServer/security/dynamicIpSecurity/denyByRequestRate" -name "enabled" -value "False"
Set-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$s" -filter "system.webServer/security/dynamicIpSecurity/denyByConcurrentRequests" -name "enabled" -value "False"
Write-Host "Disabled DIPR for $s"
}
Note that the next Contensive upgrade will re-enable Dynamic IP Restrictions with the default settings unless the upgrade script is also modified.
Dynamic IP Restrictions monitors two metrics per IP address:
When either threshold is exceeded, the IP is temporarily blocked. The block is released automatically when the request rate drops below the threshold. No manual intervention is required.
Blocked connections are silently dropped (the Abort deny action). The client receives no response at all, which is the preferred behavior for scanners and bots because it gives them no information about the server.
The Contensive upgrade script applies these settings to each IIS site:
| Setting | Default Value | Description |
|---|---|---|
| Request rate limit | 200 requests per 10 seconds | Maximum requests from a single IP in a 10-second window |
| Concurrent connection limit | 25 | Maximum simultaneous connections from a single IP |
| Deny action | Abort (silent drop) | How blocked requests are handled |
These defaults are designed to be permissive enough for legitimate users while blocking vulnerability scanners and rapid-fire bots. Legitimate users rarely exceed 5-10 requests per second sustained. Automated scanners like Nikto typically run at 50-200+ requests per second.
To change the request rate threshold, open IIS Manager and navigate to your site. Double-click IP Address and Domain Restrictions, then click Edit Dynamic Restriction Settings in the Actions panel.
The two rate settings work together:
For example, 200 requests with a 10000 millisecond (10 second) period means 200 requests per 10 seconds, or approximately 20 requests per second.
To make the limit stricter, reduce the number of requests or reduce the time period. To make it more permissive, increase either value.
Tuning guidance:
$siteName = "YourSiteName"
Set-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName" `
-filter "system.webServer/security/dynamicIpSecurity/denyByRequestRate" `
-name "maxRequests" -value 300
Set-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName" `
-filter "system.webServer/security/dynamicIpSecurity/denyByRequestRate" `
-name "requestIntervalInMilliseconds" -value 10000
Concurrent connection limiting catches slow-rate scanners that maintain many open connections simultaneously. The default limit is 25 concurrent connections per IP.
To adjust, use the same Edit Dynamic Restriction Settings dialog in IIS Manager and change the Maximum number of concurrent requests value.
$siteName = "YourSiteName"
Set-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName" `
-filter "system.webServer/security/dynamicIpSecurity/denyByConcurrentRequests" `
-name "maxConcurrentRequests" -value 50
To disable rate limiting entirely for a site, set the enabled property to False for both restriction types.
Open IP Address and Domain Restrictions for the site, click Edit Dynamic Restriction Settings, and uncheck both options.
$siteName = "YourSiteName"
# Disable request rate limiting
Set-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName" `
-filter "system.webServer/security/dynamicIpSecurity/denyByRequestRate" `
-name "enabled" -value "False"
# Disable concurrent connection limiting
Set-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName" `
-filter "system.webServer/security/dynamicIpSecurity/denyByConcurrentRequests" `
-name "enabled" -value "False"
Note that the next Contensive upgrade will re-enable Dynamic IP Restrictions with the default settings. To permanently disable it, the upgrade script must also be modified.
Add static Allow rules for IP addresses that should never be blocked. This is important for office networks, VPN endpoints, monitoring services, Googlebot, and the server's own IP if it makes internal requests.
In IP Address and Domain Restrictions, click Add Allow Entry in the Actions panel. Enter the IP address or range to allow.
$siteName = "YourSiteName"
# Allow a single IP
Add-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName" `
-filter "system.webServer/security/ipSecurity" `
-name "." `
-value @{ipAddress="203.0.113.10"; allowed="True"}
# Allow an IP range using subnet mask
Add-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName" `
-filter "system.webServer/security/ipSecurity" `
-name "." `
-value @{ipAddress="10.0.0.0"; subnetMask="255.0.0.0"; allowed="True"}
Add static Deny rules to permanently block specific IP addresses regardless of their request behavior.
In IP Address and Domain Restrictions, click Add Deny Entry in the Actions panel.
$siteName = "YourSiteName"
Add-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName" `
-filter "system.webServer/security/ipSecurity" `
-name "." `
-value @{ipAddress="198.51.100.50"; allowed="False"}
To remove a block:
Remove-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName" `
-filter "system.webServer/security/ipSecurity" `
-name "." `
-AtElement @{ipAddress="198.51.100.50"}
If your server is behind a load balancer, reverse proxy, or CDN, the IP address seen by IIS is the proxy IP, not the real client. This causes Dynamic IP Restrictions to block the proxy instead of the actual abusive client.
Enable Proxy Mode so IIS reads the real client IP from the X-Forwarded-For header.
In IP Address and Domain Restrictions, click Edit Feature Settings, then check Enable Proxy Mode.
$siteName = "YourSiteName"
Set-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName" `
-filter "system.webServer/security/dynamicIpSecurity" `
-name "enableProxyMode" -value "True"
Warning: Only enable Proxy Mode if you have a trusted proxy in front of your server. Without a proxy, a malicious client can spoof any IP address by forging the X-Forwarded-For header, effectively bypassing all IP-based restrictions.
The deny action controls what happens when an IP is blocked. The default is Abort (silent connection drop).
| Action | HTTP Response | Best For |
|---|---|---|
| Abort | None (connection dropped) | Scanners and bots. Gives the attacker no information. |
| Forbidden | 403 | Informing legitimate users that they were rate-limited. |
| Unauthorized | 401 | Less common. May trigger authentication prompts in browsers. |
| Not Found | 404 | Misleading blocked clients into thinking the resource does not exist. |
$siteName = "YourSiteName"
# Options: AbortRequest, Forbidden, Unauthorized, NotFound
Set-WebConfigurationProperty -pspath "MACHINE/WEBROOT/APPHOST/$siteName" `
-filter "system.webServer/security/dynamicIpSecurity" `
-name "denyAction" -value "Forbidden"
When using Abort mode, blocked connections are not logged in IIS access logs because the connection is dropped before a response is written.
To see what is being blocked:
Dynamic IP Restrictions requires the IIS IP and Domain Restrictions feature to be installed. The Contensive install script checks for this automatically and installs it if missing.
To verify or install manually:
# Check if installed
Get-WindowsFeature Web-IP-Security
# Install if needed
Install-WindowsFeature -Name Web-IP-Security
Open Server Manager, navigate to Add Roles and Features, then Web Server (IIS), Web Server, Security, and check IP and Domain Restrictions.
Dynamic IP Restrictions handles blunt-force rate blocking at the IIS kernel level with no application code involved. The Contensive Abuse Detection addon (when implemented) adds a complementary layer of protection:
| Concern | Handled By |
|---|---|
| Raw request rate and scanner speed | IIS Dynamic IP Restrictions |
| Suspicious URL patterns (script injection, SQL probes, path traversal) | Contensive Abuse Detection addon |
| Persistent block list that survives IIS recycles | Contensive IP Block List table |
| Manual admin blocks with expiration | Contensive admin UI |
Both systems work together. Dynamic IP Restrictions provides immediate, zero-overhead blocking for high-volume attacks. The Abuse Detection addon provides intelligent pattern-based detection that catches low-volume attacks like a single XSS probe in a query string.