Managing Your Server Firewall

A firewall is your server's first line of defence against unauthorised access and network-based attacks. On CyclebreezeHost VPS and dedicated servers, you configure the firewall at the operating system level. This guide covers the two most common tools: UFW (used on Ubuntu and Debian) and firewalld (used on AlmaLinux and CentOS).

Firewall wall between the internet and a VPS server with a port rules table showing ALLOW for ports 22, 80, and 443 in green and DENY for all others in red

Why You Need a Firewall

By default, a fresh Linux server has all ports accessible to the internet. Without a firewall, anyone can attempt to connect to any port on your server. A correctly configured firewall ensures only the services you intentionally expose are reachable.

UFW — Ubuntu and Debian

UFW (Uncomplicated Firewall) is a straightforward command-line tool that manages iptables rules with simple commands.

Check the Current Status

ufw status verbose

If UFW is inactive, the output will say Status: inactive and no rules are in effect.

Basic Setup

Allow the ports your server needs before enabling the firewall, so you do not lock yourself out:

ufw allow 22        # SSH
ufw allow 80        # HTTP
ufw allow 443       # HTTPS

Then enable the firewall:

ufw enable

Type y when prompted. UFW will now be active and start automatically on reboot.

Common UFW Commands

TaskCommand
Allow a portufw allow 3306
Allow a port for TCP onlyufw allow 25/tcp
Block a portufw deny 3306
Delete a ruleufw delete allow 3306
Allow from a specific IPufw allow from 203.0.113.10
Allow from IP to specific portufw allow from 203.0.113.10 to any port 22
List rules with numbersufw status numbered
Delete a rule by numberufw delete 3
Disable the firewallufw disable
Reload rulesufw reload

Changing the SSH Port

If you changed SSH to a non-standard port (e.g., 2222), allow that port and remove the old rule:

ufw allow 2222
ufw delete allow 22
ufw reload

Always test the new port in a second terminal session before closing your existing connection.

firewalld — AlmaLinux and CentOS

firewalld uses zones to group rules. The public zone applies to most server setups.

Check the Current Status

firewall-cmd --state
firewall-cmd --list-all

Allow and Remove Services

firewall-cmd --permanent --add-service=ssh
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload

To allow a specific port number:

firewall-cmd --permanent --add-port=3306/tcp
firewall-cmd --reload

To remove a rule:

firewall-cmd --permanent --remove-port=3306/tcp
firewall-cmd --reload

Block a Specific IP Address

firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="203.0.113.45" reject'
firewall-cmd --reload

Recommended Open Ports by Use Case

Server RolePorts to Allow
Basic web server22 (SSH), 80 (HTTP), 443 (HTTPS)
Mail server22, 25, 80, 143, 443, 587, 993
cPanel/WHM22, 80, 443, 2082, 2083, 2086, 2087
Database server (internal only)22, 3306 from trusted IPs only
Custom SSH portNew SSH port, 80, 443

Recovering from a Lockout

If you accidentally lock yourself out of SSH, use the Console/VNC feature in your CyclebreezeHost Client Area to regain access:

  1. Log in at https://clients.cyclebreezehost.com.
  2. Open your server and click Server Control Panel.
  3. Launch the Console or VNC session.
  4. Log in directly and adjust your firewall rules:
    • UFW: ufw allow 22 && ufw reload
    • firewalld: firewall-cmd --permanent --add-service=ssh && firewall-cmd --reload

For assistance with firewall configuration, contact CyclebreezeHost support at info@cyclebreezehost.com or open a ticket at https://clients.cyclebreezehost.com. Our team is available 24/7.