Solved [Solved] nc: strange behaviour

Hello,

nc(1) reports a successful a connection to any port when using UDP. Even if the port is not opened. Am I misunderstanding something or is this really a bug?

Code:
# sockstat -4l | grep 123
# nc -zu localhost 123
Connection to localhost 123 port [udp/ntp] succeeded!
 
Re: nc: strange behaviour

UDP is a stateless transport protocol, you send data and hope for a reply. In this case nc(1) just reports that it was able to send UDP packet(s) with destination address localhost and port 123 but since UDP is stateless there's no way for it to know if they were ever received at the destination. With TCP there's always the three way handshake that is defined in the standard that can be used to reveal if a port is open or not.
 
Back
Top