常见的用于验证端口号是否可用的工具有telnet、curl、nc(netcat)、nmap等。
- 使用telnet验证端口:
[root@localhost ~]# telnet 192.168.15.137 22
Trying 192.168.15.137...
Connected to 192.168.15.137.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.4
Connection closed by foreign host.
- 使用curl验证端口(还是调用telnet实现):
[root@localhost ~]# curl -v telnet://192.168.15.137:22
* About to connect() to 192.168.15.137 port 22 (#0)
* Trying 192.168.15.137...
* Connected to 192.168.15.137 (192.168.15.137) port 22 (#0)
SSH-2.0-OpenSSH_7.4
* Send failure: Broken pipe
* Closing connection 0
curl: (55) Send failure: Broken pipe
- 使用curl验证端口:
[root@localhost ~]# curl 192.168.15.137:22
SSH-2.0-OpenSSH_7.4
Protocol mismatch.
curl: (56) Recv failure: Connection reset by peer
- 使用nc验证端口:
[root@localhost ~]# nc -zv 192.168.15.137 22
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 192.168.15.137:22.
Ncat: 0 bytes sent, 0 bytes received in 0.01 seconds.
- 使用nmap验证端口:
[root@localhost ~]# nmap -p 22 192.168.15.137
Starting Nmap 6.40 ( http://nmap.org ) at 2023-10-10 15:13 CST
Nmap scan report for 192.168.15.137
Host is up (0.000057s latency).
PORT STATE SERVICE
22/tcp open ssh
Nmap done: 1 IP address (1 host up) scanned in 0.26 seconds
总结,ping、telnet、curl、nc、nmap等工具功能和用途有所不同,在工作中使用的都很频繁,它们能极大地提升我们的工作效率,你学会了吗?
© 版权声明
本站文章由不念博客原创,未经允许严禁转载!
THE END