检测端口连通性的几种方式
2023-09-20 本文已影响0人
Eren_Jaeger
- nc命令
nc -zv 10.1.13.11 22
# -v 以详细模式运行
# -z 进行端口扫描时,在连接成功后立即关闭连接,不进行数据传输
连通性通过会显示如下:
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 10.1.13.11:22.
Ncat: 0 bytes sent, 0 bytes received in 0.02 seconds.
连通性不通过会显示如下:
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: No route to host.
- ssh命令
ssh -v -p2222 10.1.13.11
# -v 调试模式(会打印日志)
# -p 指定端口
连通性通过会显示如下:
此处省略
连通性不通过会显示如下:
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to 10.1.13.11 [10.1.13.11] port 81.
debug1: connect to address 10.1.13.11 port 81: No route to host
ssh: connect to host 10.1.13.11 port 81: No route to host
- curl命令
可以用curl命令测试http性质端口的连通性
curl http://10.1.13.11:80
- telnet命令
telnet 127.0.0.1 8066
如果测试某个端口未开放,则是会显示:
[root@nlrth-metersphere ~]# telnet 127.0.0.1 8066
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
测试通过,可能会等好长时间才会有反应:
[root@nlrth-metersphere ~]# telnet 127.0.0.1 8081
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.