In CentOS 7, the specified port number can be opened through the following steps:
- Log in to the CentOS 7 server as root or a user with administrator privileges.
- Use a firewall management tool
firewalld
to open ports.firewalld
It is the default firewall management tool for CentOS 7. - Check the status of the current firewall to ensure that
firewalld
the service is running and working properly. You can check with the following command:
shCopy code
sudo systemctl status firewalld
- Open the specified port number. For example, if you want to open port 6690, you can run the following command:
shCopy code
sudo firewall-cmd --zone=public --add-port=6690/tcp --permanent
--zone
The parameter in the above command specifies the firewall area, usually used to public
indicate the public area, --add-port
the parameter specifies the port number and protocol to be opened (here is 6690/tcp
), and --permanent
the parameter indicates that the modification will be permanently saved.
- Reload the firewall rules to take effect:
shCopy code
sudo firewall-cmd --reload
- Check if the port is successfully opened. You can run the following command to check if port 6690 is open in firewall rules:
shCopy code
sudo firewall-cmd --zone=public --list-ports
If you see output similar to the following, the port has been successfully opened:
bashCopy code
6690/tcp
The above steps can help you open the specified port number in CentOS 7. Note that opening ports may increase the security risk of the server, so when opening ports, be sure to open only necessary ports and follow best practices in network security.