Linux – Run ncat in background

linuxnetworkingnmaptcp

from some time I'm trying to resolve very annoying issue:

I need to have simple server which will listen on particular TCP port and throw all information which it recieve to trash. I'm doing it by running ncat:

ncat -l 192.168.1.1 49111 -k -m 50

As everyting is working fine I want to run ncat in background. After some testing I decided to keep it running with screen:

screen -dm ncat -l 192.168.1.1 49111 -k -m 50

And still – everything is working fine except one thing: it refuses connections from time to time, no matter what is after -m parameter. Sometimes after few minutes, sometimes after few hours… Only way to make it working is to kill process and start it again.

Did you have similar problems? Or maybe you can suggest me another solution?
I'm working at Virtualized workstation with CentOS. Do you think working at VM might cause this issue?

Best Answer

If running it in the background is your problem, you can use nohup instead of screen

nohup ncat -l 192.168.1.1 49111 -k -m 50 &

You can then use fg, bg, jobs to interact with it if needed, as long as you don't exit the shell.

If ncat is the problem, please provide more information about what you're trying to do.

You could use tcpserver from ucspi-tcp

tcpserver 192.168.1.1 49111 cat > /dev/null