Table of Contents
Shell-Kernel-TCP port test
Preface
In this document I’ll try to describe how to do simple test of remote TCP port check with help of Linux kernel.
This test can be performed in case that it’s not possible to use better test like:
# nc # telnet # ….
This method has been tested with:
Linux kernel - Successful Mac OS X - Successful HP Unix – Without Success
Test TCP port Connection
To test TCP connection to remote server it is possible to use Linux Kernel in this way:
# IP=<Destination_IP> ; # IP where to connect # TCP_Port=<Destination_TCP_Port> ; # TCP port where to connect # $(echo> /dev/tcp/$IP/$TCP_Port)>/dev/null 2>&1 && echo "Successful connected" || echo "NOT Successful connected"
Example - Successful
# IP="127.0.0.1" ; # IP where to connect # TCP_Port="22" ; # TCP port where to connect # $(echo> /dev/tcp/$IP/$TCP_Port)>/dev/null 2>&1 && echo "Successful connected" || echo "NOT Successful connected" Successful connected # Result of the test
Example - Unsucessful
# IP="127.0.0.1" ; # IP where to connect # TCP_Port="2222" ; # TCP port where to connect # $(echo> /dev/tcp/$IP/$TCP_Port)>/dev/null 2>&1 && echo "Successful connected" || echo "NOT Successful connected" -bash: connect: Connection refused # If it's possible it will provide you the reason -bash: /dev/tcp/127.0.0.1/2222: Connection refused # Way it was not possible to connect NOT Successful connected # Result of the test