Allow ports in firewalld on CentOS8

CentOS comes with firewalld by default. It allows you to manage your firewall rules based on zones. This short tutorial will cover only the basic setup with the default ‘public’ zone and how to allow ports in it.

You can manage your ‘firewalld’ using the ‘firewall-cmd’ command. To allow a port, you simply do:

firewall-cmd --permanent --add-port=80/tcp --add-port=443/tcp
firewall-cmd --reload

Keep in mind that you need to reload the ‘firewalld’ configuration when you make changes. This command has added TCP ports 80 and 443, for HTTP and HTTPS.

To list your current configuration, you can use the ‘list-all’:

firewall-cmd --list-all