How Do I Open Firewall Ports on CentOS

Opening a firewall is as easy as a few simple entries. Use this command to find your active zone(s):

firewall-cmd --get-active-zones

It will say either public, dmz, or something else. You should only apply to the zones required.

In the case of public try:

firewall-cmd --zone=public --add-port=2888/tcp --permanent

Then remember to reload the firewall for changes to take effect.

firewall-cmd --reload

Otherwise, substitute public for your zone, for example, if your zone is dmz:

firewall-cmd --zone=dmz --add-port=2888/tcp --permanent

Easy enough, BUT there's more! You also can use:

firewall-cmd --permanent --zone=public --add-port=2888/tcp 

but if is a known service, you can use:

firewall-cmd --permanent --zone=public --add-service=http 

and then reload the firewall

firewall-cmd --reload

If you have any comments, feel free to post them below or find us on Twitter and Facebook!

Until next time!

May 12 2021

Add or review comments

Please leave your comment

Existing comments

Comments 0