Linux查看所有对外开放的端口

Linux查看所有对外开放的端口

Centos 8查看所有对外开放的端口
查看防火墙对对应的端口是否已开启
firewall-cmd --list-all

方式1

已知服务使用的端口,查看服务是否在监听

netstat -anlp | grep 3306

方式二

查询所有服务监听的端口

安装 nmap工具检测开放端口

1、下载安装包

http://nmap.org/dist/nmap-7.01.tar.bz2

2、解压

tar -xvf nmap-7.01.tar.bz2 

3、进入目录执行

cd /nmap-7.12
./configure

若报错“configure: error: no acceptable C compiler found in $PATH”,
说明未安装gcc,gcc安装命令为#yum install gcc. 
执行#make 若报错“-bash: make: command not found”,
则执行#yum install g++或#yum install gcc-c++安装gcc。 

4、make

5、make install

6、查看是否安装成功

nmap -v

在这里插入图片描述

安装nmap工具之后,可以通过工具查询对外开放,并在监听服务的端口

执行:nmap 127.0.0.1

Starting Nmap 7.01 ( https://nmap.org ) at 2022-10-10 17:39 CST
Warning: File ./nmap-services exists, but Nmap is using /usr/local/bin/../share/nmap/nmap-services for security and consistency reasons.  set NMAPDIR=. to give priority to files in your local directory (may affect the other data files too).
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000010s latency).
Not shown: 998 closed ports
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http

猜你喜欢

转载自blog.csdn.net/Tomcat_king/article/details/127248991