Friday, January 28, 2011

How to check if a port is open for remote system(ubuntu)

Is it possible to check that if the ports are open for the remote system on ubuntu server?

I should able to check if a port(eg:ssh) on my machine is open for the remote machine.

  • Use NMAP. Example:

    nmap example.com

    You can use IP address in place of domain name. Here is the full documentation: http://nmap.org/book/man.html

    : Its only listing the ports on which services are running on a specified machine.
    Christoffer Hammarström : Then you're using it wrong.
    Josh : @user53864, that is correct. More specifically, it will list all OPEN ports and also describe what services are using them. If you are looking for a specific port, try simply "nmap example.com 22" as natxo asenjo said, which will scan port 22 (SSH) to see if it is open.
    From Josh
  • nmap example.com -p 22

    From Sudheer
  • use good old telnet:

    [user@lappie ~]$ telnet host 22
    Trying ip.adr.tld ...
    Connected to host  (ip.addr.tld).
    Escape character is '^]'.
    SSH-2.0-OpenSSH_5.1p1 Debian-5
    

    this is a successful attempt. An unsuccessful one should look like this;

    [user@lappie ~]$ telnet host 23
    Trying ip.adr.tld ...
    telnet: connect to address ip.adr.tld: Connection refused
    telnet: Unable to connect to remote host: Connection refused
    

    or with nmap

    [user@lappie ~]$ nmap host
    
    Starting Nmap 5.21 ( http://nmap.org ) at 2010-10-07 11:25 CEST
    Nmap scan report for host (ip.adr.tld)
    Host is up (0.0052s latency).
    rDNS record for ip.adr.tld : host.domain.tld
    Not shown: 995 closed ports
    PORT     STATE SERVICE
    22/tcp   open  ssh
    80/tcp   open  http
    111/tcp  open  rpcbind
    3000/tcp open  ppp
    5666/tcp open  nrpe
    
    Nmap done: 1 IP address (1 host up) scanned in 0.18 seconds
    
    : Great help!. I felt It's only listing the port no's for which the services are running on the specified host. I checked it stopping the services and running nmap command again. so it didn't list the port which I stopped. Is it really showing the open ports for remote machine?
    natxo asenjo : @user53864: you should run this test on a remote machine, obviously.

0 comments:

Post a Comment