Method: 1. Use the telnet command, the syntax is "telnet ip port"; 2. Use the nc command, the syntax is "telnet ip port"; 3. Use the firewall command, the syntax is "firewall-cmd -- query-port=port/tcp”.
The operating environment of this article: centos 7 system, Dell G3 computer.
Different Linux systems have different ways of checking whether the port is open. In some environments, it depends on the software. If the relevant software is not installed in centos, These three may not necessarily work, so which method to use depends on the environment, but you can try each one.
Method 1
Use the telnet command. Telnet can be used directly on Windows. If used on Linux, install it first (yum install -y telnet), and then use the following method to detect it. Whether the port is open
telnet ip port
Method 2
Use the nc command. The nc command usually also needs to be installed (yum install -y nc). The command is
nc -v ip port
Method 3
Use the firewall command that comes with centos7
firewall-cmd --query-port=port/tcp
Note:
Permanently open a port
firewall-cmd --zone=public --add-port=port/tcp --permanent
Recommended tutorial: "centos tutorial"
The above is the detailed content of How to check if the port is open in centos. For more information, please follow other related articles on the PHP Chinese website!