Tuesday, April 7, 2015

How to view or scan accessible ports on remote server


If you are working with virtual machines, sometimes you have to test ports between machines. If you want to check specific port, the best way is to use telnet command,
[akila@localhost ~]# telnet <target IP> <target Port>
If you want to check port range you can use nc command to check.
[akila@localhost ~]# nc -z <target IP> <Starting Port>-<End port>
Ex,
[akila@localhost ~]# nc -zw3 192.166.200.55 23-33
It will check ports connectivity between 23 and 33.
Also you can write a small script to check port connectivity using below command,
[akila@localhost ~]# nc -zw3 <target IP> <target Port> && echo "port opened" || echo "port closed"

Ex,
[akila@localhost ~]# nc -zw3 192.166.200.55 88 && echo "port opened" || echo "port closed"


This will print "port opened" if the port connection is opened and will print "port closed" if the port closed.
You can use nmap command to do the same job. But most often nmap is not coming with default installation of the Operating System.

No comments:

Post a Comment