FirewallD is the default firewall management tool for RHEL 7 and Centos 7 systems. Let's learn how to open ports 80 and 43 in FirewallID in this article.
1. What is FirewallD?
FirewallD is the default firewall management tool for RHEL 7 and CentOS 7, replacing Iptables with the following key differences:
- Uses "zones" and "services" instead of "chains" and "rules" in Iptables.
- Manages rule sets in a flexible way, taking effect immediately without breaking existing connections and sessions.
2. How to open ports 80 and 443 in FirewallD
With the firewall, you can open ports either temporarily or permanently. Temporary rules will be removed after the system restarts.
- To open a port temporarily, run the following commands (the port will close again after a system reboot):
firewall-cmd --zone=public --add-port=80/tcp
firewall-cmd --zone=public --add-port=443/tcp - To open a port permanently, run the following commands:
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=443/tcp
Adding --permanent ensures that the rule remains in place even after a system reboot. Next, you need to reload FirewallD to apply the changes. To reload FirewallD, run:
firewall-cmd --reload
Check the rules
After adding the rules, you can run the following command to verify if they have been successfully applied:
firewall-cmd --permanent --zone=public --list-ports
Remove the rules
To remove previously added rules, run:
firewall-cmd --permanent --zone=public --remove-port=80/tcp
firewall-cmd --permanent --zone=public --remove-port=443/tcp
After that, reload FirewallD again for the changes to take effect:
firewall-cmd --reload
Conclusion
Hopefully, with this guide on opening ports 80 and 443 in FirewallD, you now understand the steps clearly and can implement them successfully.