CentOS is our common server image. For example, when we install the pagoda panel, we will give priority to the CentOS system. Although CentOS7 will be banned from updating in 2024, there is no denying that this image is used more frequently in China. Considering the installation of the server, we usually set the firewall. Here we record how to turn on and off and disable the firewall when using CentOS.
The following describes CentOS commands to turn on and off firewalls.
1. Turn on the firewall
Use the following command to open the CentOS firewall:
systemctl start firewalld
This command will start the firewalld service provided by CentOS by default and start protecting the system.
2. Turn off firewall
Use the following command to turn off the firewall of CentOS:
systemctl stop firewalld
This command will stop the firewalld service provided by CentOS by default and stop protecting the system. Please note that your system will become more vulnerable to attacks after the firewall is turned off, so please operate with caution.
3. Disable firewall
Use the following command to disable the firewall of CentOS:
systemctl disable firewalld
This command will disable the firewalld service provided by CentOS by default, so that it will no longer run automatically when the system starts.
4. Enable firewall
Use the following command to enable the firewall of CentOS:
systemctl enable firewalld
This command enables the firewalld service provided by CentOS by default to run automatically when the system starts.
Summary: With the above commands, we can easily turn on, turn off, disable, and enable the CentOS firewall. When using this operating system, be sure to pay attention to network security issues and select appropriate operations as required.