← Networking
Linux · Networking
How to test if a remote port is open in Linux
Check whether a TCP port on a remote host is reachable with nc, bash /dev/tcp, and curl, without installing telnet.
Check whether a service is reachable on a remote host and port, for example an Oracle listener on 1521. nc is the usual tool; the bash /dev/tcp trick works with no extra packages.
# netcat: zero-I/O scan, verbose
nc -zv <host> 1521
# Pure bash, no tools needed
timeout 3 bash -c '</dev/tcp/<host>/1521' && echo open || echo closed
# HTTP endpoint status code
curl -sS -o /dev/null -w '%{http_code}\n' http://<host>:8080LinuxncPorts