How to test open ports w/o telnet or nc

Found this out of necessity when a security team didn’t allow the installation of either telnet or nc. I initially thought ssh would work, but it doesn’t really work.

The command is simple. Just do this:


Replace the <host> and <port>. Here’s how it would look if successful:

SV-LT-1361:~ altonyu$ > /dev/tcp/
SV-LT-1361:~ altonyu$ echo $?

Here’s how it would look if unsuccessful:

SV-LT-1361:~ altonyu$ > /dev/tcp/
-bash: connect: Connection refused
-bash: /dev/tcp/ Connection refused
SV-LT-1361:~ altonyu$ echo $?

Obviously if the command hangs, it probably means it won’t work either.

Hope this helps someone!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.