3

so... we know that we can test that if a port is open on the firewall with:

telnet SERVERIP PORT

..but afaik there are services that can't be tested with telnet, because ex.: telnet doesn't know that protocol that the service is using, and telnet will report that the port is closed, but in reality the service is up&running.

Q: first: was I correct about telnet? second: What to use for testing that a port is opened on a server? (so it's not blocked by a firewall) - are there any unix tools for this?

  • Have a look at nmap. It probably can do more than you will ever need. – Marco Jan 25 '13 at 15:58
3

On the first question, maybe the service does not wait for interactive input. There could be other explanations, too. On the second, nmap can be used to test the firewall. There are many options.

Scan the first 1,000 ports (default):

nmap -v -A -PN hostname.domainname.com

Or perhaps a specific range:

nmap -v -A -p 10000-11000 -PN hostname.domainname.com
  • so you are saying that an: nmap -v -A -p PORTNUMBER -PN hostname.domainname.com is the best solution? – gasko peter Jan 25 '13 at 19:33
  • 1
    If you want to see all open ports on a firewall you can chuck the following at it: nmap -v -p- <IP address or hostname>. Of course, a lot of configurations might mean that certain services might not respond, then you'll have to get clever with the switches but there's plenty of resources. – I_GNU_it_all_along Aug 17 '17 at 14:17
2

Your comment about telnet not being appropriate in all cases puzzled me, so I ran a quick network trace while connecting to some arbitrary ports (in this case an HTTP server and a DICOM server).

In all cases I can confirm that telnet merely opens its socket to the TCP connection but neither tries to read from it nor write to it until you explicitly type a line.

This means your TCP stack will just initiate a standard TCP handshake and the three packets involved (SYN/SYN-ACK/ACK) will be the only ones to ever travel the wire. These of course aren't specific to any application.

tl;dr It seems to me that telnet is in fact absolutely appropriate to test whether a specific port is open or not, regardless of the protocol spoken by the server listening behind it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.