The system firewall controls which network traffic reaches your Simple Application Server. Before enabling the firewall, make sure SSH access is explicitly allowed — otherwise you will be locked out of your server.
Prerequisites
Before you begin, ensure that you have:
A Simple Application Server running Linux
Root or sudo access to the server
CentOS 7, Red Hat 7, and Alibaba Cloud Linux 2
These distributions use firewalld, managed through systemctl and firewall-cmd.
Enable the firewall:
systemctl start firewalld.serviceDisable the firewall:
systemctl stop firewalld.serviceCheck the firewall status:
firewall-cmd --stateExpected output when the firewall is running:
runningExpected output when the firewall is stopped:
not runningUbuntu
Ubuntu uses ufw (Uncomplicated Firewall).
Before enabling ufw, allow SSH traffic to avoid being locked out of your server:
ufw allow sshEnable the firewall:
ufw enableWhen prompted, type y to confirm. Disabling the firewall with ufw disable preserves all configured rules — they take effect again when you re-enable ufw.
Disable the firewall:
ufw disableCheck the firewall status:
ufw statusExpected output when active:
Status: activeExpected output when inactive:
Status: inactiveDebian
By default, no firewall is installed on Debian. If a firewall has been installed, you can remove all firewall rules to stop traffic blocking.
Back up your firewall rules before deleting them.
Back up the current firewall rules. Replace
<backup-file-path>with the path where you want to save the backup file (for example,/tmp/iptables-backup.txt):touch <backup-file-path> iptables-save > <backup-file-path>Delete all firewall rules:
iptables -Fiptables -Fflushes all rules from the active rule chains. Theiptablesmodule itself remains loaded, so this is equivalent to disabling traffic filtering — not uninstalling the firewall.