Centos7 – How to allow port in firewall

For allowing port on centos7 use this commands (1234 is new port):

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

and reload firewall:

firewall-cmd –reload

Warning: Any port is ruled with selinux. When you will make quick test with selinux start and stop use this command dor stop selinux:

setenforce  0

and this for selinux start:

setenforce  1


Commenting area

  1. You don’t have to specify the zone. If you omit the ‚–zone=public‘ you’ll open the port in default zone, which is what you want in most cases.

  2. Hi Jiri. Thanks for the complement solution!

Leave a Reply