reply: problem with nc 1.107-4

Brian Inglis Brian.Inglis@SystematicSw.ab.ca
Thu Mar 30 19:52:00 GMT 2017


On 2017-03-30 10:44, Michael Enright wrote:
> On Wed, Mar 29, 2017 at 11:28 PM, 高锋 wrote:
>> Two days ago, I wanted to determine whether a udp port of another 
>> machine is open or not, which is deployed on different subnet. But
>> Windows platform does not provide utility that can do this. So I
>> downloaded a setup.exe from cygwin, of which version is 2.877 (64 
>> bit), and I had never used this utility before.
> 
> I tried this command on Debian 8.7. My conclusion is that this didn't
> tell me that the UDP port is listened to by another machine. I used
> your exact command, which had similarly uninformative results as
> yours. There is no 10.31.x.x machine that I can reach, yet 'nc -u'
> allowed me to send text to that address and port. Strace of 'nc -uz'
> showed that the special -z option (zero i/o port scan) code "sent
> successfully" a single byte to the destination, even though it 
> doesn't exist.
> 
> I conclude that "nc -uz" can't be used to determine unambiguously if
> a UDP host is available, because it will succeed even if the host is
> not present. And that carries to all systems that use the same 'nc' 
> utility as Debian or Cygwin.

man nc CAVEATS says -uz always reports success and suggests how it 
could be used.

nc is used, instead of a network daemon, as a patient network pipe that 
can be used to move arbitrary bytes, without having to previously set 
up direct routes between systems or daemons to handle specific types of 
connections e.g. if you have sshd set up on a target system, and a 
route to it, you may do:

src $ tar -cf - -C /export/mnt/home . | ssh dest tar -xf - -C /nfs/home

with nc if you don't have any direct route to the target or sshd set up 
still you may do:

 dest $ nc -dl 9000 | tar -xf - -C /nfs/home

inter $ nc -dl 9000 | nc 10.123.456.789 9000

  src $ tar -cf - -C /export/mnt/home . | nc 192.168.123.456 9000

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list