Security & hardening
Security & hardeningintermediate15 min read·Updated Sep 10, 2026

Configure Windows Firewall on a Windows VPS

Configure Windows Firewall safely on a Windows Server VPS: check profiles, audit inbound rules, restrict RDP, create narrow port rules, enable firewall logging, test connectivity, and avoid remote lockouts.

Let Raff Guardian keep your Windows server patched and watched.

Raff Guardian installs Windows updates in your maintenance window, restarts stopped services and blocks repeated failed sign-ins. Free for the first 6 months on a Raff Windows server, from $19.99 a month with the licence included.

Start with Raff GuardianExplore Security14-day money-back guarantee

In short

Configure Windows Firewall on a production VPS by keeping every firewall profile enabled, leaving inbound traffic blocked by default, and creating only the exceptions your workload actually needs. Scope rules by profile, protocol, application or port, and trusted source address where possible. Before changing RDP rules remotely, confirm a recovery path. Then test the service, review effective rules, enable useful firewall logging, document the change, and remove temporary rules.

The safest firewall model is default-deny inbound

Windows Firewall is a host-based firewall built into Windows Server. Microsoft’s current guidance keeps the firewall enabled and uses a default block posture for inbound connections, with explicit allow rules for required traffic.

TaskRecommended action
Check firewall stateReview Domain, Private, and Public profiles
Publish a websiteAllow only required HTTP/HTTPS traffic
Administer with RDPRestrict exposure to trusted sources where practical
Run SQL ServerPrefer private/trusted access instead of public TCP 1433
Run SMBKeep TCP 445 off the public internet
Open an application portScope protocol, local port, profile, and remote address
Troubleshoot connectivityConfirm the application is listening before changing the firewall
Audit a production serverReview inbound allow rules and firewall logs

For most Windows Server deployments, Microsoft recommends allowing outbound traffic by default because switching to default-deny outbound requires a complete inventory of every application and service that needs network access. Treat outbound blocking as an advanced policy, not a routine VPS hardening shortcut.

What we tested on Raff

The original lab for this guide was performed on a Raff Windows Server 2025 Datacenter Evaluation VM.

PowerShell output showing Remote Desktop firewall rules with display name, enabled state, direction, action, and profile.

Test environment:

ItemValue
EnvironmentRaff Windows VM
OSWindows Server 2025 Datacenter Evaluation
Build26100
CPU4 vCPU
RAMApproximately 8 GB
Test date2026-05-24
EngineerAybars Altınyay

The lab verified:

  • Windows Firewall profile status;
  • existing Remote Desktop rules;
  • creation of a temporary inbound TCP rule;
  • verification of that rule;
  • cleanup of the temporary rule.

The temporary test used TCP 54321. It did not expose a real production application. This September 2026 refresh preserves those screenshots and tested commands while revalidating Microsoft guidance for production scoping, rule precedence, logging, centrally managed firewall policy, and Windows remote-management rule groups.

Step 1 — Check every Windows Firewall profile

Run PowerShell as Administrator:

Powershell
Get-NetFirewallProfile | Select-Object Name, Enabled, DefaultInboundAction, DefaultOutboundAction, AllowLocalFirewallRules

You should see the three main profiles:

  • Domain;
  • Private;
  • Public.

PowerShell output showing Windows Server 2025 test environment and enabled Windows Firewall profiles on a Raff VPS.

For a production server, keep the firewall enabled on all profiles. Microsoft’s Windows Server 2025 security baseline uses an enabled firewall with a default-deny inbound stance across Domain, Private, and Public profiles.

A value such as NotConfigured in a policy field does not mean the firewall is disabled. Always verify the Enabled state and remember that effective policy can combine local settings with Group Policy or other centralized management.

Verify which network profile is active

Before creating a rule that is limited to one profile, check the current network category:

Powershell
Get-NetConnectionProfile | Select-Object InterfaceAlias, NetworkCategory, IPv4Connectivity, IPv6Connectivity

A firewall rule should normally be enabled only on the profiles where the workload needs it. Avoid using -Profile Any in production simply because it is convenient.

Step 2 — Review existing RDP firewall rules before changing them

Remote Desktop is one of the most sensitive inbound rule groups on a Windows VPS.

Run:

Powershell
Get-NetFirewallRule -DisplayGroup "Remote Desktop" | Select-Object DisplayName, Enabled, Direction, Action, Profile | Format-Table -AutoSize

PowerShell output showing existing Remote Desktop firewall rules on a Windows Server VPS.

To inspect the source-address scope attached to those rules:

Powershell
Get-NetFirewallRule -DisplayGroup "Remote Desktop" | Get-NetFirewallAddressFilter | Select-Object Name, RemoteAddress

Windows Server normally uses TCP and UDP 3389 for direct RDP. Microsoft warns that exposing Remote Desktop directly to the internet increases risk and recommends a VPN when practical; full RDS environments can also use RD Gateway over HTTPS.

Before changing RDP firewall rules on a remote server:

  1. Confirm your current public source IP.
  2. Confirm you have a dashboard/console/recovery path.
  3. Record the existing rules.
  4. Make one change at a time.
  5. Test a second connection before closing the working session.

For general RDP setup, see How to Connect to a Windows VPS via RDP. For multi-user environments, see Multi-User RDP: 2 Admin Sessions vs RDS Session Host.

Step 3 — Understand Windows Firewall rule precedence

Firewall rules are not evaluated by a simple top-to-bottom list.

Microsoft documents these important behaviors:

  1. An explicit allow rule can permit traffic that the default inbound block would otherwise deny.
  2. An explicit block rule takes precedence over a conflicting allow rule.
  3. More-specific rules generally take precedence over less-specific rules, except where an explicit block rule conflicts.
  4. Windows Firewall does not provide administrator-assigned weighted rule ordering.

This matters when troubleshooting. Creating a new allow rule does not necessarily solve the problem if another explicit block rule matches the same traffic.

Check matching block rules as well as allow rules:

Powershell
Get-NetFirewallRule -Enabled True -Direction Inbound -Action Block | Select-Object DisplayName, Profile, Direction, Action

Do not solve a rule conflict by disabling Windows Firewall globally.

Step 4 — Create a safe temporary test rule

The original Raff lab used TCP port 54321 as a disposable demonstration port:

Powershell
New-NetFirewallRule ` -DisplayName "Raff Test Inbound Rule TCP 54321" ` -Direction Inbound ` -Protocol TCP ` -LocalPort 54321 ` -Action Allow ` -Profile Any

Then verify it:

Powershell
Get-NetFirewallRule -DisplayName "Raff Test Inbound Rule TCP 54321" | Select-Object DisplayName, Enabled, Direction, Action, Profile

PowerShell output showing a temporary inbound Windows Firewall rule created for TCP port 54321.

-Profile Any is retained here because it matches the original controlled lab test. Do not copy that scope blindly into production. Production rules should target the profile or profiles where the application actually operates.

Also remember that a firewall rule does not start a service. An application still has to bind and listen on that port.

Check listeners with:

Powershell
Get-NetTCPConnection -State Listen | Select-Object LocalAddress, LocalPort, OwningProcess | Sort-Object LocalPort

If nothing is listening on the intended port, opening the firewall will not make the application reachable.

Step 5 — Remove the temporary test rule

Delete temporary rules as soon as the test is complete:

Powershell
Remove-NetFirewallRule -DisplayName "Raff Test Inbound Rule TCP 54321"

Verify cleanup:

Powershell
if (Get-NetFirewallRule -DisplayName "Raff Test Inbound Rule TCP 54321" -ErrorAction SilentlyContinue) { Write-Output "Test firewall rule still exists" } else { Write-Output "Test firewall rule removed" }

PowerShell output confirming the temporary Windows Firewall test rule was removed.

Temporary exceptions are easy to forget. Use distinctive names and delete them during the same change session.

Step 6 — Build narrower rules for production workloads

Microsoft recommends making inbound exceptions as specific as practical. A useful rule can combine:

  • direction;
  • protocol;
  • local port;
  • application or service;
  • network profile;
  • remote source address;
  • interface or authentication requirements where needed.

Example: public HTTPS service

For a public IIS site using HTTPS:

Powershell
New-NetFirewallRule ` -DisplayName "Allow HTTPS TCP 443" ` -Direction Inbound ` -Protocol TCP ` -LocalPort 443 ` -Action Allow ` -Profile Public

Use the profile that actually matches your network design rather than assuming Public on every server.

Example: application port from one trusted source

Powershell
New-NetFirewallRule ` -DisplayName "Allow App TCP 8080 from Office" ` -Direction Inbound ` -Protocol TCP ` -LocalPort 8080 ` -RemoteAddress 203.0.113.10 ` -Action Allow ` -Profile Public

203.0.113.10 is an example documentation address. Replace it with the real trusted source IP or approved subnet.

Example: scope by application as well as port

If a specific application should own the listener, a program rule can reduce accidental exposure:

Powershell
New-NetFirewallRule ` -DisplayName "Allow Example Service TCP 8443" ` -Direction Inbound ` -Program "C:\Program Files\Example\service.exe" ` -Protocol TCP ` -LocalPort 8443 ` -RemoteAddress 203.0.113.0/24 ` -Action Allow ` -Profile Public

Use the real executable path and vendor-documented port requirements. Microsoft does not support wildcard executable paths in application firewall rules.

Step 7 — Restrict RDP carefully when the source is stable

If administrators connect from a fixed office/VPN IP, source restrictions can reduce who can even reach the RDP service.

Do not disable the existing broad RDP rules until a replacement path is created and tested.

A controlled example for TCP RDP is:

Powershell
New-NetFirewallRule ` -DisplayName "RDP TCP 3389 from Admin IP" ` -Direction Inbound ` -Protocol TCP ` -LocalPort 3389 ` -RemoteAddress 203.0.113.10 ` -Action Allow ` -Profile Public

If you intentionally use RDP over UDP as well, create a matching UDP rule for the same trusted source.

Only after confirming the replacement access path works should you narrow or disable broader RDP allow rules. If the administrator’s public IP changes frequently, use a VPN, RD Gateway, or another controlled administrative access design rather than repeatedly opening 3389 to everyone.

Microsoft’s RD Gateway role provides external RDS access over HTTPS and avoids exposing internal RDP ports directly to end users.

Step 8 — Review common Windows Server ports by exposure, not habit

PortCommon useProduction guidance
TCP/UDP 3389RDPRestrict source where practical; consider VPN/RD Gateway
TCP 80HTTPOpen only for workloads that intentionally serve HTTP
TCP 443HTTPSNormal public web/API port when required
TCP 1433SQL ServerPrefer private/trusted access; do not expose broadly
TCP 445SMBKeep off the public internet
TCP 5985WinRM HTTPAvoid broad public exposure
TCP 5986WinRM HTTPSRestrict to trusted management sources
Custom portsBusiness applicationsFollow vendor requirements and scope narrowly

Do not use a “standard ports” table as permission to open everything. The application’s architecture decides which ports are necessary.

Step 9 — Enable firewall logging for troubleshooting and audit

Microsoft recommends logging dropped packets and successful inbound connections when firewall visibility is important. For production systems, Microsoft also recommends increasing the firewall log size to at least 20 MB and using separate log files per profile.

Example:

Powershell
Set-NetFirewallProfile -Profile Domain ` -LogBlocked True ` -LogAllowed True ` -LogMaxSizeKilobytes 20480 ` -LogFileName "$env:SystemRoot\System32\LogFiles\Firewall\pfirewall_Domain.log" Set-NetFirewallProfile -Profile Private ` -LogBlocked True ` -LogAllowed True ` -LogMaxSizeKilobytes 20480 ` -LogFileName "$env:SystemRoot\System32\LogFiles\Firewall\pfirewall_Private.log" Set-NetFirewallProfile -Profile Public ` -LogBlocked True ` -LogAllowed True ` -LogMaxSizeKilobytes 20480 ` -LogFileName "$env:SystemRoot\System32\LogFiles\Firewall\pfirewall_Public.log"

Review the effective settings:

Powershell
Get-NetFirewallProfile | Select-Object Name, LogAllowed, LogBlocked, LogFileName, LogMaxSizeKilobytes

Firewall logs are useful for answering questions such as:

  • Is Windows dropping the connection?
  • Which source IP is trying to connect?
  • Is the request using the port you expected?
  • Is a new allow rule actually seeing traffic?

For larger environments, forward relevant logs to centralized monitoring rather than relying only on files stored on the server.

Step 10 — Check whether central policy overrides local rules

Domain Group Policy, MDM/CSP policy, and local settings can all affect the effective firewall policy.

Microsoft supports disabling local policy merge in stricter managed environments. When local rule merging is disabled, an administrator can create a local rule but centrally deployed policy may prevent that local rule from becoming effective.

Check the profile view:

Powershell
Get-NetFirewallProfile | Select-Object Name, AllowLocalFirewallRules, AllowLocalIPsecRules

If a server is centrally managed, troubleshoot the effective policy before repeatedly recreating local rules. In a domain environment, production firewall rules should normally be managed through the organization’s intended policy source rather than one-off local changes.

Windows Remote Management and Windows Firewall Remote Management are different rule groups

A common troubleshooting mistake is treating these two built-in rule groups as interchangeable:

Text
Windows Remote Management Windows Firewall Remote Management

They serve different management paths.

Windows Remote Management is associated with WinRM-based remote administration, including PowerShell remoting and management operations that use WinRM. Inspect its rules with:

Powershell
Get-NetFirewallRule -DisplayGroup "Windows Remote Management" | Select-Object DisplayName, Enabled, Direction, Action, Profile

If WinRM is part of your intended management design, enable that built-in group rather than creating an unnecessarily broad custom port rule:

Powershell
Enable-NetFirewallRule -DisplayGroup "Windows Remote Management"

PowerShell remoting over WinRM commonly uses TCP 5985 for HTTP and TCP 5986 for HTTPS. Do not expose either port broadly to the public internet. Restrict remote management to trusted networks, VPN paths, management subnets, or approved source addresses.

Windows Firewall Remote Management is the separate built-in group Microsoft documents for remotely managing Windows Firewall itself. Inspect or enable it with:

Powershell
Get-NetFirewallRule -DisplayGroup "Windows Firewall Remote Management" | Select-Object DisplayName, Enabled, Direction, Action, Profile Enable-NetFirewallRule -DisplayGroup "Windows Firewall Remote Management"

If you searched for a command such as:

Powershell
Get-NetFirewallRule -DisplayGroup "Windows Remote Management"

first decide what you are trying to manage. Use the Windows Remote Management group for WinRM-based administration; use Windows Firewall Remote Management when the requirement is remote administration of the firewall service and its management interfaces.

For remote firewall administration through PowerShell, supported NetSecurity cmdlets can also use a CIM session, for example:

Powershell
Get-NetFirewallRule -CimSession SERVER01

Before enabling either group, verify the active profile, source-network scope, and whether Group Policy or another central policy controls the effective rule set.

Step 11 — Test the service from the correct side of the firewall

Testing only from inside the server can give a false sense of success.

Confirm the server is listening

Powershell
Get-NetTCPConnection -State Listen | Where-Object LocalPort -eq 443

Test from a remote Windows client

Powershell
Test-NetConnection YOUR_SERVER_IP -Port 443

For an IP-restricted rule, run the test from an allowed source and, when safe, from a non-allowed source. The desired result is not simply “the port is open”; it is “the right clients can connect and the wrong clients cannot.”

If the remote test fails, check in this order:

  1. Is the application running?
  2. Is it listening on the expected local address and port?
  3. Does an explicit block rule overlap the allow rule?
  4. Is the rule enabled on the active profile?
  5. Does the rule’s remote-address scope include the client?
  6. Is a central policy overriding the local rule?
  7. Is another network firewall or routing layer involved?

A production firewall workflow should be repeatable

Use this change sequence:

  1. Identify the exact service and business reason.
  2. Confirm its vendor-documented ports and protocols.
  3. Confirm the service is listening.
  4. Identify which clients actually need access.
  5. Check the active network profile.
  6. Preserve a recovery path before changing RDP/admin rules.
  7. Create the narrowest practical rule.
  8. Test from the intended client network.
  9. Check logs if the test fails.
  10. Document the rule name, owner, source scope, port, and reason.
  11. Remove temporary or superseded rules.
  12. Review exposed rules after major application or architecture changes.

For broader host security, pair this workflow with the Windows Server Hardening Checklist.

Use Windows Firewall together with Raff security controls and a documented server-hardening process rather than relying on a single network rule.

Useful Windows Firewall PowerShell commands

List enabled inbound allow rules

Powershell
Get-NetFirewallRule -Enabled True -Direction Inbound -Action Allow | Select-Object DisplayName, Profile, Direction, Action | Sort-Object DisplayName

Show port filters for a rule

Powershell
Get-NetFirewallRule -DisplayName "Rule Name" | Get-NetFirewallPortFilter

Show address filters for a rule

Powershell
Get-NetFirewallRule -DisplayName "Rule Name" | Get-NetFirewallAddressFilter

Find rules by name

Powershell
Get-NetFirewallRule | Where-Object DisplayName -Like "*RDP*"

Disable a rule without deleting it

Powershell
Disable-NetFirewallRule -DisplayName "Rule Name"

Re-enable a rule

Powershell
Enable-NetFirewallRule -DisplayName "Rule Name"

Remove a custom rule

Powershell
Remove-NetFirewallRule -DisplayName "Rule Name"

Open the Advanced Security GUI

Text
wf.msc

PowerShell is useful for repeatability; Windows Defender Firewall with Advanced Security is useful when you need to inspect profile, scope, program, port, and advanced rule properties visually.

Common mistakes make firewall rules broader than intended

Disabling Windows Firewall to troubleshoot an application

Do not turn off the firewall as a production fix. Confirm the listener, rule, profile, address scope, and logs instead.

Using -Profile Any for every production rule

A lab rule can use Any for demonstration, but a production exception should normally be enabled only where the workload requires it.

Creating a narrow RDP allow rule while leaving a broad allow rule enabled

The broad rule still permits traffic. To actually restrict RDP, verify the replacement path and then narrow or disable the broader rule safely.

Forgetting explicit block-rule precedence

An explicit block can override an allow rule. Check for conflicts instead of creating duplicate allow rules.

Opening SQL Server or SMB to everyone

Database and file-sharing protocols should normally be limited to application servers, trusted IPs, private networks, VPN users, or another controlled network path.

Assuming a listening port means the firewall allows it

A listener and a firewall rule are two different conditions. Both must be correct for inbound connectivity.

Assuming a firewall rule proves the application is secure

A firewall reduces network exposure. It does not replace patching, strong authentication, least privilege, application security, monitoring, or backups.

Raff’s recommendation is to keep the rule set small and explainable

For production Windows workloads:

  • keep Windows Firewall enabled on all profiles;
  • preserve the default-deny inbound model;
  • keep outbound allow-by-default unless you operate a managed deny-by-default outbound policy;
  • scope inbound exceptions to the actual application, port, profile, and client sources;
  • reduce direct RDP exposure;
  • keep SMB and database ports away from the public internet;
  • enable firewall logging when the server needs operational visibility;
  • distinguish WinRM rules from Windows Firewall remote-management rules;
  • document every custom rule;
  • clean up test and superseded rules;
  • manage policy centrally when the server belongs to a domain or managed fleet.

The objective is not to have many firewall rules. It is to have a small set of rules that an administrator can explain and validate.

Tested on

Tested on Raff Windows Server 2025 Datacenter Evaluation, build 26100, 4 vCPU, approximately 8 GB RAM, on 2026-05-24 by Aybars Altınyay. The original lab verified firewall profile status, Remote Desktop rules, creation of a temporary TCP 54321 inbound rule, verification of that rule, and cleanup. The September 2026 refresh adds Microsoft-sourced production and remote-management guidance without claiming those additional policy scenarios were re-tested in the lab.

Validation scope

The Windows Firewall rule-precedence model, command-line management examples, WinRM/firewall remote-management group distinction, and current NetSecurity cmdlet behavior were revalidated against Microsoft documentation on September 10, 2026. No fresh Raff lab test is claimed for this refresh.

What's next

Sources

Was this article helpful?

Frequently asked questions

Should I disable Windows Firewall on a Windows VPS?
No. Windows Firewall is enabled by default, and Microsoft’s Windows Server 2025 security baseline keeps the firewall enabled with default-deny inbound behavior. Fix the specific listener or rule instead of disabling the firewall globally.
What does `NotConfigured` mean in `Get-NetFirewallProfile`?
NotConfigured in a policy field does not mean the firewall is off. Effective settings can come from local policy, Group Policy, MDM/CSP policy, and Windows defaults. Check the profile’s Enabled state and the effective rules before diagnosing the firewall.
Does a Windows Firewall allow rule override every block rule?
No. Microsoft documents that an explicit block rule takes precedence over a conflicting allow rule. More-specific rules matter, but explicit block behavior must be checked when troubleshooting rule conflicts.
Is opening a Windows Firewall port enough for an application to work?
No. The service must be running and listening on the expected local address and port. Use Get-NetTCPConnection -State Listen before changing the firewall.
Should RDP port 3389 be open to the entire internet?
Avoid broad public RDP exposure when practical. Restrict RDP to trusted source addresses, use a VPN, or use RD Gateway for an RDS architecture. Microsoft specifically warns that direct internet exposure of Remote Desktop increases risk.
Should Windows Server block outbound connections by default?
Not for most deployments. Microsoft recommends outbound allow-by-default for typical environments because default-deny outbound requires a maintained inventory and explicit rules for every application and service that needs network access.
Should Windows Firewall logging be enabled?
For production troubleshooting and auditing, logging dropped packets and successful inbound connections is useful. Microsoft recommends at least a 20 MB firewall log and separate logs per profile when configuring detailed firewall logging.

Published May 24, 2026 · Updated September 10, 2026

Back to hub

Let Raff Guardian keep your Windows server patched and watched.

Raff Guardian installs Windows updates in your maintenance window, restarts stopped services and blocks repeated failed sign-ins. Free for the first 6 months on a Raff Windows server, from $19.99 a month with the licence included.

14-day money-back guarantee

Related articles