NotePublic/Software/Applications/Telnet/Telnet_测试端口连通性.md

54 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Telnet 测试端口连通性
telnet命令是TELNET协议的用户接口它支持两种模式命令模式和会话模式虽然telnet支持许多命令但大部分情况下我们只是使用它查看目标主机是否打开了某端口默认是23
其执行结果有两种:
## 端口未打开
```bash
telnet 101.199.97.65 62715
Trying 101.199.97.65...
telnet: connect to address 101.199.97.65: Connection refused
```
此时,命令已退出。
## 端口已打开
```bash
telnet 101.199.97.65 62715
Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is '^]'.
```
此时命令未退出。
根据提示Escape character is '^]'.可知退出字符为'^]'CTRL+]。此时输入其它字符不能使其退出CTRL+C都不行。输入CTRL+]后会自动执行,进入命令模式:
```bash
^]
telnet>
```
此时再运行 quit 才会真正退出。
```bash
telnet> quit
Connection closed.
```
其中Escape character 可以自定义,使用参数 -e
```bash
telnet -e p 101.199.97.65 62715 #使用p字符
Telnet escape character is 'p'.
Trying 101.199.97.65...
Connected to 101.199.97.65.
Escape character is 'p'.
p
telnet> quit
Connection closed.
```