Linux測試端口是否連通的方法 -bash: telnet: 未找到命令
telnet命令一般用來檢測一個端口使用,新安裝的linux系統或是Mac系統都可能是不支持telnet命令的,所以我們需要安裝一下
1.linux 安裝:
yum install telnet
2.mac安裝需要用到brew軟件包管理器
brew install telnet
Linux幾種常用測試端口連通的方法
- 1 telnet方法
- 2 wget方法
- 3 ssh方法
- 4 curl方法
1 telnet
#用法: telnet ip port
#(1) telnet連接不存在的端口
telnet 1.1.1.1 8
Trying 1.1.1.1...
telnet: connect to address 1.1.1.1: Connection timed out
#(2) telnet 鏈接存在端口
telnet 1.1.1.1 8000
Trying 1.1.1.1...
Connected to 1.1.1.1.
Escape character is '^]'.
Connection closed by foreign host.
2 wget
#用法: wget ip:port
#(1) 不存在端口
wget 1.1.1.1:8
--2017-01-24 11:38:34-- http://1.1.1.1:8/ Connecting to 1.1.1.1:8...
failed: Connection timed out. Retrying.
#(2) 存在端口
wget 1.1.1.1:8000
--2017-01-24 11:39:03-- http://1.1.1.1:8000/
Connecting to 1.1.1.1:8000... connected.
HTTP request sent, awaiting response... 200 OK
3 ssh
#用法: ssh -v -p port username@ip -v 調試模式(會打印日志). -p 指定端口 這里沒有給出測試,留給讀者自己測試
4 curl
#用法: curl ip:port
#(1) 不存在端口
獲取不到結果
#(2) 存在端口
curl 1.1.1.1:8000
<!DOCTYPE html>
<html>
<head>xxx</head>
<body>
......
</body>
</html>

