Why does '~$ nc -z T43 1-1024' not produce any output although '~$ ping T43' is successful?
'~$ nc -z -v T43 1-1024' prints 'Connection to T43 22 port [tcp/ssh] succeeded!' and 'nc: connect to T43 port 1000 (tcp) failed: Connection refused.'
'man nc': "PORT SCANNING: It may be useful to know which ports are open and running services on a target machine. The -z flag can be used to tell nc to report open ports, rather than initiate a connection. For example: '$ nc -z host.example.com 20-30'.
I've checked the source code, first the original (netcat-openbsd_1.89.orig.tar.gz). The relevant lines in
netcat.c
(367-388) (edited):But the diff package (netcat-openbsd_1.89-4ubuntu1.diff.gz) contains a patch, removing the verbose display functionality:
So it seems that without the
v
flag, thez
flag branch never „runs” and does not display the message. (Although I'm not an expert C programmer, so please take this with a bit of skepticism.)Also the changelog refers to this:
The Debian bug report for #464564 contains the following:
So I think it is a bug in the manual page: the port scanning section have not followed the changed functionality.