Skip to content

Instantly share code, notes, and snippets.

@rafaeltuelho
Last active January 5, 2020 11:31
Show Gist options
  • Save rafaeltuelho/a7f76c7573c30f80a4e2 to your computer and use it in GitHub Desktop.
Save rafaeltuelho/a7f76c7573c30f80a4e2 to your computer and use it in GitHub Desktop.
testing a TCP connection on Linux without telnet
  • option 1) just with echo
TCP_PORT_STATUS=`(echo > /dev/tcp/x.x.x.x/yyyy) >/dev/null 2>&1 && echo "UP" || echo "DOWN"`; echo $TCP_PORT_STATUS

where x.x.x.x is a valid IP ADDR or a HOSTNAME accesible on your network; and yyyy is valid TCP PORT

  • option 2) using Netcat tool
nc -vz IP_Address Port

you need to install netcat tool on you system. For Red Hat like use yum install nc

@rafaeltuelho
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment