I have the following problem. I’m using Debian GNU/Linux Stretch and I am trying to use netcat as a simple server. I start it using following command:
$ netcat -l 127.0.0.1 33333
It starts just fine and accepts connections but on a different port than requested:
$ netstat -tulpn | grep netcat tcp 0 0 0.0.0.0:38782 0.0.0.0:* LISTEN 2851/netcat
This behavior is independent of requested port, user or ufw status. Recently I installed LXC with following packages:
- apparmor
- bridge-utils
- cgmanager
- libapparmor-perl
- lxc
All have been removed later, but somehow I feel like this behavior may be related to some changes in configuration.
Advertisement
Answer
It looks like you are using traditional netcat
which requires providing -p
argument for the listening port:
netcat -l 127.0.0.1 -p 33333
From nc -h
:
-p port local port number
Syntax you use would work with OpenBSD netcat.