Configure Windows Firewall
This guide explains how to configure Windows Defender Firewall on your Windows VPS.
Access Windows Firewallβ
Via Control Panelβ
- Press
Win + R - Type
firewall.cpland press Enter - Click Advanced settings in the left menu
Via Windows Defenderβ
- Open Windows Settings (
Win + I) - Windows Security > Firewall & network protection
- Click Advanced settings
Advanced Firewall Interfaceβ
The interface is divided into several sections:
- Inbound Rules: Controls connections to your server
- Outbound Rules: Controls connections from your server
- Connection Security Rules: IPsec and secure tunnels
- Monitoring: Overview of active rules
Create an Inbound Ruleβ
Open a Port (GUI)β
- Click Inbound Rules
- In the right panel, click New Rule...
- Select Port > Next
- Choose TCP or UDP
- Enter the port (e.g.:
25565for Minecraft) - Select Allow the connection > Next
- Check the profiles (Domain, Private, Public) > Next
- Give the rule a name (e.g.: "Minecraft Server")
- Click Finish
Open a Port (PowerShell)β
# Open TCP port 25565 (Minecraft)
New-NetFirewallRule -DisplayName "Minecraft Server" -Direction Inbound -Protocol TCP -LocalPort 25565 -Action Allow
# Open UDP port 25565
New-NetFirewallRule -DisplayName "Minecraft Server UDP" -Direction Inbound -Protocol UDP -LocalPort 25565 -Action Allow
# Open a port range
New-NetFirewallRule -DisplayName "FiveM Ports" -Direction Inbound -Protocol TCP -LocalPort 30120-30130 -Action Allow
Common Ports to Openβ
Game Serversβ
| Service | TCP Port | UDP Port |
|---|---|---|
| Minecraft | 25565 | 25565 |
| FiveM | 30120 | 30120 |
| Garry's Mod | 27015 | 27015 |
| ARK | 7777-7778 | 7777-7778, 27015 |
| Rust | 28015-28016 | 28015-28016 |
Web Servicesβ
| Service | Port |
|---|---|
| HTTP | 80 |
| HTTPS | 443 |
| FTP | 21 |
| MySQL | 3306 |
| RDP | 3389 |
Complete FiveM Exampleβ
# FiveM main port
New-NetFirewallRule -DisplayName "FiveM TCP" -Direction Inbound -Protocol TCP -LocalPort 30120 -Action Allow
New-NetFirewallRule -DisplayName "FiveM UDP" -Direction Inbound -Protocol UDP -LocalPort 30120 -Action Allow
# txAdmin
New-NetFirewallRule -DisplayName "txAdmin" -Direction Inbound -Protocol TCP -LocalPort 40120 -Action Allow
Manage Existing Rulesβ
Via PowerShellβ
# List all inbound rules
Get-NetFirewallRule -Direction Inbound | Format-Table Name, Enabled, Action
# List active rules
Get-NetFirewallRule -Enabled True -Direction Inbound
# Disable a rule
Disable-NetFirewallRule -DisplayName "Rule Name"
# Enable a rule
Enable-NetFirewallRule -DisplayName "Rule Name"
# Delete a rule
Remove-NetFirewallRule -DisplayName "Rule Name"
View Open Portsβ
# View listening ports
netstat -an | findstr LISTENING
# Detailed version with process name
Get-NetTCPConnection -State Listen | Select-Object LocalPort, OwningProcess, @{Name="Process";Expression={(Get-Process -Id $_.OwningProcess).Name}} | Sort-Object LocalPort
Block a Specific IPβ
Via Interfaceβ
- Inbound Rules > New Rule
- Select Custom > Next
- All programs > Next
- Protocol: Any > Next
- Remote IP address: These IP addresses > Add the IP to block
- Block the connection > Next
- Name the rule and finish
Via PowerShellβ
# Block an IP
New-NetFirewallRule -DisplayName "Block IP" -Direction Inbound -RemoteAddress 203.0.113.50 -Action Block
# Block an IP range
New-NetFirewallRule -DisplayName "Block IP Range" -Direction Inbound -RemoteAddress 203.0.113.0/24 -Action Block
Allow an Applicationβ
# Allow a specific application
New-NetFirewallRule -DisplayName "My Application" -Direction Inbound -Program "C:\Path\To\Application.exe" -Action Allow
Firewall Profilesβ
Windows uses three profiles:
- Domain: Enterprise network with Active Directory
- Private: Trusted network (home)
- Public: Untrusted network (default on VPS)
For a VPS, apply rules to the Public profile.
# Create a rule only for Public profile
New-NetFirewallRule -DisplayName "Web Server" -Direction Inbound -Protocol TCP -LocalPort 80 -Action Allow -Profile Public
Reset the Firewallβ
Warning
This will delete all your custom rules!
# Reset to default settings
netsh advfirewall reset
Enable/Disable the Firewallβ
# Disable (not recommended)
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled False
# Enable
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True
# Check status
Get-NetFirewallProfile | Format-Table Name, Enabled
Export/Import Rulesβ
# Export rules
netsh advfirewall export "C:\backup\firewall-rules.wfw"
# Import rules
netsh advfirewall import "C:\backup\firewall-rules.wfw"
Tip
After configuring your rules, always test connectivity from outside to verify that ports are properly open.