How to check whether certain port is opened or block on any other servers from a dev box?

69,212

Solution 1

From your dev box you could likely just use telnet if it's a TCP port:

telnet sc-host01.vip.slc.qa.host.com 9042
telnet sc-host01.vip.slc.qa.host.com 9160

If you get a timeout error, then the port is blocked.

Solution 2

You can use NMAP to test them (available in most distributions)

nmap -p T:9042 sc-host01.vip.slc.qa.host.com
nmap -p T:9160 sc-host01.vip.slc.qa.host.com

Edit: If the staging server has filtered ports and no response, it's likely that Cassandra server is dead or those ports filtered by IPTables/Firewall

Share:
69,212

Related videos on Youtube

SSH
Author by

SSH

Updated on September 18, 2022

Comments

  • SSH
    SSH almost 2 years

    I am trying to connect to one of our staging Cassandra servers on port 9042 and 9160 here in our company from a dev box.. Through the code, I am not able to connect to it... The program gets hanged at my SELECT query..

    So I am wondering is there any way to figure out from my dev box whether these two ports are either blocked on my Cassandra staging servers or not?

    Below is the Cassandra staging server url which I am trying to connect from my dev box -

    sc-host01.vip.slc.qa.host.com

    And my dev box machine url is -

    username-dyn-vm1-4.phx-os1.tratus.dev.host.com

    Can anyone tell me how to figure out what can be the possible reason to which I am not able to connect to it..

    How to check from my dev box whether these ports are opened or not on my Cassandra staging servers?

    Update:-

    This is what I got when I ran nmap -

    ubuntu@username-dyn-vm1-4:~/build$ nmap -p T:9160 sc-host01.vip.slc.qa.host.com
    
    Starting Nmap 6.00 ( http://nmap.org ) at 2013-10-13 20:01 UTC
    Nmap scan report for sc-host01.vip.slc.qa.host.com (10.109.107.64)
    Host is up (0.0037s latency).
    rDNS record for 10.109.107.64: stgcass01-1.vip.slc.qa.host.com
    PORT     STATE SERVICE
    9160/tcp open  apani1
    
    Nmap done: 1 IP address (1 host up) scanned in 0.19 seconds
    ubuntu@username-dyn-vm1-48493:~/build$ nmap -p T:9042 sc-host01.vip.slc.qa.host.com
    
    Starting Nmap 6.00 ( http://nmap.org ) at 2013-10-13 20:02 UTC
    Nmap scan report for sc-host01.vip.slc.qa.host.com (10.109.107.64)
    Host is up (0.0049s latency).
    rDNS record for 10.109.107.64: stgcass01-1.vip.slc.qa.host.com
    PORT     STATE SERVICE
    9042/tcp open  unknown
    
    Nmap done: 1 IP address (1 host up) scanned in 0.11 seconds
    

    Does that mean port is opened correctly and there is no problem?

    And with telnet I get this -

    ubuntu@username-dyn-vm1-4:~/build$ telnet sc-host01.vip.slc.qa.host.com 9042
    Trying 10.109.107.64...
    Connected to stgcass01-1.vip.slc.qa.host.com.
    Escape character is '^]'.
    ^CConnection closed by foreign host.
    
    ubuntu@username-dyn-vm1-4:~/build$ telnet sc-host01.vip.slc.qa.host.com 9160
    Trying 10.109.107.64...
    Connected to stgcass01-1.vip.slc.qa.host.com.
    
  • SSH
    SSH over 10 years
    I should use the above command to run from my dev box? Right? And what is 192.168.1.1? This should be replaced with my staging servers hostname?
  • SSH
    SSH over 10 years
    btw, I cannot run nmap in my dev box ubuntu machine.. It says command not found?
  • thompson27502
    thompson27502 over 10 years
    Run sudo apt-get install nmap first
  • SSH
    SSH over 10 years
    I just installed and now nmap is working fine.. I updated my question with the details of nmap.. Can you take a look and let me know if those results means port is opened? If it is opened then what can be the other problem?
  • thompson27502
    thompson27502 over 10 years
    That means that the server is accepting connections on that port, given the port numbers uniqueness it's most likely your Cassandra server, and that you have (from the nmap testing box) an open communication channel to it.
  • SSH
    SSH over 10 years
    After trying this, I got connected to some server name.. Updated my question as well for this test..
  • SSH
    SSH over 10 years
    Then what can be the other problem? Why I am not able to connect to those staging servers through code? Is there anything else we can do?
  • Jensen010
    Jensen010 over 10 years
    So the question then becomes, is the server you connected to, the one you wanted to connect to ? (ie. eliminate the possibility of a DNS problem...)
  • thompson27502
    thompson27502 over 10 years
    I'm not too familiar with Cassandra outside of the general idea but most likely your next steps should be: checking a local loopback connection from the server itself - if possible to make sure that some extra ports are not filtered. Second step (if the first one is good or can't be done) is double checking your auth credentials since that's the most common failure in DB connections. Third step is using some tool that you know works with this Cassandra server from your dev box to make sure that it's not your code that is bad.
  • SSH
    SSH over 10 years
    Yeah kind of I guess...
  • thompson27502
    thompson27502 over 10 years
    For step 1 and 3, I found some info that might help you connect and test the server manually.
  • SSH
    SSH over 10 years