Linux 系統測試埠連通性的方法
阿新 • • 發佈:2021-10-27
Linux 系統測試埠連通性的方法
有四種常用方法:
- telnet 方法
- wget 方法
- ssh 方法
- curl 方法
1.telnet 用法:telnet ip port
#1.連線不存在的埠 telnet 1.1.1.1 8 Trying 1.1.1.1... telnet: connect to address 1.1.1.1: Connection timed out #2.連線存在的埠 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 --2020-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 --2020-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>