All Products
Search
Document Center

Simple Application Server:Enable or disable the system firewall in a Linux server

Last Updated:Aug 12, 2024

A firewall is a technology that helps a computer build a relatively isolated protective barrier between internal networks and external networks to protect data. If you enable a firewall for a simple application server and configure rules to block external access, you may be unable to connect to the server. This topic describes how to enable or disable the system firewall in a Linux simple application server.

Procedure

Run commands that are suitable for the Linux distribution of your instance.

CentOS 7/Red Hat 7/Alibaba Cloud Linux 2

  • Enable the system firewall.

    systemctl start firewalld.service
  • Disable the system firewall.

    systemctl stop firewalld.service
  • Check the status of the system firewall.

    firewall-cmd --state

Ubuntu

  • Enable the system firewall.

    ufw enable
  • Disable the system firewall.

    ufw disable
  • Check the status of the system firewall.

    ufw status

Debian

By default, no firewall is installed on Debian. If a firewall is installed on Debian, you can delete all firewall rules to remove traffic blocking.

Note

Before you delete all firewall rules, back up the rules.

  1. Run the following commands to back up firewall rules:

    touch [$Iptables]
    iptables-save > [$Iptables]
    Note

    Replace the [$Iptables] variable with the actual directory in which you want to save the firewall rule backup file.

  2. Run the following command to delete all firewall rules:

    iptables -F