Check TCP Port 80 (http) with telnet
In this article, we will show you how you can test accessing a web server through TCP port 80 using telnet.
HTTP Protocol Basics
HTTP is a plaintext protocol. Thereby, simulating a browser and testing access through port 80 using the telnet command becomes simple.
The following steps are necessary for this from a Linux command line:
telnet SERVERNAME 80. Thereby, telnet will connect to the server named SERVERNAME through port 80.
- If the establishment of the TCP connection is possible, telnet will respond with the messages:
Connected to SERVERNAME.and
Escape character is '^]'.
- A web page can now be requested using the HTTP protocol (such as the server’s web site). Enter the following two lines to do this and press afterwards the Enter key two times:
GET / HTTP/1.1
- The server will respond with the HTTP status and the web page (such as
HTTP/1.1 200 OKand so forth.)
telnet checkip.dyndns.org 80
GET / HTTP/1.1
The checkip.dyndns.org server will respond with HTTP Response, which will also contain the HTML code for the web page:
[user@fedora9 user]$ telnet checkip.dyndns.org 80 Trying 22.214.171.124... Connected to checkip.dyndns.org. Escape character is '^]'. GET / HTTP/1.1 HOST: checkip.dyndns.org HTTP/1.1 200 OK Content-Type: text/html Server: DynDNS-CheckIP/1.0 Connection: close Cache-Control: no-cache Pragma: no-cache Content-Length: 106 <html><head><title>Current IP Check</title></head><body>Current IP Address: 126.96.36.199</body></html> Connection closed by foreign host. [user@fedora9 user]$
Change Escape Character
If necessary, you can change the escape character when you call telnet:
[user@fedora9 user]$ telnet checkip.dyndns.org 80 -e+
This call uses
-e to define a plus sign as an escape character.
- Hypertext Transfer Protocol (en.wikipedia.org)
- For details, see http://www.dyndns.com/support/tools/
Author: Werner Fischer
Werner Fischer, working in the Web Operations & Knowledge Transfer team at Thomas-Krenn, completed his studies of Computer and Media Security at FH Hagenberg in Austria. He is a regular speaker at many conferences like LinuxTag, OSMC, OSDC, LinuxCon, and author for various IT magazines. In his spare time he enjoys playing the piano and training for a good result at the annual Linz marathon relay.