K
K
Konstantin2020-04-30 20:28:51
linux
Konstantin, 2020-04-30 20:28:51

What is the best TCP port to use for tcp/ip server on linux?

Hello.
I am writing a tcp/ip server under linux. It will listen on 3 ports and work 24/7, so there should be no overlap with other programs that can use ports from this range.
Therefore, the question arises: what ports can you use for your server?

From the wiki:

All ports are divided into three ranges - well-
known (or system, 0-1023),
registered (or user, 1024-49151)
and dynamic (or private, 49152-65535).

I guess my range is 49152-65535.

But:
The range 49152-65535 contains dynamically allocated or private ports that are not registered with IANA. These ports are used for temporary (short-lived) client-server connections or in certain special cases.

Answer the question

In order to leave comments, you need to log in

7 answer(s)
C
CityCat4, 2020-05-01
@webmaster

Any.
Except those in /etc/services

K
ky0, 2020-04-30
@ky0

Your server - take any port that you are not going to occupy with something else. The only caveat is that in Linux, by default, unprivileged users cannot bind to ports below 1024.
Or better, make some kind of default and the ability to change it.

K
Karpion, 2020-04-30
@Karpion

I would clarify that ports that are scanned and brute-forced should not be used - so that your programs are not forced to respond to hackers' attempts to break into your system. An example list is:

  • 20.21 - FTP
  • 22-SSh
  • 23 - Telnet
  • 25-SMTP
  • 143.993 - IMAP4
  • 80 - HTTP
  • 110-POP3
  • 3128 - Squid
  • Samba, OpenLDAP, well-known SQL servers - I don't remember the ports, too lazy to look
Probably, the comrades will add some more to the list, I probably didn’t remember everything.
Denis Sechin suggests " do not run tsp daemons on the server with a selected port " - well, if you select a port that some daemon needs, then there will be problems with the prohibition to run this daemon.

R
Ruslan, 2020-04-30
@msHack

According to RFC standards, any between 1024-49151
or in the range from 1024 to 49151, for example, 1025, 1026, 1027, 2029, 33252, and so on, up to at least 11111
and dynamic (or private, from 49152 to 65535, their router may not miss

F
fara_ib, 2020-04-30
@fara_ib

Increasing TCP port range with net.ipv4.ip_local_port_range
blog.sedicomm.com/2018/06/10/uvelichenie-diapazona...

D
Denis Sechin, 2020-04-30
@tamogavk

Select any from 1000 to 65534, do not run tsp daemons on the server with the selected port

F
foxyhunt, 2020-05-10
@foxyhunt

Any custom port will work for you. The main thing is that there is no intersection with the current server and client software.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question