Search code examples
bashshellconnectionnetcattraffic

Create multiple connections using netcat and send continuous traffic through each netcat connection


#!/bin/bash
for i in `seq 1 1000`;
do
echo sahil | nc -v 10.33.0.32 4050 &
#sleep 1
done

Currently I'm albe to create 1000 nc connections, each connection is running as a process. Now I want all these 1000 connections to send traffic continuously. Need a script through which I can create multiple connections(more than 1000 conns) using netcat and also send traffic continuously through each connection.


Solution

  • You could replace the echo sahil with dd if=/dev/urandom | base64 if you need a bunch of random data, otherwise dd if=/dev/zero could also work.

    I think that technically answers your question, but if you are looking to perform a loadtest on a server, there are many tools such as Apache Bench, or Locust, which will make that much easier.