方法一:telnet
telnet只能用于测试TCP端口,而nc即可用于测试TCP端口也可用来测试UDP端口。
[root@zq /]# telnet 10.21.137.42 1520 Trying 10.21.137.42... Connected to 10.21.137.42. #==>出现Connected表示连通了,说 Escape character is '^]'. #==>按“ctrl+]”退出此地。 hello world #发送的消息,一行是一条消息,直接按“Enter”键 ^] telnet> quit #==>按“quit”退出连接 Connection closed.
方法二:ssh
[root@zq]# ssh -v 10.21.137.42 -p 1520 OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 56: Applying options for * debug1: Connecting to 10.21.137.42 [10.21.137.42] port 1520. debug1: Connection established. # 连接成功 debug1: permanently_set_uid: 0/0 debug1: identity file /root/.ssh/id_rsa type -1 debug1: identity file /root/.ssh/id_rsa-cert type -1 debug1: identity file /root/.ssh/id_dsa type -1 debug1: identity file /root/.ssh/id_dsa-cert type -1 debug1: identity file /root/.ssh/id_ecdsa type -1 debug1: identity file /root/.ssh/id_ecdsa-cert type -1 debug1: identity file /root/.ssh/id_ed25519 type -1 debug1: identity file /root/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.6.1
方法三:curl
方法四:nmap
zq@ubuntu:~$ nmap smtp.mxhichina.com # 查找开放的端口、服务、MAC地址 Starting Nmap 7.91 ( https://nmap.org ) at 2021-07-06 06:33 PDT Nmap scan report for smtp.mxhichina.com (42.120.226.4) Host is up (0.031s latency). Other addresses for smtp.mxhichina.com (not scanned): 42.120.219.29 Not shown: 997 filtered ports PORT STATE SERVICE 25/tcp open smtp # 开放的端口 80/tcp open http 465/tcp open smtps Nmap done: 1 IP address (1 host up) scanned in 35.59 seconds zq@ubuntu:~$ nmap smtp.mxhichina.com -p 465 # 查找特定端口是否开放 Starting Nmap 7.91 ( https://nmap.org ) at 2021-07-06 06:34 PDT Nmap scan report for smtp.mxhichina.com (42.120.219.29) Host is up (0.021s latency). Other addresses for smtp.mxhichina.com (not scanned): 42.120.226.4 PORT STATE SERVICE 465/tcp open smtps Nmap done: 1 IP address (1 host up) scanned in 2.26 seconds
方法五:nc
zq@ubuntu:~$ nc -vz -w 2 smtp.mxhichina.com 25 # -v可视化,-z扫描时不发送数据,-w超时几秒,后面跟数字 Connection to smtp.mxhichina.com 25 port [tcp/smtp] succeeded! zq@ubuntu:~$ nc -v -w 2 smtp.mxhichina.com 25 Connection to smtp.mxhichina.com 25 port [tcp/smtp] succeeded! 220 smtp.aliyun-inc.com MX AliMail Server zq@ubuntu:~$ nc -w 2 smtp.mxhichina.com 25 220 smtp.aliyun-inc.com MX AliMail Server
参考链接:
https://www.cnblogs.com/machangwei-8/p/10353004.html nmap命令详解
https://www.cnblogs.com/nmap/p/6148306.html nc命令用法举例
https://www.cnblogs.com/apple2016/p/10214987.html linux telnet检测与某个端口是否开通
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/204569.html原文链接:https://javaforall.net
