测试环境为Centos7.9,本文简单给出了几种检测端口的例子。
一、查看本机端口占用 1、netstat#安装netstat yum -y install net-tools #检测端口占用 netstat -npl | grep "端口"2、lsof
#安装lsof yum -y install lsof #检测端口占用 lsof -i :端口号3、psmisc
#安装psmisc yum -y install psmisc #检测端口占用,如果占用,能够查到pid fuser 端口/tcp二、查看对方端口是否开放 1、nc(netcat)
#安装nc yum -y install nc #查看对方端口是否开放 nc -vz 对方ip 对方端口2、telnet
#安装telnet yum -y install telnet #查看对方端口是否开放 telnet 对方ip 对方端口
telnet是基于TCP的
这两种检测的当然也适用于检测本机端口,ip换成127.0.0.1即可。



