本文介绍3中检测远程端口方式,telnet、nmap和nc。

如果Mac提示找不到命令,请用brew安装。
如果Linux提示找不到命令,请用apt-get或者yum安装。

1 telnet方式

命令:

检测已打开的端口80(HTTP)

$ telnet google.com 80
Trying 216.58.197.174...
Connected to google.com.
Escape character is '^]'.
^C
Connection closed by foreign host.

如果提示Connected to google.com,说明80端口可以访问。

检测未打开的端口88

$ telnet google.com 88
Trying 216.58.197.174...
^C

如果超时,说明端口未开放。

2 nmap方式
命令:

检测已打开的端口80(HTTP)

$ nmap google.com -p 80

Starting Nmap 6.40 ( http://nmap.org ) at 2017-12-07 00:54 UTC
Nmap scan report for google.com (216.58.200.206)
Host is up (0.030s latency).
rDNS record for 216.58.200.206: nrt12s12-in-f206.1e100.net
PORT   STATE SERVICE
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 0.09 seconds

检测未打开的端口88

$ nmap google.com -p 88

Starting Nmap 6.40 ( http://nmap.org ) at 2017-12-07 00:55 UTC
Nmap scan report for google.com (216.58.200.206)
Host is up (0.030s latency).
rDNS record for 216.58.200.206: nrt12s12-in-f14.1e100.net
PORT STATE SERVICE
88/tcp filtered kerberos-sec

Nmap done: 1 IP address (1 host up) scanned in 0.30 seconds

显示全部打开的端口

nmap ip

$ nmap google.com

Starting Nmap 6.40 ( http://nmap.org ) at 2017-12-07 00:55 UTC
Nmap scan report for google.com (172.217.25.238)
Host is up (0.030s latency).
rDNS record for 172.217.25.238: nrt12s14-in-f14.1e100.net
Not shown: 998 filtered ports
PORT    STATE SERVICE
80/tcp  open  http
443/tcp open  https

Nmap done: 1 IP address (1 host up) scanned in 4.19 seconds

根据显示STATE的close/open确定端口是否打开。

3 nc方式
命令:
nc -v google.com 80
端口未打开返回状态为非0。

本文链接:https://blog.blogbins.com/linuxjian-ce-yuan-cheng-duan-kou-shi-fou-da-kai/

相关推荐

Linux检测远程端口是否打开
https://www.awaimai.com/914.html

打赏

Leave a Reply

Your email address will not be published. Required fields are marked *