linux nc (netcat) UDP Connection refused

0

I faced with some strange nc behavior. It works well with TCP when on one host I do:

nc -tlp 31337

and on the other one:

nc 14.0.0.1 31337  

So there can be some data exchange.
But when I do:

nc -ulp 31337

then

nc 14.0.0.1 31337

fails with:

(UNKNOWN) [14.0.0.1] 31337 (?) : Connection refused

But there are no iptables rules on both listening and connecting sides.

P.S. nc version is v1.10-41

z0lupka

Posted 2019-12-09T12:20:11.233

Reputation: 115

2Check the manual for the meaning of -t. Maybe you though -t means TCP. I don't know all nc implementations but most likely TCP is specified by lack of -u. – Kamil Maciorowski – 2019-12-09T12:37:15.977

Answers

2

The connecting nc needs -u as well. Otherwise it tries TCP and finds no listening process for this TCP port. The last command should be:

nc -u 14.0.0.1 31337

Kamil Maciorowski

Posted 2019-12-09T12:20:11.233

Reputation: 38 429