@georgiana.senger
Creating such a large number of TCP connections on a single Linux machine can be challenging due to system resource limitations. Here's a general approach to achieve it:
- Increase system limits:
Open the /etc/security/limits.conf file and add the following lines:
* soft nofile 100000
* hard nofile 100000
Modify the /etc/sysctl.conf file and add the following lines:
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 1024 65000
Apply the changes using the command sudo sysctl -p.
- Disable reverse DNS lookup:
Open the /etc/ssh/sshd_config file and add the following line:
UseDNS no
Restart the SSH service with the command sudo service sshd restart.
- Modify TCP configuration:
Open the /etc/sysctl.conf file and add the following lines:
net.ipv4.tcp_max_syn_backlog = 16384
net.core.somaxconn = 16384
Apply the changes using the command sudo sysctl -p.
- Writing a script:
Use a programming language (e.g., Python, C) to write a script that establishes TCP connections.
Use a loop to create and maintain connections. For example, in Python:
import socket
for _ in range(50000):
sock = socket.socket()
try:
sock.connect(('127.0.0.1',
- Run the script:
Execute the script with appropriate configurations.
Monitor system resource usage and adjust the script if necessary.
Note: Creating and maintaining a large number of TCP connections may have implications on system performance and resource availability. Ensure that your system is capable of handling such a high load.