【Linux】测试端口连通性telnet

telnet 命令测试端口连通性

语法: telnet ip地址 port(端口)
  • Linux的telnet用法结果
(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.
    
此时命令未退出。
根据提示Escape character is '^]'.可知退出字符为'^]'(CTRL+])。
此时输入其它字符不能使其退出,CTRL+C都不行。输入CTRL+]后会自动执行,进入命令模式:

^]
telnet>

此时再运行quit才会真正退出。
telnet> quit
Connection closed.


  • Windows的telnet用法结果
(1) telnet 连接不存在的端口  
      弹出无法连接,说明此端口不同
      
(2) telnet 链接存在端口
      敲回车后弹出"黑屏,没有输出任何信息"说明此端口是相通的。



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



ssh 命令测试端口连通性

语法: ssh -v -p port username@ip
-v 调试模式(会打印日志).
-p 指定端口
(1) 不存在端口
结果输出:ssh: connect to host "IP地址" port "端口": Connection refused

(2) 存在端口
结果输出:ssh_exchange_identification: Connection closed by remote host



curl 命令测试端口连通性

语法: curl ip地址:port(端口)
(1) 不存在端口
    获取不到结果
    
(2) 存在端口
    curl  IP地址:8080
    <!DOCTYPE html>
    <html>
        <head>xxx</head>
        <body>
            ......
        </body>
    </html>



发布了11 篇原创文章 · 获赞 0 · 访问量 123

猜你喜欢

转载自blog.csdn.net/weixin_43658009/article/details/95865730