Detailed explanation and usage examples of telnet command

       telnet is a protocol and command-line tool for remotely accessing and managing computer network devices, servers, and services. It can be used to connect to any computer running Telnet server software and execute commands and operations on the remote computer. The following are detailed explanations and usage examples of the telnet command.

        Usually we use this command to pass parameters to test whether your server and other servers can be accessed normally, for example:

telnet ip地址  端口

示例:telnet 192.168.0.100 8080

When using the Telnet command to connect to a remote IP address and port, a response similar to the following is returned if the connection is successful:

Trying 192.168.0.100...
Connected to 192.168.0.100.
Escape character is '^]'.

Among them, "Trying 192.168.0.100…" means trying to connect to the specified IP address, "Connected to 192.168.0.100." means the connection has been established, "Escape character is '^]'." is a prompt message, means you can use Ctrl + ] to exit the Telnet command.

If the connection fails, an error message similar to the following is displayed:

Trying 192.168.0.100...
telnet: Unable to connect to remote host: Connection refused

Among them, "Unable to connect to remote host: Connection refused" means that the remote host cannot be connected, which may be because the port is not opened or the host is unreachable.

So, if the connection is successful, the first response will be displayed, and if the connection fails, the second response or other relevant error message will be displayed. In addition to the commonly used command above, there are other detailed usages, as follows:

  1. command syntax

The syntax of the command is as follows:

telnet [-a][-e char][-f log_file][-l user][-t term_type][host [port]]

      2. Command parameters

  • -a: This flag tells the telnet command to send a carriage return character to the remote host after the connection is established.
  • -e char: specify a character as the escape character of the telnet command, the default is "^]" (Ctrl+]).
  • -f log_file: Specifying a file name will log the session to that file.
  • -l user: Specifies the login name to use on the remote computer.
  • -t term_type: Specifies the terminal type, which can be vt100, ansi, vt52 or xterm.
  • host: Specifies the IP address or host name of the remote host to connect to.
  • port: Specify the port number of the remote host to connect to, if not specified, the default port number 23 will be used.

      3. Command example

  • connect to remote host

telnet 192.168.0.1

  • Connect to a specific port on a remote host

telnet 192.168.0.1 8080

  • Specify the login name to connect to the remote host

telnet -l user 192.168.0.1

  • Specify the log file to connect to the remote host

telnet -f log.txt 192.168.0.1

  • Specify the terminal type to connect to the remote host

telnet -t vt100 192.168.0.1

  • exit telnet

quit

The above is the syntax and usage examples of the telnet command. These commands and parameters can help users connect to remote computers and services, and perform a series of operations and commands on the remote computer.

Guess you like

Origin blog.csdn.net/qq_37764320/article/details/129797494