telnet client software is one of the simplest network tools to use and provides an interactive means to communicate with a service, the default being a Telnet service, RFC 854. Telnet servers are seldom used today, as they are insecure and subject to eavesdropping by network packet snoopers. They have now been replaced by ssh, Secure Shell servers, that provide communication channel level encryption. Still telnet client software remains useful for developers and administrators for testing assorted protocols and services.
telnet is simply invoked with a hostname or IP address of a server and the port number to connect on. In the following examples, the leading dollar sign ($) denotes the user's shell prompt. Our first example is a simple connection to a DayTime service, RFC 867, which simply returns a human readable date and time, then disconnects.
telnet to DayTime service
$ telnet localhost 13 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Wed Apr 24 10:27:27 2013 Connection closed by foreign host. $
In the above example, we see telnet attempt to connect to localhost port 13 using the IPv6 address ::1 and then successfully connect on the older IPv4 address for localhost, 127.0.0.1. When a hostname, like localhost or mx.example.com, is looked up through DNS, it will try both the IPv6 and IPv4 addresses. Command line based telnet clients have an escape mode where commands can be directed at the telnet client, instead of the connected service. To access that mode, the user presses CTRL+], which is denoted by ^] notation in the above example.
The most important telnet command sequence to remember if you ever get stuck is:
Graphical User Interface (GUI) versions of telnet, such as putty or kitty, don't display anything other than what is typed by the user and returned by the server. Options and software exit are found in the menu and/or tool bar.
In the following example, we connect to a SMTP service, breakout to the telnet escape mode, display the telnet help, return back to the SMTP session, display the SMTP help, and finally quit.
telnet to an SMTP server
$ telnet localhost 25 Trying ::1... Connected to localhost. Escape character is '^]'. 220 chippy.snert.com ESMTP #632 p3NAUf266330014000 ^] telnet> help Commands may be abbreviated. Commands are: close close current connection logout forcibly logout remote user and close the connection display display operating parameters mode try to enter line or character mode ('mode ?' for more) open connect to a site quit exit telnet send transmit special characters ('send ?' for more) set set operating parameters ('set ?' for more) unset unset operating parameters ('unset ?' for more) status print status information toggle toggle operating parameters ('toggle ?' for more) slc change state of special characters ('slc ?' for more) auth turn on (off) authentication ('auth ?' for more) encrypt turn on (off) encryption ('encrypt ?' for more) z suspend telnet ! invoke a subshell environ change environment variables ('environ ?' for more) ? print help information telnet> HELP 214-2.0.0 ESMTP RFC 1985, 3207, 4954, 5321 supported commands: 214-2.0.0 AUTH DATA EHLO ETRN HELO HELP 214-2.0.0 NOOP MAIL RCPT RSET QUIT STARTTLS 214-2.0.0 214-2.0.0 ESMTP RFC 2821, 5321 not implemented: 214-2.0.0 EXPN TURN VRFY 214-2.0.0 214-2.0.0 Administration commands: 214-2.0.0 CONN CACHE INFO KILL LKEY OPTN 214-2.0.0 STAT VERB XCLIENT 214-2.0.0 214 2.0.0 End QUIT 221 2.0.0 chippy.snert.com closing connection #247 p3NAUf266330014000 Connection closed by foreign host. $
Some of the common reasons to break out into telnet escape mode, is to quit or change settings, such as the echo behaviour. Some telnet clients default to echo off, which means you might not see what is typed. Note that command line telnet escape mode commands and settings vary with the client software, so it's typically a good idea to try the HELP command to see a summary and/or consult the man page on Unix systems or online documentation.
In the example below, the Microsoft Windows telnet client is used to connect to a POP service, and the telnet escape mode help summary is displayed.
Microsoft telnet connecting to POP service and escape mode.
C:\Users\Slartibartfast> telnet mail.example.com 110 +OK POP3 mail.example.com 2007f.104 server ready ^] Welcome to Microsoft Telnet Client Escape Character is 'CTRL+]' Microsoft Telnet> help Commands may be abbreviated. Supported commands are: c - close close current connection d - display display operating parameters o - open hostname [port] connect to hostname (default port 23). q - quit exit telnet set - set set options (type 'set ?' for a list) sen - send send strings to server st - status print status information u - unset unset options (type 'unset ?' for a list) ?/h - help print help information Microsoft Telnet> quit C:\Users\Slartibartfast>
The References below list several basic testing services that one can experiment with using telnet. Most of the basic services are disabled by default on Unix and Windows systems. For Unix, the basic services are provided by inetd(8); for Microsoft Windows 7 see Control Panel > Programs and Features > Turn Windows features on or off > Simple TCPIP Services.