Search
Thursday 27 November 2014
  • :
  • :

Commands to find opened or closed ports in remote linux box

 

In this post i am going to explain about how to find a port is opened orĀ  in remote Linux / Unix box.

This may be achieved by using three command prompt tool. They are

  1. telnet,
  2. nmap and
  3. nc.

 

 

Telnet:

Using the telnet command we may trace whether the remote machine port is opened or not.
Sample example is given below

[root@client ~]#telnet yahoo.com 443
Trying 72.30.38.140…
Connected to yahoo.com (72.30.38.140).
Escape character is ‘^]’.

If the output is like connected to yahoo.com(remote machine) and in the next line Escape character is ‘^]’ . It clearly tells that 443 is a open port for domain yahoo.com

[root@client ~]# telnet yahoo.com 22
Trying 72.30.38.140…
telnet: connect to address 72.30.38.140: Connection timed out

In the above example i am trying to find whether ssh port 22 is opened for yahoo.com(remote machine).
Its showing Trying 72.30.38.140(server IP) and connection timed out. It clearly shows that the remote host is not reachable.

Netcat(nc)

Using the nc command also we may trace whether the remote host port is opened or closed.
Sample example is given below.

[root@client ~]# nc -z google.com 80
Connection to google.com 80 port [tcp/http] succeeded!

-z —–> Specifies that nc should just scan for listening daemons, without sending any data to them.

nmap:

nmap is the best way to find the port check. It shall gives you all the details you are expecting.
Sample example for nmap.

[root@client ~]# nmap -v -A -p 80,443 google.com