Open Ports CentOS 7

To open up a new port (e.g., 80,21,22,3306 ) permanently, use these commands.

$ sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
$ sudo firewall-cmd --zone=public --add-port=3306/tcp --permanent
$ sudo firewall-cmd --zone=public --add-port=21/tcp --permanent
$ sudo firewall-cmd --zone=public --add-port=22/tcp --permanent

$ sudo firewall-cmd --reload

Without “–permanent” flag, the firewall rule would not persist across reboots.

Check the updated rules with

$ firewall-cmd --list-all
Share

Leave a Reply

Your email address will not be published. Required fields are marked *