Setting up cloud firewall rules on Data Mammoth is one of the most important security steps you can take after provisioning a server. A properly configured firewall blocks unwanted traffic at the network level, protecting your server from scanning bots, brute-force attacks, and unauthorized access.
This guide walks you through creating a firewall rule group, adding rules, and applying them to your servers.
Before You Begin
Before creating firewall rules, know which services your server runs and which ports they need:
- SSH — Port 22 (TCP)
- HTTP — Port 80 (TCP)
- HTTPS — Port 443 (TCP)
- MySQL/MariaDB — Port 3306 (TCP)
- PostgreSQL — Port 5432 (TCP)
- Redis — Port 6379 (TCP)
- Custom applications — Whatever port your application listens on
Step 1 — Navigate to Cloud Firewall
The firewall management page displays your existing rule groups (if any) and options to create new ones.
Step 2 — Create a Firewall Rule Group
A rule group is a named collection of firewall rules that can be applied to one or more servers.
Your new rule group is created with no rules — which means all traffic is blocked (default deny). Now you need to add allow rules for the traffic you want to permit.
Step 3 — Add Firewall Rules
Click on your newly created rule group to open it, then click Add Rule.
For each rule, configure the following fields:
Direction
- Inbound — Rules for traffic coming into your server from the internet.
- Outbound — Rules for traffic leaving your server. (Outbound traffic is typically allowed by default.)
Protocol
- TCP — Used by most services (SSH, HTTP, HTTPS, databases).
- UDP — Used by DNS, some game servers, VPN protocols.
- ICMP — Used by ping. Allow this if you want your server to respond to ping requests.
- All — Matches all protocols.
Port
- Enter a specific port number (e.g.,
22). - Enter a port range (e.g.,
8000-9000). - Select All ports if the rule should apply to any port.
Source (for inbound rules)
- Any / 0.0.0.0/0 — Allow traffic from any IP address. Use this for public services like HTTP and HTTPS.
- Specific IP — Allow traffic only from a specific IP address (e.g.,
203.0.113.50/32). Use this for SSH and admin access. - IP range (CIDR) — Allow traffic from a range of IPs (e.g.,
203.0.113.0/24for the entire 203.0.113.x subnet).
Action
- Allow — Permit the matching traffic.
- Deny — Block the matching traffic (usually the default for non-matching rules).
Example: Essential Web Server Rules
Add these rules for a typical web server:
| Direction | Protocol | Port | Source | Action | Purpose |
|---|---|---|---|---|---|
| Inbound | TCP | 22 | Your IP (e.g., 203.0.113.50/32) | Allow | SSH access from your IP only |
| Inbound | TCP | 80 | Any (0.0.0.0/0) | Allow | HTTP web traffic |
| Inbound | TCP | 443 | Any (0.0.0.0/0) | Allow | HTTPS web traffic |
| Inbound | ICMP | All | Any (0.0.0.0/0) | Allow | Ping (optional) |
Click Save or Add Rule after configuring each rule.
Step 4 — Apply the Rule Group to Your Server
After creating your rules, assign the rule group to one or more servers:
The firewall rules take effect within seconds. Your server is now protected.
Alternative: Assign from the Server Detail Page
You can also assign firewall groups from the server's management page:
Step 5 — Verify Your Firewall Rules
After applying rules, verify that they work as expected:
Test Allowed Access
- SSH — Connect via SSH from your allowed IP. If it works, the SSH rule is correct.
- Web — Open your server's IP in a browser (e.g.,
http://203.0.113.10). If the page loads, HTTP is allowed.
Test Blocked Access
- Try accessing a port that should be blocked (e.g., try to connect to port 3306 from the internet). The connection should time out or be refused.
- If you have access from a different IP address (e.g., your phone on mobile data), try SSHing from that IP. It should be blocked if you restricted SSH to your specific IP.
Managing Firewall Rules
Editing Rules
Changes apply instantly to all servers using the rule group.
Reordering Rules
Firewall rules are typically evaluated in order. Rules higher in the list take precedence. Drag rules to reorder them if your firewall supports rule priority.
Deleting Rules
Warning: Deleting an allow rule for SSH may lock you out of your server. Always make sure you have at least one way to access your server before removing access rules.
Unassigning a Rule Group
To remove a firewall rule group from a server:
Warning: Removing all firewall groups may leave your server with no firewall protection (or a default-allow policy, depending on the configuration). Always verify the resulting security posture.
Creating Multiple Rule Groups
Use separate rule groups for different server types:
- "Web Server Rules" — SSH + HTTP + HTTPS.
- "Database Rules" — SSH + database port from specific IPs only.
- "Game Server Rules" — SSH + game-specific ports.
- "Management Only" — SSH only, from specific IPs.
What to Do Next
- Cloud Firewall Best Practices — Advanced security strategies.
- Common Firewall Rules — Pre-built rules for popular services.
- Cloud Firewall vs iptables — Understand when to use each.
- Troubleshooting Cloud Firewall Issues — Fix common firewall problems.