Late one evening, I found myself staring at the terminal, faced with a daunting task: testing ports on a remote server. But there was a catch—telnet was no longer installed, and I wasn’t eager to bring back the old tool. That’s when I discovered a set of modern alternatives that changed the way I approach port testing forever. Here are the tools that saved the day.

Telnet Alternatives for Port Testing in Linux

Late one evening, I found myself staring at the terminal, faced with a daunting task: testing ports on a remote server. But there was a catch—telnet was no longer installed, and I wasn’t eager to bring back the old tool. That’s when I discovered a set of modern alternatives that changed the way I approach port testing forever. Here are the tools that saved the day.

If you want to test ports in Linux without using the deprecated telnet command, here are some great alternatives:

1. Netcat (nc)

netcat (or nc) is a versatile tool that can test connections on specific ports.

Usage:

nc -zv <hostname or IP> <port>
  • The -z option is for scanning without sending data.
  • The -v option enables verbose output.

Example:

nc -zv google.com 80

2. Nmap

nmap is a powerful network scanning tool that can test whether a specific port is open.

Usage:

nmap -p <port> <hostname or IP>

Example:

nmap -p 80 google.com

3. Curl

curl is typically used for transferring data but can also test connections to ports (especially HTTP/S).

Usage:

curl -v telnet://<hostname or IP>:<port>

Example:

curl -v telnet://google.com:80

4. OpenSSL (openssl s_client)

openssl is useful for testing SSL/TLS connections to a port.

Usage:

openssl s_client -connect <hostname or IP>:<port>

Example:

openssl s_client -connect google.com:443

5. Socat

socat is another versatile networking tool, similar to nc but with more advanced features.

Usage:

socat - TCP:<hostname or IP>:<port>

Example:

socat - TCP:google.com:80

6. Bash /dev/tcp

Bash itself can be used to test ports by accessing /dev/tcp.

Usage:

echo > /dev/tcp/<hostname or IP>/<port> && echo "Port is open" || echo "Port is closed"

Example:

echo > /dev/tcp/google.com/80 && echo "Port is open" || echo "Port is closed"

Summary of Tools

  • Netcat (nc): Lightweight and flexible for general port testing.
    • Install on Debian/Ubuntu: sudo apt install netcat
    • Install on RHEL/CentOS/Fedora: sudo yum install nc
    • Install on Alpine: sudo apk add netcat-openbsd
  • Nmap: Full-featured port scanning tool.
    • Install on Debian/Ubuntu: sudo apt install nmap
    • Install on RHEL/CentOS/Fedora: sudo yum install nmap
    • Install on Alpine: sudo apk add nmap
  • Curl: Great for testing HTTP/S ports.
    • Install on Debian/Ubuntu: sudo apt install curl
    • Install on RHEL/CentOS/Fedora: sudo yum install curl
    • Install on Alpine: sudo apk add curl
  • OpenSSL: Ideal for testing SSL/TLS connections.
    • Install on Debian/Ubuntu: sudo apt install openssl
    • Install on RHEL/CentOS/Fedora: sudo yum install openssl
    • Install on Alpine: sudo apk add openssl
  • Socat: Powerful and versatile tool for advanced scenarios.
    • Install on Debian/Ubuntu: sudo apt install socat
    • Install on RHEL/CentOS/Fedora: sudo yum install socat
    • Install on Alpine: sudo apk add socat
  • Bash /dev/tcp: Simple and built-in for basic port testing (available in Bash without needing installation).