Checking if a port is open using /dev directory
An old but useful tip. You don’t need telnet, nc or other related tool to check if a port is open.
Lets assume you want to check if the port 22 is open at host 192.168.0.2, perform it:
# echo > /dev/tcp/192.168.0.2/22
Check the return code of the command above
# echo $?
If “0”, port is open, if “1” the port is closed.