Open specified or specific port number in CentOS 7

In CentOS 7, the specified port number can be opened through the following steps:

  1. Log in to the CentOS 7 server as root or a user with administrator privileges.
  2. Use a firewall management tool firewalldto open ports. firewalldIt is the default firewall management tool for CentOS 7.
  3. Check the status of the current firewall to ensure that firewalldthe service is running and working properly. You can check with the following command:
shCopy code
sudo systemctl status firewalld
  1. 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

--zoneThe parameter in the above command specifies the firewall area, usually used to publicindicate the public area, --add-portthe parameter specifies the port number and protocol to be opened (here is 6690/tcp), and --permanentthe parameter indicates that the modification will be permanently saved.

  1. Reload the firewall rules to take effect:
shCopy code
sudo firewall-cmd --reload
  1. 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.

Guess you like

Origin blog.csdn.net/wlei0618/article/details/130215857