Linux下检测某个ip端口的连通状态
目录
举个例子,要测试的 ip+port: 192.168.0.100:8080
-
使用
telnet
命令telnet 192.168.0.100 8080
连通成功:
1 2 3 4
Trying 192.168.0.100... Connected to 192.168.0.100. Escape character is '^]'. Connection closed by foreign host.
连通失败:
1 2
rying 192.168.0.100... telnet: Unable to connect to remote host: Connection refused
-
使用
nc
命令nc -zvw3 192.168.0.100 8080
参数说明:
-z
: 仅扫描侦听, 不会发送数据。-v
: 输出详细信息。-w3
: 允许超时3秒~
连通成功:
1
Connection to 192.168.0.100 8080 port [tcp/http] succeeded!
连通失败:
1
nc: connect to 192.168.0.100 port 8080 (tcp) failed: Connection refused
-
使用
nmap
命令nmap 192.168.0.100 -p 8080
连通成功:
1 2 3 4 5 6 7 8
Starting Nmap 7.80 ( https://nmap.org ) at 2021-01-21 21:30 CST Nmap scan report for 192.168.0.100 Host is up (0.00049s latency). PORT STATE SERVICE 8080/tcp open http Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds
连通失败:
1 2 3 4 5 6 7 8
Starting Nmap 7.80 ( https://nmap.org ) at 2021-01-21 21:30 CST Nmap scan report for 192.168.0.100 Host is up (0.00029s latency). PORT STATE SERVICE 8080/tcp closed unknown Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds
欢迎访问 spaceack.com