You need to enable JavaScript to run this app.
Elastic Compute Service

Elastic Compute Service

Copy page
Download PDF
Network connection issue
Enabling or disabling the system firewall on a Linux instance
Copy page
Download PDF
Enabling or disabling the system firewall on a Linux instance
This topic describes how to enable or disable the system firewall on a Linux instance.​
  • A firewall is a technology that builds a relatively isolated protective barrier between the internal network and external network of a computer (instance), thereby protecting data and information.​
  • If the instance has the firewall enabled and has configured rules to block external access, remote connection to the instance may fail.​
Prerequisites​
To modify the configuration or data of an instance, we recommend that you create a snapshot to improve fault tolerance and ensure data security.​
Procedure​
  1. Log in to the target instance. For operation details, refer to Logging in to Linux instances.​
  1. Commands to enable or disable the firewall vary based on the Linux system version. Select the corresponding command for your system.​
  • CentOS 5 and CentOS 6​
  • ​
    # Enable the firewall​
    service iptables start​
    # Disable the firewall​
    service iptables stop​
    # Check firewall running status​
    service iptables status​
    ​
  • CentOS 7/Red Hat 7​
  • ​
    # Enable the firewall​
    systemctl start firewalld.service​
    # Disable the firewall​
    systemctl stop firewalld.service​
    # Check firewall running status​
    firewall-cmd --state​
    ​
  • Ubuntu​
  • ​
    # Enable the firewall​
    ufw enable​
    # Disable the firewall​
    ufw disable​
    # Check firewall running status​
    ufw status​
    ​
  • Debian​
  • In Debian systems, you can clear a firewall policy to delete the related blocking rule. The steps are as follows:​
  1. Execute the following commands in sequence to back up the firewall policy.​
  • ​
    touch [$Iptables]​
    iptables-save > [$Iptables]​
    ​
    ​
tip​
[$Iptables] is the backup file address of a firewall policy. Before you clear the firewall policy, back up the policy first.​
  1. Execute the following command to clear the firewall policy.​
  • ​
    iptables -F​
    ​
​
Last updated: 2026.06.18 17:49:51