How to Configure Windows Firewall on a Windows VPS

Windows Defender Firewall controls which network connections are allowed to and from your server. Properly configuring it is one of the most important steps in securing a new Windows VPS.

Prerequisites

  • Windows Server VPS with Administrator access

Checking Firewall Status

Get-NetFirewallProfile | Select Name, Enabled

Viewing Existing Rules

Get-NetFirewallRule | Where-Object {$_.Enabled -eq "True"} | Select DisplayName, Direction, Action

Allowing a Specific Port (e.g. a Web Application on 8080)

New-NetFirewallRule -DisplayName "Allow App Port 8080" -Direction Inbound -Protocol TCP -LocalPort 8080 -Action Allow

Allowing HTTP and HTTPS (for IIS)

New-NetFirewallRule -DisplayName "Allow HTTP" -Direction Inbound -Protocol TCP -LocalPort 80 -Action Allow
New-NetFirewallRule -DisplayName "Allow HTTPS" -Direction Inbound -Protocol TCP -LocalPort 443 -Action Allow

Restricting a Rule to Specific Source IPs

New-NetFirewallRule -DisplayName "Restrict RDP" -Direction Inbound -Protocol TCP -LocalPort 3389 -RemoteAddress 203.0.113.10 -Action Allow

Blocking a Port

New-NetFirewallRule -DisplayName "Block Port 445" -Direction Inbound -Protocol TCP -LocalPort 445 -Action Block

Blocking SMB (port 445) from the public internet is strongly recommended unless you specifically require external file sharing access.

Removing a Rule

Remove-NetFirewallRule -DisplayName "Allow App Port 8080"

Using the GUI Instead

  1. Open Windows Defender Firewall with Advanced Security
  2. Select Inbound Rules → New Rule
  3. Choose Port, specify TCP/UDP and the port number
  4. Choose Allow the connection
  5. Apply to all profiles or specific ones (Domain, Private, Public)
  6. Give it a descriptive name and finish

Recommended Baseline Configuration for a New VPS

PortServiceRecommendation
3389 (or custom)RDPAllow, restricted to trusted IPs
80 / 443HTTP/HTTPSAllow if hosting a website
445SMBBlock from public internet
1433SQL ServerBlock from public internet, restrict to app servers only

Common Errors

Rule added but connection still blocked — confirm the rule applies to the correct firewall profile (Public profile is typically active on a VPS, not Private/Domain).

Locked out of RDP after a firewall change — use your VPS provider's console access to review and correct firewall rules via PowerShell.

Best Practices

  • Deny by default, allow explicitly only what's needed
  • Restrict administrative ports (RDP, SQL Server) to specific trusted IPs
  • Review firewall rules after installing any new service

FAQ

Is Windows Firewall enough on its own?
It's an essential layer, but should be combined with NLA for RDP, strong passwords, and regular updates — not relied on as the sole security measure.

Related Articles

  • How to Secure RDP on a Windows VPS
  • How to Install IIS on a Windows VPS
  • Windows Server Security Checklist for a New VPS
  • windows firewall, netfirewallrule, windows server security, powershell firewall
  • 0 gebruikers vonden dit artikel nuttig
Was dit antwoord nuttig?

Gerelateerde artikelen

How to Connect to a Windows VPS via Remote Desktop (RDP)

Remote Desktop Protocol (RDP) provides full graphical access to a Windows Server VPS, letting you...

How to Secure RDP on a Windows VPS

RDP's default configuration (standard port, password authentication, unlimited login attempts)...

How to Create a New Administrator User on Windows Server

Using only the built-in Administrator account for all management tasks is risky. Creating a...

How to Install Windows Updates on a Windows VPS

Keeping Windows Server updated is essential for security and stability. This guide covers...

How to Install IIS on a Windows VPS

Internet Information Services (IIS) is Microsoft's web server, built into Windows Server, used...