Allow Remote Desktop Only From Your IP Addresses

Remote Desktop (port 3389) is reachable from the whole internet. Bots constantly try passwords on it. If you always connect from the same addresses (your home, your office, your VPN), you can let only those addresses in. Everyone else is blocked by the Windows firewall before they can try a password.

⚠ Do not lock yourself out

If your address is not on the list, you can no longer connect with Remote Desktop. Check your address at myip.com first. Many home connections get a new address from time to time: add your provider's whole range, or use a VPN with a fixed address. If you lock yourself out, use Console Access under Information for a VPS, or noVNC / IPMI for a dedicated server to undo the change.


With Windows Defender Firewall

Press Windows key + R, type wf.msc and press Enter. Open Inbound Rules and double-click Remote Desktop – User Mode (TCP-In).

Inbound Rules with Remote Desktop - User Mode (TCP-In)

Open the Scope tab. Under Remote IP address, choose These IP addresses.

Scope tab: Remote IP address

Choose Add and type your address, or a whole range such as 198.51.100.0/24.

Adding an IP address

Add all addresses you need and choose OK. The change applies at once; your current session stays connected.

Scope with the allowed address

Do the same for Remote Desktop – User Mode (UDP-In).


With PowerShell

The same with one command (replace the addresses with yours, separated by commas):

Set-NetFirewallRule -DisplayGroup "Remote Desktop" -RemoteAddress 203.0.113.10,198.51.100.0/24

To allow every address again:

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

Related Guides

View all Windows guides

Was this answer helpful? 0 Users Found This Useful (0 Votes)