Home  >  Article  >  Operation and Maintenance  >  How to check if the port is open in centos

How to check if the port is open in centos

WBOY
WBOYOriginal
2022-02-22 15:42:4822057browse

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”.

How to check if the port is open in centos

The operating environment of this article: centos 7 system, Dell G3 computer.

How to check whether the port is open in centos

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn