How to open port on CentOS 7 using firewalld
What is Firewalld ?
It is a tool to manage firewall in a Linux operating system. It acts as an alternative to iptables service. In CentOS 7 or later firewalld is a default tool for firewall management.In this guide, I will tell you how to open port on CentOS 7 firewall or later using firewalld. Firstly you have to check firewalld service is running or not on your system.
systemctl status firewalld
The above command will show you the status of firewalld service on your system.
Enter the following command to open port your system
firewall-cmd --permanent --add-port=80/tcp
In the above command, I have opened port number 80
To open multiple port at a once
firewall-cmd --permanent --add-port={80,443,110}/tcp
Once you have done a port open procedure, now reload the firewall to apply the change
firewall-cmd --reload
or
firewall-cmd --complete-reload
There is a difference between both two commands -
firewall-cmd --reload - This command will reload firewalld rules by keeping state information. It is a runtime configuration it will be lost when firewalld is restarted.
firewall-cmd --complete-reload - This command will completely reload firewall by terminating active connections because state information is lost.
To make changes permanent use --permanent argument in between the command
firewall-cmd --permanent --complete-reload
To view opened port on a system enter following command, it will show you port.
firewall-cmd --list-port
Any edits and suggestions are always welcome.
0 Comments