How to check if a remote server port is open or not

                                      by Jephe Wu - http://linuxtechres.blogspot.com


Objective: test from a Linux client to decide if remote server port is open or not

Method 1:  telnet

e.g. telnet server1 389  - check if tcp/389 is open on server1 to client


Method 2: nc 

e.g. nc -vz server1 389  - check if tcp/389 is open on server1 to client

or nc -w 5 -vz server1 389 to specify timeout value


Method 3: openssl

Sometimes, there's no telnet or nc available/installed on client, we can try openssl

e.g.  openssl s_client -connect server1:389

 

Method 4: curl 

server 1 has ip 1.2.3.4


[root@server1 unixadm]# curl -v  telnet://1.2.3.4:10002
* About to connect() to 1.2.3.4 port 10002 (#0)
*   Trying 1.2.3.4...
* Connected to 1.2.3.4 (1.2.3.4) port 10002 (#0)

Method 5: from Windows Powershell

PS c:\users\jwu> Test-NetConnection -computername xxxx -port 443


Method 6: Linux bash shell

(timeout 1 bash -c "</dev/tcp/x.x.x.x/8080" && echo -n PORT OPEN || echo -n PORT CLOSED)


No comments:

Post a Comment