FirewallD is the frontend management solution of iptables for most of the Linux distributions. It provides an easy-to-use command line and GUI-based interface to manage iptable rules. This tutorial describes to you to open port 80 (HTTP) and port 443 (HTTPS) in FirewallD.

Advertisement

Allow Port 80 & 443 in FirewallD

Using firewalld, you can allow/deny any port temporarily or permanently. The temporary allow/deny rules will be removed after the system reboot. But the permanent rules will persist even after the system restart.

The following commands allow incoming traffic on TCP ports 80 and 443 in firewalld.

sudo firewall-cmd --zone=public --add-port=80/tcp 
sudo firewall-cmd --zone=public --add-port=443/tcp 

The --permanent option insures to remain firewall rules after system reboots.

sudo firewall-cmd --permanent --zone=public --add-port=80/tcp 
sudo firewall-cmd --permanent --zone=public --add-port=443/tcp 

Next, apply the changes by reloading the firewallD.

sudo firewall-cmd --reload 

View Firewall Rules

After adding the rules in firewalld, You can verify the by the running following command.

sudo firewall-cmd --permanent --zone=public --list-ports 

Output:

443/tcp 8080/tcp

Remove Rules from FirewallD

If you don’t need to keep the ports open, you can remove/deny the above ports from the firewalld using the –remove-port option:

sudo firewall-cmd --permanent --zone=public --remove-port=80/tcp 
sudo firewall-cmd --permanent --zone=public --remove-port=443/tcp 

Next, run the following command to apply the changes:

sudo firewall-cmd --reload 

Conclusion

This tutorial helped you to open port 80 and 443 through the firewalld on Linux operating systems.

Share.

5 Comments

  1. @Heather: Are you using –, or are you using a single hyphen-minus (-)? It appears as if you are using either a single hyphen-minus, or an en-dash (–). The system won’t recognize a single hyphen-minus or an en-dash.

  2. [root@clever-banzai ~]# firewall-cmd –zone=public –add-port=80/tcp
    Warning: ALREADY_ENABLED: ’80:tcp’ already in ‘public’
    success
    [root@clever-banzai ~]# firewall-cmd –zone=public –add-port=443/tcp
    Warning: ALREADY_ENABLED: ‘443:tcp’ already in ‘public’
    success
    [root@clever-banzai ~]# firewall-cmd –permanent –zone=public –add-port=80/tcp
    Warning: ALREADY_ENABLED: 80:tcp
    success
    [root@clever-banzai ~]# firewall-cmd –permanent –zone=public –add-port=443/tcp
    Warning: ALREADY_ENABLED: 443:tcp
    success
    [root@clever-banzai ~]# firewall-cmd –reload
    success
    [root@clever-banzai ~]# firewall-cmd –permanent –zone=public –list-ports
    80/tcp 443/tcp
    [root@clever-banzai ~]#

    dont work for me

    https://ping.eu/port-chk/
    80.211.37.89

    • Hi,

      Make sure the web server is listening on both ports. Please share the output of below commands:

      netstat -tulpn | grep 80
      netstat -tulpn | grep 443

Leave A Reply

Exit mobile version