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

How to check if the port is open in centos

WBOY
Release: 2022-02-22 15:42:48
Original
22203 people have browsed it

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
Copy after login

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
Copy after login

Method 3

Use the firewall command that comes with centos7

firewall-cmd --query-port=port/tcp
Copy after login

Note:

Permanently open a port

 firewall-cmd --zone=public --add-port=port/tcp --permanent
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template