How to test connectivity if Telnet or Putty is not available

When reporting a Foglight connectivity issue, support people are always asking to test the connection using Telnet or Putty. But what to do if you do not have Telnet or Putty installed?

There are some other options, for example using an Internet browser or running command line tools like curl or netcat.

So let’s start with the browsers. To test the connection you type in the address line:

http://<host>:<port>

For example: http://192.168.1.218:8080

You can test even other ports like the UDP port 135 or the DB port 1521. Based on the reply you get from the browser, you will know if the port is open or not. Now each browser shows different messages, below some examples from Chrome, Internet Explorer and Firefox.

 

Chrome:

When you see the blow message you know, that the port is blocked and/or not listening.

 

The following screen shots can appear, if the port is open, but the request is rejected for another reasons, for example the return content is not a web content which can be displayed in a browser:

 

Internet Explorer:

The following 2 screen shots could come up, if the port is blocked and/or not listing:

 

If the port is open but rejecting the request for another reason, you will get the message below:

 

Firefox:

The port is blocked and/or not listening:

 

The port is open, but rejecting the request for another reason:

 

On Unix machine there are 2 more commands you use to test connectivity: netcat and curl. Below some examples how to run the commands.

Using netcat on a Linux (CentOS) server

If the port is open you will get a new blank command line or message "connection reset by peer" - examples:

[root@foglight /]# nc 192.168.1.48 8080 < /dev/null
[root@foglight /]#

[root@foglight /]# nc 192.168.1.48 135 < /dev/null
[root@foglight /]#

[root@foglight /]# nc 192.168.1.50 1433 < /dev/null
[root@foglight /]#

[root@foglight /]# nc 192.168.1.48 5029 < /dev/null
Ncat: Connection reset by peer.

[root@foglight /]# nc 192.168.1.41 1521 < /dev/null
[root@foglight /]#

If you get the output "Connection refused" the port is closed.

[root@foglight /]# nc 192.168.1.48 8081 < /dev/null
Ncat: Connection refused.

 

Using netcat on Oracle Linux or RHEL (the commands are a bit different):

[root@foglight2 orauser]# nc -vz 192.168.1.215 8080 < /dev/null
Connection to 192.168.1.215 8080 port [tcp/webcache] succeeded!

[root@foglight2 orauser]# nc -vz 192.168.1.215 135 < /dev/null
Connection to 192.168.1.215 135 port [tcp/epmap] succeeded!

[root@foglight2 orauser]# nc -vz 192.168.1.218 1433 < /dev/null

Connection to 192.168.1.218 1433 port [tcp/ms-sql-s] succeeded!

[root@foglight2 orauser]# nc -vz 192.168.1.215 5029 < /dev/null

Connection to 192.168.1.215 5029 port [tcp/infobright] succeeded!

[root@foglight2 orauser]# nc -vz 192.168.1.216 1521 < /dev/null
Connection to 192.168.1.216 1521 port [tcp/ncube-lm] succeeded!

 

Same like under CentOS, if you get the output "Connection refused" the port is closed.

[root@foglight2 orauser]# nc -vz 192.168.1.215 8081 < /dev/null
nc: connect to 192.168.1.215 port 8081 (tcp) failed: Connection refused

 

And how to use curl?

The simplest way to use it, is shown in the examples below. You can create much complex URIs, but let us keep it simple here.

If you use curl without a protocol prefix it will use HTTP by default. That means you might get a protocol mismatch error or curl will stop if the listener is not a web service. If that happen, you know the port is open and listen.

If curl cannot connect, it will time out or you will get "Connection refused" message.

Examples:

This is a blocked port either closed or blocked by a firewall:

[root@foglight /]# curl 192.168.1.48:8081
curl: (7) Failed connect to 192.168.1.48:8081; Connection refused

 A PI repository is running on a remote server:

[root@foglight /]# curl 192.168.1.48:5029
curl: (56) Recv failure: Connection reset by peer

An open FMS webpage, there is no error and a new command line entry is displayed:

[root@foglight /]# curl 192.168.1.48:8080
[root@foglight /]#

This is open Windows RPC port, which established a connection. Use Ctrl-C to end the connection:

[root@foglight /]# curl 192.168.1.48:135
^C
[root@foglight /]#

This is an open SQL Server port:

[root@foglight /]# curl 192.168.1.50:1433
curl: (52) Empty reply from server

This is an open Oracle port:

[root@foglight /]# curl 192.168.1.41:1521
curl: (52) Empty reply from server

 

 

Details are from solution 238273.

Anonymous