Skip to content
Advertisement

Netcat uses different port than requested

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:

JavaScript

It starts just fine and accepts connections but on a different port than requested:

JavaScript

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:

JavaScript

From nc -h:

JavaScript

Syntax you use would work with OpenBSD netcat.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement