Check Remote Ports Are Reachable

1 minute read

In some cases when I have to check if remote TCP port is open, where different tools are installed on machines and absolutely nothing can be added I have still a chance to find something what can be used. I have a few tools on my list such as netcat (nc), curl, telnet, nmap, bash, perl or even python.

First of methods is netcat which is easy to use and available almost on any Linux distribution. To check if port is open on run:

1nc -vz <server> <port>

The second one is TELNET. It’s basically a simple clear-text TCP connection to the target host and port.

1curl telnet://<hostname>:<port>

If ‘netcat’ or ‘curl’ isn’t available, we can try to use ‘wget’ command.

1wget -qS -O- https://<hostname>:<port> 

If none of them are installed and you have a recent enough version of bash, we can can try to use the simplest bash solution. It’s good enough to check if the port is open, or close. Advanced Bash-Scripting Guide: /dev and /proc

1cat </dev/tcp/<hostname>/<port>