Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to listen for multiple tcp connection using nc

Tags:

linux

tcp

netcat

How to create a TCP connection using nc which listens to multiple hosts?

nc -l -p 12345 
like image 516
Aman Jain Avatar asked Apr 19 '15 09:04

Aman Jain


People also ask

Can netcat accept multiple connections?

Simultaneous connections are not possible with netcat . You should use something like ucspi-tcp 's tcpserver tool or leverage xinetd since you're on Linux. Consecutive connections could be handled through a shell script that restarts netcat after it finishes.

Can netcat listen on multiple ports?

You also can use Netcat/nc to scan multiple ports. The syntax is the same as shown previously; just add a space and the ports you want to scan, as shown in the example below in which ports 80, 22, and 53 are scanned.

How do you listen for connections netcat?

On one machine, you can tell netcat to listen to a specific port for connections. We can do this by providing the -l parameter and choosing a port: netcat -l 4444.


1 Answers

Simultaneous connections are not possible with netcat. You should use something like ucspi-tcp's tcpserver tool or leverage xinetd since you're on Linux.

See: https://superuser.com/questions/232747/netcat-as-a-multithread-server

Consecutive connections could be handled through a shell script that restarts netcat after it finishes.

like image 166
Hans Z. Avatar answered Sep 25 '22 08:09

Hans Z.