How to probe remote Services using a shell script

59 views Asked by At

I have a project that needs to detect different service ip to distinguish between internal network or external network access.

At the beginning, I used the following nc command to detect, but the company did not allow it due to security issues

ret=$(nc "$internal" "$port" < /dev/null; echo $?)
if [ $ret = 0 ];then
  echo "The service can be accessed through the $internal"
  using=$internal:$port
else
  using=$external:$port
fi

Telnet is an optional way telnet $host $port, but this will occupy the terminal, and my goal is to detect whether it is accessible to determine the use of the internal network and external network

May I ask how to modify the telnet command, or use other methods (try to be native to be compatible with most environments) to achieve detection?

Looking forward to your reply.

0

There are 0 answers