tcp connection testing with telnet
Share on facebook
Share on twitter
Share on linkedin

TCP Connection Testing with Telnet

MichaelChristian
MichaelChristian

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 www.example.com, you’d use:

telnet www.example.com 80

And what you’d be looking for is this:

Connected to example.com.Escape 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 www.example.com, instead of quitting, you’d type:

HEAD / HTTP/1.1Host: www.example.com

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:

Recommended

Get more insights, news, and assorted awesomeness around all things cloud learning.

Get Started

Who’s going to be learning?

Sign In

Welcome Back!
Thanks for reaching out!

You’ll hear from us shortly. In the meantime, why not check out what our customers have to say about ACG?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout