How to open a specified port in Centos 7? In the previous post, I deployed the website developed by the client using the asp.net webform technology to the Centos 7 server. When the deployment was successful, I found that I could not access it because the ports 443 and 80 were not enabled. This post will discuss Let’s take a look at the topic of Centos opening specified ports.
Open a specified port in Centos 7
Open ports
firewall-cmd --zone=public --add-port=5672/tcp --permanent # Open port 5672 firewall-cmd --zone=public --remove-port=5672/tcp --permanent #Close port 5672 firewall-cmd --reload # The configuration takes effect immediately
View all open ports on the firewall
firewall-cmd --zone=public --list-ports
Turn off the firewall
If there are too many ports to be opened and it is troublesome, you can close the firewall and evaluate the security by yourself
systemctl stop firewalld.service
Check the firewall status
firewall-cmd --state
View the listening port
netstat -lnpt
PS: centos 7 does not have the netstat command by default, you need to install the net-tools tool, yum install -y net-tools
Check which process the port is occupied by
netstat -lnpt | grep 5672
View the details of the process
ps 6832
Abort the process
kill -9 6832