• Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
logo logo
  • Home
  • Cloud VPS
    • Hong Kong VPS
    • US VPS
  • Dedicated Servers
    • Hong Kong Servers
    • US Servers
    • Singapore Servers
    • Japan Servers
  • Company
    • Contact Us
    • Blog
ENEN
  • 简体简体
  • 繁體繁體
Client Area

PowerShell Command: New-NetFirewallRule

December 16, 2023

PowerShell Command: New-NetFirewallRule

When it comes to managing network security, the Windows PowerShell command New-NetFirewallRule is an essential tool for system administrators. This command allows you to create new inbound and outbound firewall rules on your Hong Kong VPS Hosting server, giving you the ability to control network traffic and protect your server from unauthorized access.

Understanding the New-NetFirewallRule Command

The New-NetFirewallRule command is part of the NetSecurity module in PowerShell. It provides a way to create new firewall rules using a variety of parameters, such as the rule name, action, direction, protocol, local and remote ports, and more. By using this command, you can create rules that are tailored to your specific security needs.

Examples of New-NetFirewallRule Usage

Let’s look at some examples of how the New-NetFirewallRule command can be used to enhance the security of your hosting environment.

Example 1: Allowing Remote Desktop Access

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

This command creates a new inbound firewall rule named “Allow RDP” that allows Remote Desktop Protocol (RDP) traffic on TCP port 3389. This is useful if you need to remotely manage your VPS server.

Example 2: Blocking a Specific IP Address

New-NetFirewallRule -DisplayName "Block IP" -Direction Inbound -RemoteAddress 192.168.1.10 -Action Block

This command creates a new inbound firewall rule named “Block IP” that blocks all traffic from the IP address 192.168.1.10. This can be helpful if you’ve identified a malicious source attempting to access your server.

Example 3: Allowing HTTP and HTTPS Traffic

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

These commands create two new inbound firewall rules that allow HTTP and HTTPS traffic on ports 80 and 443, respectively. This is necessary if you’re running a web server on your cloud hosting platform.

Advanced Usage of New-NetFirewallRule

The New-NetFirewallRule command also supports advanced features, such as specifying the interface type, creating rules for specific profiles (domain, private, public), and setting rule group names for easier management.

Example: Creating a Rule for a Specific Profile

New-NetFirewallRule -DisplayName "Allow SQL" -Direction Inbound -Protocol TCP -LocalPort 1433 -Action Allow -Profile Domain

This command creates a new inbound firewall rule named “Allow SQL” that allows traffic on TCP port 1433 for SQL Server, but only when the server is connected to a domain network. This adds an extra layer of security by ensuring the rule is not applied to public or private networks.

Conclusion

The New-NetFirewallRule PowerShell command is a powerful tool for managing the security of your Hong Kong VPS Hosting server. By understanding how to use this command effectively, you can create custom firewall rules that protect your server from unauthorized access and ensure that only legitimate traffic is allowed. Whether you’re allowing remote management, blocking malicious IP addresses, or managing web server traffic, the New-NetFirewallRule command provides the flexibility and control needed to maintain a secure hosting environment.

In summary, the New-NetFirewallRule command is an essential part of any system administrator’s toolkit. By incorporating relevant examples and code samples, we’ve demonstrated how this command can be used to enhance the security of your VPS. Remember to always test your firewall rules in a controlled environment before applying them to a production server to avoid any unintended consequences.

Recent Posts

  • How to Manage Services with systemd on Debian: Theory and Best Practices
  • Debian Server Security Hardening: Best Practices and Core Theory
  • How to Monitor System Resources on a Debian Server: Theory and Best Practices
  • Debian Server Performance Tuning: Best Practices and Core Theory
  • How to Check Logs on a Debian Server

Recent Comments

No comments to show.

Knowledge Base

Access detailed guides, tutorials, and resources.

Live Chat

Get instant help 24/7 from our support team.

Send Ticket

Our team typically responds within 10 minutes.

logo
Alipay Cc-paypal Cc-stripe Cc-visa Cc-mastercard Bitcoin
Cloud VPS
  • Hong Kong VPS
  • US VPS
Dedicated Servers
  • Hong Kong Servers
  • US Servers
  • Singapore Servers
  • Japan Servers
More
  • Contact Us
  • Blog
  • Legal
© 2026 Server.HK | Hosting Limited, Hong Kong | Company Registration No. 77008912
Telegram
Telegram @ServerHKBot