Blog / Tutorials

Securing RDP on a Windows VPS: Firewall, NLA and Brute-Force Lockout

By the NoctHost TeamNovember 4, 20264 min read

A Windows server with port 3389 open to the internet starts receiving password guesses almost as soon as it has an IP. Bots sweep the whole IPv4 space for RDP all day, and they do not care that your server is new or small.

None of the fixes below need extra software. They take about fifteen minutes in PowerShell, and the first one alone stops nearly all of the noise.

Step 1: Allow RDP Only From Your IP

The strongest single change is to stop the world from reaching port 3389 at all. Windows Firewall already has rules for Remote Desktop; narrow them to the address you connect from:

Set-NetFirewallRule -DisplayGroup "Remote Desktop" -RemoteAddress 203.0.113.10

Replace 203.0.113.10 with your own public IP. Several addresses or a range are fine: -RemoteAddress 203.0.113.10,198.51.100.0/24.

If your home IP changes often, this rule will lock you out the day it changes. Either allow your provider's range, or use Step 5 (a VPN) instead.

Tip: Keep the server page open in another tab before you tighten the firewall. If you lock yourself out, the browser console there still gets you to the Windows desktop without RDP.

Step 2: Make Sure Network Level Authentication Is On

Network Level Authentication (NLA) makes the client prove the password before Windows starts a full desktop session. Without it, every guess costs the server a login screen, and older RDP vulnerabilities become reachable before authentication.

Check it:

(Get-CimInstance -Namespace root/cimv2/TerminalServices -ClassName Win32_TSGeneralSetting -Filter "TerminalName='RDP-tcp'").UserAuthenticationRequired

1 means NLA is on. If you see 0, enable it:

Get-CimInstance -Namespace root/cimv2/TerminalServices -ClassName Win32_TSGeneralSetting -Filter "TerminalName='RDP-tcp'" | Invoke-CimMethod -MethodName SetUserAuthenticationRequired -Arguments @{UserAuthenticationRequired=1}

Every current RDP client supports NLA, so there is no reason to leave it off.

Step 3: Lock Out Repeated Failures

An account lockout policy turns an endless guessing loop into a handful of attempts. Five failures locks the account for fifteen minutes:

net accounts /lockoutthreshold:5 /lockoutwindow:15 /lockoutduration:15

Two things to know before relying on it:

  • On older Windows Server versions the built-in Administrator account is exempt from lockout. Step 1 matters more there.
  • A lockout policy also locks you out if you mistype your password five times. The browser console still works when that happens.

Step 4: Use a Long, Unique Password

Bots try lists of common and leaked passwords. A random password of 20 or more characters from a password manager is effectively out of reach for them. Never reuse the password from another service, and change the one you received at deploy time if you have shared it anywhere.

Step 5: Put RDP Behind a VPN

The cleanest setup is to close 3389 to the internet completely and reach it through a VPN. WireGuard has a Windows client and works well for this: connect the VPN, then RDP to the server's VPN address.

Once the VPN works, restrict the Remote Desktop rule to the VPN subnet:

Set-NetFirewallRule -DisplayGroup "Remote Desktop" -RemoteAddress 10.8.0.0/24

Now port 3389 does not answer anyone on the internet, and the bots move on.

What About Changing the RDP Port?

Moving RDP from 3389 to another port cuts the volume of automated guesses, because most bots only try the default. It does not make the server more secure: anyone scanning all ports finds it in seconds. Treat it as noise reduction on top of Steps 1 to 3, not instead of them.

If you do it, open the new port in the firewall before restarting the service, or you will lock yourself out:

Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name PortNumber -Value 3390
New-NetFirewallRule -DisplayName "RDP 3390" -Direction Inbound -Protocol TCP -LocalPort 3390 -Action Allow -RemoteAddress 203.0.113.10
Restart-Service TermService -Force

Check Who Is Knocking

Failed logons are recorded in the Security log as event 4625. This shows the latest ones:

Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625} -MaxEvents 20 | Format-Table TimeCreated, Message -Wrap

On a server with RDP open to everyone, expect a steady stream of them. After Step 1 the list should go quiet.

Keep Windows Updated

Most serious RDP flaws were fixed by Windows Update long before they were widely exploited. Leave automatic updates on, and let the server reboot when it needs to, at a time you choose under Settings, Windows Update, Advanced options.

What It Costs

None of this needs extra software or a bigger server. On our Windows VPS plans the licence is included in the hourly price, starting with the Standard plan (2 vCPU, 4 GB), and the browser console on the server page is there if a firewall change goes wrong.

Spin one up in about a minute

Email signup, pay with crypto or card, hourly billing. Trying a box costs cents: destroy it when you are done.

Deploy a server

Frequently asked

Is changing the RDP port enough on its own?
No. It reduces automated noise, but a full port scan finds the new port in seconds. Restrict the firewall to your IP or put RDP behind a VPN.
What if I lock myself out after changing the firewall?
Open the server page and use the browser console. It connects to the Windows desktop directly, without RDP, so you can fix the firewall rule.
Do I need NLA if I already restrict RDP to my IP?
Keep it on anyway. It costs nothing, every modern client supports it, and it protects you if the firewall rule is ever loosened by mistake.

Keep reading