I don't understand the behaviour of netcat. Let's say that I have one host acting as server:

[root@localhost tmp]# nc -u -l -p 670

Then I try to connect from a client:

root@debian:/tmp#  nc   -u 670

Meanwhile I try to capture those packages:

[root@localhost sergio]# tcpdump -nn -i wlp7s0 port 670

I see no packets at all, only when I issue something like:

root@debian:/tmp#  echo "Hola Mundo" | nc   -u 670

[root@localhost sergio]# tcpdump -nn -i wlp7s0 port 670
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wlp7s0, link-type EN10MB (Ethernet), capture size 65535 bytes
01:37:39.425276 IP > UDP, length 12

I wonder if is it the proper behaviour of netcat. Why is the reason why it's not seen any packets except when I send something from stdin?


Because you are using UDP. There is no connection setup in UDP before sending any packets like you have with TCP, which means you only see packets if actual data gets transferred. And netcat sends only the data it gets from stdin.

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.