Build a local Telnet lab

Connect and use command mode

Open the local connection, send terminal data, and leave the session through the client command escape.

8 minute lesson

~~~

Keep the server from the previous lesson running. Open another terminal and connect:

telnet 127.0.0.1 2323

The client prints a few lines before you type anything:

Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Welcome

Trying means a TCP connection attempt is in progress. Connected means the handshake completed. Welcome is the first data your server sent. The escape character line matters most, and we will come back to it in a moment.

Type hello and press Enter. The server terminal prints the received bytes in hexadecimal:

68656c6c6f0d0a

That is hello in ASCII, followed by 0d0a: carriage return and line feed. The client displays the server reply, Received 7 bytes. You typed five characters and the line ending added two more.

Command mode

A Telnet client also has a local command mode. The default escape is commonly Ctrl+], which is what '^]' meant in the connection banner. Press it and the client shows its own prompt:

telnet> 

You are now talking to the client program, not the server. Enter status to inspect the connection. It reports the connected host and the current escape character. Press Enter on an empty line to return to the session, or enter quit to close the connection and exit.

The escape character is handled by the client. It is not sent to the server as terminal data. Nothing appears in your server’s hexadecimal log when you press it.

This gives you three layers to keep apart. Client commands like status and quit live in the client program only. Telnet protocol commands travel inside the stream as IAC sequences. Ordinary terminal data is everything else you type.

One common confusion: if you close the server while the client sits in command mode, the client may not notice until you return to the session and press a key. TCP only reports a closed connection when you try to use it.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →