How Do I Disable a Linux ECS Firewall and Add a Port Exception on a Linux ECS Firewall?
Scenarios
This section describes how to disable a Linux ECS firewall and add a port exception on a Linux ECS firewall.
Enabling a firewall and configuring a security group protect your ECSs. If you disable a firewall, exercise caution when you enable ports in the security group.
Disabling a Firewall
Run the following command to disable the firewall based on the ECS OS:
Adding a Port Exception on a Firewall
- CentOS 6
- CentOS 7
- Check the firewall status.
or
firewall-cmd --state
- If the firewall is disabled, run the following command to enable it:
If "Failed to start firewalld.service: Unit is masked." is displayed, run the systemctl unmask firewalld command first and then run the preceding command again to enable the firewall:
- Run the following command to check whether the firewall is enabled:
Information similar to the following is displayed:
[root@ecs-centos7 ~]# firewall-cmd --state running
- For example, to add TCP port 23, run the following command:
firewall-cmd --zone=public --add-port=23/tcp --permanent
The configuration is correct if the command output is as follows:
[root@ecs-centos7 ~]# firewall-cmd --zone=public --add-port=23/tcp --permanent success
- Reload the policy configuration for the new configuration to take effect.
- View all enabled ports.
[root@ecs-centos7 ~]# firewall-cmd --list-ports 23/tcp
- (Optional) Configure the firewall to automatically start upon ECS startup.
systemctl enable firewalld.service
Check whether automatic firewall startup is enabled.
systemctl is-enabled firewalld.service;echo $?
The configuration is correct if the command output is as follows:
[root@ecs-centos7 ~]# systemctl is-enabled firewalld.service;echo $? enabled 0
To disable automatic firewall startup, run the following command:
systemctl disable firewalld.service
- Check the firewall status.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.