Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

TCP Connection Testing with Telnet

Jun 08, 2023 • 3 Minute Read

Please set an alt value for this image...
The beauty of Telnet is that it’s available for almost any operating system, and it's installed by default on many. While the use of insecure Telnet for network communication eventually gave way to encrypted protocols, like SSH, its usefulness lives on. Telnet is the perfect tool for testing TCP port connectivity. Let's walk through how to use Telnet for TCP connection testing, as taught in Linux Networking and Troubleshooting.Using TelnetPerhaps you’ve just finished building an environment in AWS, and you're getting ready to migrate some on-premises web content to something more scalable. You’ve configured your VPC, added the security groups, and instantiated the EC2 instances. How can you verify your ingress rules are set appropriately for the workload you plan to move to the EC2 instances?For services listening on TCP ports, it’s simple - just use Telnet! Here’s an example.Check HTTP ConnectivityLet’s say you want to check HTTP connectivity to, you'd use:
telnet 80
And what you'd be looking for is this:
Connected to character is '^]'
This tells you when the connection was able to be made successfully. At this point, you’ll usually hit CTRL+C and type “quit” to exit Telnet, but you could also use Telnet to request some data.Pull HTTP HeadersLet’s say you want to pull the HTTP headers of, instead of quitting, you'd type:
HEAD / HTTP/1.1Host:
Telnet HTTP header requestFollowed by ENTER twice:Header pulled from www.example.comNot only will you be able to verify that port 80 was open and permitting communication, but you'll also be able to perform some validation against the service itself. The use case can be extended to pull the web page's HTML as well using something like:
GET /index.html HTTP/1.1
This, of course, assumes index.html exists at the root level of the site, and that 1.1 is the right HTTP host header specification.These are just a few examples of what Telnet can help with. For even more flexibility, including the ability to listen on TCP and UDP ports, you should check out netcat!  Get a deeper dive of all this and more in the latest hands-on training course: Linux Networking and Troubleshooting.Related Resources:


More about this author