RDP security on a Windows server: NLA, account lockout and IP restrictions
The Remote Desktop port (3389) is scanned constantly on the internet and is a favorite target for password guessing. In this guide you protect RDP access to your Windows server with layers of defense: a strong password, Network Level Authentication (NLA), account lockout, IP restrictions and a VPN, and you learn how to monitor failed sign-in attempts.
Why layered protection?
Port 3389 on a newly deployed Windows server is usually found by automated scanners within a short time. Attackers try predictable account names such as Administrator with leaked password lists (credential stuffing) and brute force. Pre-authentication vulnerabilities seen in RDP in the past (e.g. BlueKeep, which affected older Windows versions) have also allowed unpatched servers to be compromised without a password ever being asked.
No single measure is enough: a password can leak, a lockout policy lets an attacker lock you out of your own account, and an IP restriction can lock you out when you work from a changing address. The layers below cover each other's weaknesses, and the checklist at the end lets you verify where you stand.
Before you start making changes, open the VNC Console in the client area once to confirm you can sign in as Administrator, and take a snapshot with the Snapshots tool. If a firewall or registry mistake cuts off your RDP access, you can recover through the console (see VNC Console and snapshots).
Authentication: strong passwords, NLA and account lockout
A strong, unique password
The panel's Windows password rule requires at least 8 characters and at least three of the following: uppercase letters, lowercase letters, digits and symbols; that is only a minimum. For an RDP account exposed to the internet, choose a randomly generated password of at least 16 characters that you use nowhere else, and keep it in a password manager. Change the password with the Reset Root Password tool in the client area: the panel logs in to the server with the stored password, and a password changed inside Windows makes later panel resets fail.
Network Level Authentication (NLA)
NLA verifies the client's identity with the CredSSP protocol before the sign-in screen opens. An unauthenticated connection cannot create a sign-in screen or a user session on the server, which reduces both resource usage and the pre-authentication attack surface. In the graphical interface, open System Properties with sysdm.cpl and, on the Remote tab, check the box that allows connections only from computers using Network Level Authentication. With PowerShell:
# Show the current state (1 = NLA required)
(Get-CimInstance -Namespace root\cimv2\TerminalServices -ClassName Win32_TSGeneralSetting -Filter "TerminalName='RDP-tcp'").UserAuthenticationRequired
# Require NLA and check the registry value
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name 'UserAuthentication' -Value 1
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name 'UserAuthentication'If the first command returns 1, NLA is required. The change applies to new connections; if you do not see the effect, restart the server. Current versions of Windows App, mstsc and FreeRDP support NLA.
Account lockout policy
A lockout policy slows down password guessing by making an account unusable for a while after a set number of failed attempts. The example below locks an account for 30 minutes after 5 failed attempts within 15 minutes:
net accounts /lockoutthreshold:5
net accounts /lockoutwindow:15
net accounts /lockoutduration:30
# Show the current policy
net accountsYou can see the same settings in Local Security Policy, opened with secpol.msc, under Account Policies → Account Lockout Policy: Account lockout threshold, Account lockout duration and Reset account lockout counter after.
How the built-in Administrator account is affected by this policy depends on the Windows version and local policy. On older versions this account usually is not locked out, while on newer versions, and with updates, the Allow Administrator account lockout policy determines the behavior. Check the setting on your server in secpol.msc, and because lockout also lets an attacker lock you out of your account, always combine this layer with IP restrictions.
Restrict access by IP address
The most effective layer is making sure that only your own addresses can reach port 3389. The Remote Desktop rules in Windows Defender Firewall (the User Mode TCP and UDP inbound rules) are open to every address by default, so narrow their scope. In the graphical interface, go to wf.msc → Inbound Rules → the relevant rule → the Scope tab, select These IP addresses under Remote IP address and add your addresses.
In PowerShell, the display name of the rule group depends on the UI language: -DisplayGroup 'Remote Desktop' works on an English interface, while a Turkish interface shows the group under a different name. The commands below use the group ID, which is the same in every language:
# 1) The address you are connected from, as the server sees it
Get-NetTCPConnection -LocalPort 3389 -State Established | Select-Object RemoteAddress
# 2) The Remote Desktop rules and the localized group name
Get-NetFirewallRule -Group '@FirewallAPI.dll,-28752' | Format-Table DisplayName, DisplayGroup, Enabled
# 3) Limit access to your own address and your office network
Set-NetFirewallRule -Group '@FirewallAPI.dll,-28752' -RemoteAddress 203.0.113.10, 198.51.100.0/24
# 4) Verify the result
Get-NetFirewallRule -Group '@FirewallAPI.dll,-28752' | Get-NetFirewallAddressFilter | Select-Object InstanceID, RemoteAddress
# 5) Find other enabled inbound rules that open 3389
Get-NetFirewallPortFilter | Where-Object { $_.LocalPort -contains '3389' } | Get-NetFirewallRule |
Where-Object { $_.Enabled -eq 'True' -and $_.Direction -eq 'Inbound' } | Format-Table DisplayName, DisplayGroup, ActionBefore narrowing the scope, confirm the address you are connected from with the first command. If the address of your home or mobile internet connection can change, use a static address, an office range or a VPN. If you enter the wrong address, your RDP connection drops; in that case you can remove the restriction from the VNC Console with Set-NetFirewallRule -Group '@FirewallAPI.dll,-28752' -RemoteAddress Any.
The restriction covers only the rules in this group. If another rule for 3389 was added manually earlier and is open to every address, your restriction has no effect; the last command lists such rules, and its output should show only the Remote Desktop rules.
RDP behind a VPN, and changing the port
Hide 3389 from the internet entirely with a VPN
If several people connect from different, changing addresses, the cleanest solution is to put RDP behind a VPN. A WireGuard or OpenVPN tunnel can run on a separate Linux server or on your office gateway. On the Windows server, you then use the command above to narrow the scope of the Remote Desktop rules to the VPN server's public IP address or, if the server is connected to the VPN as a peer, to the VPN's internal network (e.g. 10.8.0.0/24). Port 3389 then does not appear open on the internet, and giving a new user access becomes a matter of defining a new peer or account in the VPN rather than changing the firewall.
Changing the RDP port: obscurity, not security
Changing the port reduces the log noise generated by automated scanners, but a full port scan finds RDP again quickly, so treat this step only as an addition to the other layers. To avoid clashing with Windows' ephemeral port range (49152–65535), pick a port below that range that no other service uses. Open the firewall rule for the new port first, then change the port and restart the server; if you do it the other way around, you lose your connection. The steps are also described in the Microsoft documentation:
$port = 40125
# First open the firewall rules for the new port
New-NetFirewallRule -DisplayName "RDP TCP $port" -Direction Inbound -Protocol TCP -LocalPort $port -Action Allow -RemoteAddress 203.0.113.10
New-NetFirewallRule -DisplayName "RDP UDP $port" -Direction Inbound -Protocol UDP -LocalPort $port -Action Allow -RemoteAddress 203.0.113.10
# Then change the listening port and restart the server
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name 'PortNumber' -Value $port
Restart-ComputerAfter the restart, connect with mstsc /v:203.0.113.10:40125. The Sign-in Details card and the downloaded .rdp file keep using the default port 3389; if you use the file, add the new port to its address line. If you cannot connect, set PortNumber back to 3389 from the VNC Console and restart the server.
The Administrator account and monitoring failed sign-ins
Do not rename the Administrator account
A common hardening tip is to rename the built-in Administrator account; do not do this on Hostimor servers. Panel tools such as Reset Root Password use the Administrator account and may not work as expected if its name changes. Instead, you can create a separate administrator account for daily work and keep Administrator for emergencies. Because the name of the Administrators group is also localized on a Turkish interface, the command below uses the group's language-independent security identifier (SID):
$pw = Read-Host -AsSecureString 'Password for the new account'
New-LocalUser -Name 'admin2' -Password $pw -FullName 'Backup administrator'
# S-1-5-32-544: the built-in Administrators group (works in any UI language)
Add-LocalGroupMember -SID 'S-1-5-32-544' -Member 'admin2'
Get-LocalGroupMember -SID 'S-1-5-32-544'Monitor failed sign-ins
Every failed sign-in attempt is written to the Security log with event ID 4625. The commands below list the latest failed attempts, the addresses with the most attempts in the last 24 hours, and sessions successfully opened over RDP (4624, logon type 10). If no records match, Get-WinEvent reports "No events were found"; that is not a fault.
# Last 20 failed sign-ins: time, account, source IP
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625} -MaxEvents 20 |
Select-Object TimeCreated, @{n='Account'; e={$_.Properties[5].Value}}, @{n='SourceIP'; e={$_.Properties[19].Value}}
# The 10 addresses with the most attempts in the last 24 hours
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625; StartTime=(Get-Date).AddDays(-1)} |
ForEach-Object { $_.Properties[19].Value } | Group-Object | Sort-Object Count -Descending | Select-Object -First 10 Count, Name
# Successful sign-ins over RDP (logon type 10)
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4624} -MaxEvents 500 |
Where-Object { $_.Properties[8].Value -eq 10 } |
Select-Object TimeCreated, @{n='Account'; e={$_.Properties[5].Value}}, @{n='SourceIP'; e={$_.Properties[18].Value}}
# If the source address is empty with NLA on: event 140 in the RDP connection log
Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-RemoteDesktopServices-RdpCoreTS/Operational'; Id=140} -MaxEvents 20 |
Select-Object TimeCreated, MessageWith NLA on, the source address in a 4625 record can appear empty or as "-" on some systems; in that case the RDP connection log in the last command shows the address. Addresses with constant attempts show why IP restrictions are necessary. If you see an address or time you do not recognize among the successful sign-ins, assume the server may be compromised and follow the steps in the incident response guide.
Updates and checklist
Vulnerabilities in RDP and CredSSP are fixed by the monthly security updates, and on an unpatched server some of the layers above lose their value. Install updates at least once a month, take a snapshot before major updates and plan the restart; see the Windows Server maintenance guide for details. Remember that a snapshot is not a backup; for a backup stored outside the server, see the backup strategy guide.
| Layer | Target state | How to verify |
|---|---|---|
| Password | 16+ characters, unique, set from the client area | Entry in your password manager; panel resets work without errors |
| NLA | Required | UserAuthenticationRequired value is 1 |
| Account lockout | 5 attempts / 15 minutes / 30-minute lockout | net accounts output |
| IP restriction | Remote Desktop rules open only to your addresses | No Any in the Get-NetFirewallAddressFilter output |
| VPN | 3389 reachable only through the VPN | Test-NetConnection fails from outside the VPN |
| Port (optional) | An unused port below 49152 | The PortNumber registry value and the firewall rule |
| Administrator | Not renamed, plus a second administrator account | Get-LocalGroupMember -SID 'S-1-5-32-544' |
| Monitoring | 4625 and 4624 records reviewed weekly | The Get-WinEvent commands |
| Updates | Monthly security updates installed | Windows Update history |
Frequently asked questions
I locked myself out with a firewall or port change. What should I do?
Open the VNC Console from the client area and sign in as Administrator. For a scope mistake, remove the restriction with Set-NetFirewallRule -Group '@FirewallAPI.dll,-28752' -RemoteAddress Any; for a port mistake, set PortNumber back to 3389 and restart. If your account is locked, wait for the lockout duration to pass or sign in with your second administrator account.
Is changing the port alone, or a lockout policy alone, enough?
No. A port change only delays scanners, and a lockout policy used on its own can let an attacker keep your account locked. Build on a strong password and NLA, limit access by IP address or with a VPN, and use the other measures on top of those.
Can I turn off RDP completely?
Yes. If you manage the server only at certain times, you can turn RDP off and enable it when needed; the VNC Console is always available in the client area for emergencies. In-server panel actions such as a password reset run through VMware Tools, not RDP, so do not stop or remove VMware Tools (the VMTools service).
Related articles
Thanks for your feedback!