BSMBasil Saji Mathew

Guide

How to Block RDP Brute-Force Attacks on Windows Server (Step by Step)

Any Windows server with Remote Desktop (RDP, port 3389) open to the internet is found by scanners within minutes, and then it is hit with automated password guesses all day. This guide shows how to confirm the attack, shrink your exposure, and block the attackers automatically, using only what ships with Windows plus a little scripting.

Step 1: Confirm you are being attacked

Every failed logon is written to the Security log as Event ID 4625. Open Event Viewer, go to Windows Logs, then Security, and filter for 4625. A burst of failures from the same address in a short window is a brute-force attempt. This PowerShell command lists the ten addresses with the most failures in the last hour:

Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625; StartTime=(Get-Date).AddHours(-1)} |
  ForEach-Object { $_.Properties[19].Value } |
  Group-Object | Sort-Object Count -Descending |
  Select-Object -First 10 Count, Name

Run it as Administrator. If you see hundreds of attempts from a handful of addresses, keep reading.

Step 2: Reduce your exposure first

Blocking attackers is a second line of defence. The best protection is not exposing RDP at all:

  • Put RDP behind a VPN or an RD Gateway so port 3389 is never reachable from the internet.
  • Restrict by source address in Windows Defender Firewall: edit the inbound Remote Desktop rule and set the scope to only your office or home IP addresses.
  • Do not rely on changing the port. Scanners find non-standard ports too. It reduces noise, but it is not security.
  • Require Network Level Authentication (NLA) so the server authenticates users before it opens a full session.

Step 3: Set an account lockout policy

Open secpol.msc, then Account Policies, then Account Lockout Policy. A threshold of 5 to 10 invalid attempts with a 15 minute lockout slows guessing a lot. One caution: lockouts can be abused to lock real users out, so pair the policy with source-address blocking rather than relying on it alone.

Step 4: Block repeat offenders automatically

The pattern is simple: count failures per address in a sliding time window, and when an address crosses a threshold, add a firewall rule that blocks it. A single block looks like this:

netsh advfirewall firewall add rule name="Block 203.0.113.50" dir=in action=block remoteip=203.0.113.50

Doing this by hand does not scale, so automate it. Whatever you use, follow these rules so you never lock yourself out:

  • Allowlist your own addresses before anything can block them.
  • Start in observe mode. Log what would have been blocked for a day or two, check the list, then switch on blocking.
  • Expire bans. A ban that lasts hours or days is usually enough, and it keeps the firewall rule list short.
  • Keep an audit log of every block and why.

I built Portcullis, an open-source tool that does this for Windows RDP and Linux SSH. It starts in observe mode, has a web dashboard, and sends alerts to Discord, Telegram or Slack. Its README says plainly what is and is not tested. If you only want detection and alerts, RDP Login Monitor parses the Windows Security log in real time and posts suspicious logins to Discord.

Step 5: Get alerted

Blocking silently is risky: you will not know when a real user is caught or when an attack succeeds. Send an alert on every block, and a louder one if a successful logon (Event ID 4624) follows a run of failures from the same address. That pattern means a guess worked.

Frequently asked questions

Is it safe to leave RDP open to the internet?

Not without protection. Use a VPN or RD Gateway if you can. If you must expose RDP, restrict source addresses, enable NLA, set a lockout policy, use strong unique passwords and block repeat offenders.

Does changing the RDP port stop brute-force attacks?

No. It lowers noise from basic scanners but determined attackers scan every port.

Which event ID shows failed RDP logins?

Event ID 4625 in the Security log. Successful logons are 4624.