This article describes how to use the telnet program to troubleshoot network applications.
For many years, the telnet program was the program of choice for connecting to a remote server. However, it sends data unencrypted, and SSH (Secure Shell) has almost completely replaced telnet as the preferred method for connecting to remote servers.
However, telnet is still valuable as a troubleshooting tool. You can use telnet to test TCP connections to a remote server on any port. Once telnet establishes a connection, you can send raw commands to do additional testing.
Linux includes the telnet client by default.
Windows 10 includes telnet as part of the Windows Subsystem for Linux. Telnet can also be installed on Windows 10 and older versions of Windows by following these instructions.
Macintosh OS X included telnet by default until recently. If your version does not include telnet, it can be installed following these instructions.
To use telnet to troubleshoot a network application, you need to know at least two things:
If you are only testing basic connectivity to a particular network application, that is all you need to know. If you want to do more in-depth testing, however, you will need to know specific commands for the protocol you want to test (for example, HTTP or SMTP).
To open a connection to a remote server, open a terminal window on your computer, and then type telnet IP/host port, where IP/host represents the IP address or hostname of the server, and port represents the TCP port number. For example, to connect to example.com on port 80, type the following command:
telnet example.com 80
When you try to establish a connection to a remote server, one of two things happens:
The following sections demonstrate how to do basic telnet troubleshooting with some common network applications.
Web server testing is probably the most common scenario for telnet troubleshooting. With telnet, you can open a connection to a remote server on port 80, and then send HTTP commands. For example, the following text shows an exchange between telnet and a remote web server. Text in red represents commands typed by the user:
$ telnet example.com 80 Trying 192.168.0.62… Connected to example.com. Escape character is '^]'. GET / HTTP/1.1 Host: example.com HTTP/1.1 200 OK Accept-Ranges: bytes Cache-Control: max-age=604800 Content-Type: text/html [Additional server output follows]
In this exchange, telnet opens a connection to example.com on port 80. The user receives confirmation that there is a connection to the server, and then sends an HTTP command and request header. The HTTP response confirms that the server is accepting connections and responding to requests.
To test an SMTP server, use telnet to connect to port 25.
The following text shows a sample exchange between telnet and a remote mail server. Text in red represents commands typed by the user:
$ telnet example.com 25 Trying 192.168.0.62… Connected to example.com. Escape character is '^]'. 220-example.com ESMTP Exim 4.7 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail. EHLO a2example.com 250-example.com Hello a2example.com [192.168.3.232] 250-AUTH PLAIN LOGIN QUIT
The SMTP responses show that the server is running and accepting requests.
To test an FTP server, use telnet to connect to port 21.
The following text shows a sample exchange between telnet and a remote FTP server. Text in red represents commands typed by the user:
$ telnet example.com 21 Trying 192.168.0.62… Connected to example.com. Escape character is '^]'. 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 220-You are user number 18 of 50 allowed. 220-Local time is now 12:46. Server port: 21. 220-This is a private system - No anonymous login 220-IPv6 connections are also welcome on this server. 220 You will be disconnected after 15 minutes of inactivity.
The FTP server responds, indicating that it is active and running.
SSH uses encrypted connections. However, you can still use telnet to verify that the service is running on a server.
The following text shows a sample exchange between telnet and a remote SSH server. Text in red represents commands typed by the user:
$ telnet example.com 22 Trying 192.168.0.62… Connected to example.com. Escape character is '^]'. SSH-2.0-OpenSSH_5.3
The server returns a response indicating the current OpenSSH version.
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Usamos cookies con el fin de personalizar para usted nuestro sitio Web y analizar el uso de éste. Usted acepta esto haciendo clic en “Acepto” o al continuar usando el sitio Web. Hay más información sobre cookies en nuestra política de privacidad.