askvity

How to test ports using telnet?

Published in Network Port Testing 3 mins read

To test if a port is open using telnet, you use a simple command line instruction.

Using Telnet to Test Port Connectivity

Telnet is a basic tool you can use to check if a specific port on a server is open and accepting connections. It's a straightforward way to diagnose network issues.

Telnet Command Syntax

The fundamental telnet command follows this format:

telnet [IP address or hostname] [port number]

For example:

  • telnet www.synology.com 1723
  • telnet 10.17.xxx.xxx 5000 (replace xxx with the actual numbers)

Interpreting Telnet Output

Telnet provides immediate feedback:

  • Port Open: If the port is open and listening, you will see a message like: Connected to 10.17.xxx.xxx (the specific IP or hostname will vary based on the command you used) which indicates a successful connection to the specified port.
  • Port Closed: If the port is closed or no service is listening on that port, you will see a message similar to: Connection refused. This indicates that the port is not accessible and may mean that the service is either not running or the port is blocked by a firewall.

Practical Examples

Let's look at examples:

  1. Testing port 80 on google.com:
    telnet google.com 80
    • If port 80 is open (which is common for HTTP traffic), you should get a connection established.
  2. Testing a custom port (e.g., 3306) on a local server:
    telnet 192.168.1.100 3306
    • This would attempt a connection to the mysql port on the server with IP 192.168.1.100.

Additional Considerations

  • Telnet is a basic tool and does not encrypt data, so it is not suitable for testing sensitive services. Consider using tools that support encryption such as openssl or ncat for security purposes when working with sensitive data.
  • If the connection is successful, the telnet terminal will likely be blank as it establishes a basic connection, meaning it does not use any other protocol such as HTTP.
  • Firewalls can also block telnet connections even if a service is listening on the port.
  • You might have to enable telnet client on Windows systems.

Troubleshooting

If the connection fails, you should check:

  • The server address: Ensure the IP or hostname is correct.
  • The port number: Confirm the correct port number for the service you are trying to reach.
  • The service status: Check that the service is running on the target machine.
  • Firewall rules: Verify that no firewall is blocking the connection either on the client or server machine.
  • Network Connectivity: Make sure your network connection is working correctly
Action Expected Output Meaning
telnet [IP] [port] (e.g., telnet 192.168.1.100 80) Connected to 192.168.1.100 Port 80 is open on the server 192.168.1.100.
telnet [IP] [port] (e.g., telnet 192.168.1.100 9000) Connection refused Port 9000 is closed on the server 192.168.1.100.

Related Articles