Windows OS Hub
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux

 Windows OS Hub / Windows Server 2025 / Protect Windows Server from DDoS and Brute-Force Attacks with IPBan

May 12, 2026

Protect Windows Server from DDoS and Brute-Force Attacks with IPBan

In this article, we’ll look at how to use the IPBan tool to configure Windows Server host protection against DDoS attacks. The idea is to detect failed logons, untargeted or suspicious traffic in text log files and/or Windows event logs, and block the detected IP addresses using Windows Firewall rules. This will allow you to implement a simple Windows host protection system against DDoS attacks without using additional external security tools.

Contents:
  • How to Install IPBan on Windows Server
  • Block Malicious IP Addresses from IIS Logs in Windows Firewall

In my case, I encountered an abnormally high network interface load on the Windows Server host in the DMZ network running a lightweight web app. This consumed all the available WAN channel bandwidth.

Abnormal LAN interface load on Windows Server caused by DDoS

Using ResMon, I discovered that hundreds of external clients were establishing HTTP sessions with the Windows host simultaneously, which is an unusual pattern for historical web server workloads.

Use Resmon in Windows to view active network connections

The following PowerShell command can be used to show the number of simultaneous network connections to a host via HTTPS:

netstat -ano | findstr :443 |measure

netstat - view iis web server established connections

We will use the open-source tool IPBan (DigitalRuby.IPBan) to block bot IP addresses. IPBan is similar to Fail2Ban, but for Windows. Although IPBan was originally developed to block brute-force attacks on terminal (RDP) servers, it can also be used to protect other Windows services against DDoS attacks.

How to Install IPBan on Windows Server

We’ll use the IPBan tool to parse the web service’s text log files (or events in Event Viewer) and take action when specific count thresholds are reached. This tool uses regular expressions to parse text log files or Windows Event logs, identify recurring malicious patterns, extract the source IP addresses, and block those IPs in Windows Firewall after a defined threshold of failed requests is met.

We use the free version of IPBan, which can be found on the project page https://github.com/DigitalRuby/IPBan. The free version of IPBan only supports command-line management with configuration via a text file.

To install IPBan on Windows from the GitHub repository, run this PowerShell script:

$ProgressPreference = 'SilentlyContinue'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; iex ((New-Object System.Net.WebClient).DownloadString ('https://raw.githubusercontent.com/DigitalRuby/IPBan/master/IPBanCore/Windows/Scripts/install_latest.ps1'))

The script will download the IPBan files to the C:\Program Files\IPBan folder and create a new Windows service.

Install the IPBAN service

The IPBan service settings can be found in the ipban.config file.

ipban.config file

The ipban.config file is an XML file that contains the following sections:

  • LogFilesToParse – rules that define text log files to be parsed, regular expressions for extracting information from them, and patterns for detecting unwanted events.
  • ExpressionsToBlock – it defines patterns and regular expressions to extract suspicious events and IP addresses from Windows Event Logs, which can then be blocked in the Windows Firewall.
  • ExpressionsToNotify – similar to the previous one, but only for notification purposes (without immediately blocking IP addresses).
  • appSettings – this section contains the IPBan service’s basic settings.

XML file with IPban settings

Several rules for tracking failed login attempts are enabled by default in the ipban.config file. For example:

  • Parsing is enabled for the following text logs under the LogFiles section: OpenSSH server on Windows; IPBanCustom (used as a template for configuring your own text log parsing rules), Exchange authentication logs, SmarterMail, MailEnable, Apache logs, and RDWeb login logs.
  • Under the ExpressionsToBlock section, auditing of events in Event Viewer logs for the following services is enabled: RDP login events (find out how to protect against RDP brute-force attacks), Microsoft SQL, PostgreSQL, MSExchange, phpMyAdmin, VNC, RRAS, SVN

Remove rules for all unused services from ipban.config, or use an empty ipban.override.config file as a template for your custom ipban configuration.

I configured the following parameters in the appSettings section:

  • BanTime – the time for which the IP address is blocked in the firewall, after which it is automatically unblocked. I block addresses for 1 day( value="01:00:00:00"/ )
  • Whitelist – a whitelist of IP addresses and subnets that should never be blocked, such as your ISP ranges and customer subnets: value="123.123.0.0/16,111.111.111.11/24"

Set bantime and whitlist IP list

Block Malicious IP Addresses from IIS Logs in Windows Firewall

In my case, the DDoS attack was aimed at a small IIS website that was published on the internet and was running on my Windows Server. Additionally, the Remote Desktop Gateway role is configured on the server used for connecting remote users to internal RDSH.

An active DDoS attack on IIS can be confirmed by the unusually large size of the log files in the C:\inetpub\logs\LogFiles\W3SVC1 directory (each file spans several GB). To make it easier for IPBan to parse the IIS log files, I changed the log format in the IIS Manager console (inetmgr) so that a new log file is created when the specified file size is reached, rather than a new log file being created every day (the default setting). IIS -> Web Site -> Logging -> Select the method that IIS uses to create a new log file -> Maximum file size. Here, we specified 200 MB.

IIS log file

Next, analyse the IIS logs to identify the type of requests that are overloading your site. In my case, the log contained tens of thousands of requests from different IP addresses with an HTTP error code of 405 (Method Not Allowed).

iis log file

I have configured the following rule in the <LogFilesToParse> -> <LogFile> section:

<LogFile>
<Source>IIS405</Source>
<PathAndMask>C:/inetpub/logs/LogFiles/W3SVC1/*.log</PathAndMask>
<FailedLoginRegex>
<![CDATA[
^(?<timestamp_utc>\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s+\S+\s+\S+\s+\S+\s-\s\d+\s-\s(?<ipaddress>\S+).*?\s405\s+\d+\s+\d+\s+\d+$
]]>
<![CDATA[ ^\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\s+\S+\s+\S+\s+\S+\s+-\s+\d+\s+-\s+(?<ipaddress>[^ ]+).*405\s ]]>
</FailedLoginRegex>
<PlatformRegex>Windows</PlatformRegex>
<PingInterval>5000</PingInterval>
<MaxFileSize>100000000</MaxFileSize>
<FailedLoginThreshold>5</FailedLoginThreshold>
<MinimumTimeBetweenFailedLoginAttempts>00:00:5</MinimumTimeBetweenFailedLoginAttempts>
</LogFile>
  • PathAndMask – Path to logs (note that the slashes in the path must be inverted).
  • FailedLoginRegex – contains a regular expression for searching for events with a 405 response code and extracting the IP addresses.
  • FailedLoginThreshold – the threshold for the number of connection attempts before an IP address is blocked.

A different regular expression may be used in your custom case. You can use PowerShell to test the regexp. Copy the access line from the IIS log and check it using your regular expression. (run these tests in PowerShell ISE or VSCode):

$logLine = "2026-05-10 21:17:13 192.168.158.103 POST / - 443 - 95.123.123.12 Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10.15;+rv:128.0)+Gecko/20100101+Firefox/128.0 https://123 405 0 1 172 "
$regex = '^\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\s+\S+\s+\S+\s+\S+\s+-\s+\d+\s+-\s+(?<ip>[^ ]+).*405\s'
if ($logLine -match $regex) {
Write-Host "✓ Match: unwanted IP: $($Matches.ip)" -ForegroundColor Green
} else {
Write-Host "✗ NO MATCH!" -ForegroundColor Red
}

PowerShell: testing regexp rule to extract IP address from IIS logs

You can use this online service to check your regular expression https://regex101.com/

Restart the IPBan service to reload the rules.

Restart-Service ipban

All actions and events performed by IPBan are logged in the logfile.txt file.

IPban log

In my case, a large number of bots also hit non-existent pages that returned a 404 response. I added an additional rule to block them:

<LogFile>
<Source>IIS404</Source>
<PathAndMask>C:/inetpub/logs/LogFiles/W3SVC1/u_extend*.log</PathAndMask>
<FailedLoginRegex>
<![CDATA[
<![CDATA[ ^\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\s+\S+\s+\S+\s+\S+\s+-\s+\d+\s+-\s+(?<ipaddress>[^ ]+).*404\s ]]>]]>
</FailedLoginRegex>
<PlatformRegex>Windows</PlatformRegex>
<PingInterval>5000</PingInterval>
<MaxFileSize>206777216</MaxFileSize>
<FailedLoginThreshold>4</FailedLoginThreshold>
<MinimumTimeBetweenFailedLoginAttempts>00:00:5</MinimumTimeBetweenFailedLoginAttempts>
</LogFile>

To block the IP addresses for which the threshold is exceeded, IPBan creates Windows Firewall rules named IPBan_Block_0, IPBan_Block_1000, etc. As the maximum size of a Windows Firewall rule is limited, a new rule is created for each 1,000 blocked IP addresses.

IPBan_block rules in Windows Firewall

You can use PowerShell to view the list of blocked IP addresses in the IPBan rule.

(Get-NetFirewallrule -DisplayName 'IPBan_Block_1000'|Get-NetFirewallAddressFilter).remoteaddress
(Get-NetFirewallrule -DisplayName 'IPBan_Block_1000'|Get-NetFirewallAddressFilter).remoteaddress |measure

list blocked IPs in firewall

In my case, in less than a day of IPBan operation, nearly 3,000 IP addresses from which DoS attacks originated were blocked. After this, the load on the server’s network interface returned to normal, and the number of active sessions to IIS dropped from several thousand to hundreds.

list active iis connections

Once the blocking time has expired, the IP address will be removed from the rule.

Moreover, it is possible to block spam user agents by using IIS filtering. iismanager -> Request Filtering -> Rules -> Header: user-agent -> Deny strings. According to your IIS log, add all the obvious spam user agent headers (AppleWebKit, Lynx, etc.).

Deny connections for spam user agents using IIS request filtering

IIS will return 404 error to clients whose headers contain such user agents.

Thus, we implemented the simplest protection against DDoS attacks on a Windows web server using the IPBan. Similarly, you can mitigate suspicious traffic by blacklisting IP addresses associated with anomalous request patterns, which can be identified by extending the log analysis to other text or system event logs.

0 comment
0
Facebook Twitter Google + Pinterest
Questions and AnswersWindows Server 2022Windows Server 2025
previous post
How to Force Uninstall ANY Stubborn Program in Windows

Related Reading

How to Move (Migrate) Windows Shares to a...

February 26, 2026

Find a Process Causing High Disk Usage on...

July 16, 2025

SMB over QUIC: Mount File Share over Internet...

December 24, 2025

Automate Software and Settings Deployment with WinGet Configure...

November 20, 2025

Windows: Create (Install) a Service Manually

December 17, 2025

Pin and Unpin Apps to Taskbar in Windows...

March 26, 2026

Mounting NFS Shares in Windows Using the Built-in...

March 26, 2026

Configuring Windows Protected Print Mode (WPP)

May 28, 2025

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • How to Force Uninstall ANY Stubborn Program in Windows

    May 7, 2026
  • How to Safely Disable IPv6 on Windows

    April 30, 2026
  • Updating UEFI Secure Boot Certificates on Windows Devices Explained

    April 20, 2026
  • Security Warnings When Opening RDP Files in Windows 11

    April 17, 2026
  • Find Computers with Pending Reboot Status Using PowerShell

    April 15, 2026
  • Mounting NFS Shares in Windows Using the Built-in Client

    March 26, 2026
  • Monitor Windows Log Files in Real Time with PowerShell

    March 17, 2026
  • Pin and Unpin Apps to Taskbar in Windows 11 via PowerShell

    March 10, 2026
  • Load and Initialize Network Drivers in Windows PE or Recovery Environment

    February 25, 2026
  • How to Set a Custom Drive Icon in Windows

    February 17, 2026

Follow us

  • Facebook
  • Twitter
  • Youtube
  • Telegram
Popular Posts
  • Converting Windows 10 to Enterprise LTSC Without Losing Data
  • How to Remove ‘Some Settings are Managed by Your Organization’ on Windows 11 or 10
  • Remove the Max Path Length Limit (260-Characters) on Windows
  • How to Pause (Delay) Update Installation on Windows 11 and 10
  • How to Cancel Windows Update Pending Restart Loop
  • VMware Workstation: Slow VMs Performance on Windows
  • VPN Error 633: The modem is already in use or not configured
Footer Logo

@2014 - 2026 - Windows OS Hub. All about operating systems for sysadmins


Back To Top