檢測伺服器開放埠

2021-10-06 22:52:59 字數 2149 閱讀 1345

1.使用nmap檢測開放埠,可檢測遠端伺服器

[root@localhost ~]# nmap localhost

starting nmap 6.40 ( ) at 2020-06-09 01:40 cst

nmap scan report for localhost (127.0.0.1)

host is up (0.000023s latency).

other addresses for localhost (not scanned): 127.0.0.1

not shown: 998 closed ports

port   state service

22/tcp open  ssh

25/tcp open  smtp

nmap done: 1 ip address (1 host up) scanned in 2.01 seconds

2.使用netstat檢測本地埠

[root@localhost ~]# netstat -tunlp

active internet connections (only servers)

proto recv-q send-q local address           foreign address         state       pid/program name    

tcp        0      0 0.0.0.0:22              0.0.0.0:*               listen      6741/sshd           

tcp        0      0 127.0.0.1:25            0.0.0.0:*               listen      7053/master         

tcp6       0      0 :::22                   :::*                    listen      6741/sshd           

tcp6       0      0 ::1:25                  :::*                    listen      7053/master         

udp        0      0 0.0.0.0:68              0.0.0.0:*                   

3.使用lsof檢測開放埠

[root@localhost ~]# lsof -i:22

command   pid user   fd   type device size/off node name

sshd     6741 root    3u  ipv4  37912      0t0  tcp *:ssh (listen)

sshd     6741 root    4u  ipv6  37914      0t0  tcp *:ssh (listen)

sshd    17129 root    3u  ipv4  48317      0t0  tcp localhost.localdomain:ssh->192.168.100.1:65379 (established)

4.使用netcat檢測埠

[root@localhost ~]# nc -zv localhost 22

ncat: version 7.50 ( )

ncat: connected to ::1:22.

ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.

5.使用telnet檢測埠,只能檢測tcp埠。telnet+ip/網域名稱+埠

[root@localhost ~]# telnet localhost 22

trying ::1...

connected to localhost.

escape character is '^]'.

ssh-2.0-openssh_7.4

6.curl檢測埠,curl +ip:埠

[root@localhost ~]# curl localhost:22

ssh-2.0-openssh_7.4

protocol mismatch.

伺服器端口開放

查詢埠號80 是否開啟 firewall cmd query port 80 tcp 永久開放80埠號 firewall cmd permanent zone public add port 80 tcp 移除80埠號 firewall cmd permanent zone public remov...

Linux伺服器開放埠 查詢埠

1 檢視對外開放的埠狀態 查詢已開放的埠 netstat anp 查詢指定埠是否已開 firewall cmd query port 666 tcp 提示 yes,表示開啟 no表示未開啟。2 檢視防火牆狀態 檢視防火牆狀態 systemctl status firewalld 開啟防火牆 syst...

伺服器開放特定埠的方法

firewall cmd state檢視防火牆的狀態。systemctl start firewalld.service 將防火牆開啟。firewall cmd zone public add port xx tcp permanent 讓我們來解釋一下上乙個命令 zone public 表示作用域...