How to open HTTP port 80 and HTTPS port 443 using firewall-cmd in Redhat 8 Linux

In this article, I show you how to open HTTP port 80 and HTTPS port 443 using FirewallD in Redhat 8 Linux. To run the server the main thing is HTTP port this only interact with the server to get the request. In the following commands will help you to open HTTP and HTTPS protocols in your server.
If you want to know more about FirewallD here you have an article.
Note: You need to run the command as root or via the sudo.
Check the Status of Firewall
Before opening the port check whether the firewall is running or not using the following command.
1 |
firewall-cmd --state |
Check the Current Zone
You want to know in which zone you going to add the open ports 80 and 443. Because it is important to check the zone within which you wish to open ports 80 and 443, for that run the following command if you get public zone then everything fine to proceed.
1 |
firewall-cmd --get-active-zones |
Open HTTP port 80 and HTTPS port 443
FirewallD listed the port 80 and 443 as HTTP and HTTPS services. To open the port 80 and 443 temporarily use the following command.
1 2 |
firewall-cmd --zone=public --add-service=http firewall-cmd --zone=public --add-service=https |
Open HTTP port 80 and HTTPS port 443 permanent.
The firewall-cmd commands apply to runtime configuration but using the –permanent flag you can open port 80 and 443 permanently. To add and activate a permanent rule you need to use the below command.
1 2 |
firewall-cmd --zone=public --permanent --add-service=http firewall-cmd --zone=public --permanent --add-service=https |
Check the Open Ports/Services
To know the permanent open ports and services uses the following command.
1 |
firewall-cmd --list-all |
Remove the Ports
If you like to remove some of the port in your zone e.g. need to remove the existing HTTP port 80 and HTTPS port 443 use the following command.
1 2 |
firewall-cmd --zone=public --permanent --remove-service=http firewall-cmd --zone=public --permanent --remove-service=https |
FirewallFirewallDLinux CommandsRedhatRHEL 8security
Mraj
Creative Designer & Developer specialist by the spirit and a loving blogger by thoughts. If you have any questions let me drop an email with the article name to the following email id: [email protected]