2

I have tried to launch a script to listen to thousands of tcp ports (1000 to 10000) but it appears to be hitting a limit of 1024 listening ports. I've confirmed this via netstat and closed ports above certain ranges.

Is there a fixed limit of listening ports in linux and how, if possible, can this be raised?

2 Answers2

4

You are probably hitting at nofile limit, which is by default 1024.

Try raising ulimit -n in your shell before running the program, like:

$ ulimit -n 20480; ./myprogram

Offcourse, you have to have priviledge to raise nofile limit so high, so check current soft and hard limits with:

$ ulimit -a

And raise them in /etc/security/limits.conf or /etc/security/limits.d/*conf

Jakov Sosic
  • 5,267
  • 4
  • 24
  • 35
0

By the way I didn't mention that the program/script is launched by xinetd, and that xinetd is ignoring the ulimit nofile settings, looking at the xinetd source now to try and bypass this limitation.