Missing telnet, but need to test a TCP connection? Try echo!

This is such a simple trick, I'm still surprised. When you need to test a connection (TCP) but have no telnet or nc, you can use this workaround:

echo > /dev/tcp/google.com/80
echo $?
0

You won't get a response back, but that exitstatus ($?) will be either:

  1. 0 - It worked.
  2. not 0 - It did not work.
    1. If it takes really long for the command line to get back, not connection is possible.

      You can use this to send data to UDP, but since UDP is stateless, the exit status will always be "0".

About Consultancy Articles Contact




References Red Hat Certified Architect By Robert de Bock Robert de Bock
Curriculum Vitae By Fred Clausen +31 6 14 39 58 72
By Nelson Manning robert@meinit.nl