-1

This is a question on Unix software development. I have seen the following questions, which gave rise to my question:

Suppose you are building a service which you later want to package and publish for the Linux distro, and it involves networking. You are making everything by scratch (like not using ssh or HTTP etc.), so you will need some default ports for communication. How does the community (or whoever is responsible) decide which port is to be used and make it reserved?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
  • You seem to have two questions here: One about programming, and the other about how the community allocates ports. Only ask one question at a time. You can ask as many questions as you wish, but one question per question. – ctrl-alt-delor Jul 21 '20 at 16:37
  • Having read the question more thoroughly I now realise that there is one question. However I think the linked questions distract from the meaning of your question. – ctrl-alt-delor Jul 21 '20 at 16:45
  • Thanks for editing! There is confusion on my part that why I have not framed my question firmly. I actually want to know about the process, meaning what role the developer as well as the community which maintains the distro for which the developer is writing the software, plays for assigning a reserved port? – Aaryan BHAGAT Jul 21 '20 at 16:47
  • @ctrl-alt-delor I apologize for hasty writing of the question, the links that I have posted actually are the reason for this question to arise as they say 'some ports are reserved for root where only specific protocols run' so I wondered how one developer gets that port if he wants to build some widely applicable utility like http or ssh. Does this clarify more? – Aaryan BHAGAT Jul 21 '20 at 16:50

1 Answers1

1

Read the content of /etc/services. There are a few comments that will shed some light on this.

E.g.

# Network services, Internet style
#
# Note that it is presently the policy of IANA to assign a single well-known
# port number for both TCP and UDP; hence, officially ports have two entries
# even if the protocol doesn't support UDP operations.
#
# Updated from https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml .
#
# New ports will be added on request if they have been officially assigned
# by IANA and used in the real-world or are needed by a debian package.
# If you need a huge list of used numbers please install the nmap package.

. . .

#=========================================================================

The remaining port numbers are not as allocated by IANA.

#========================================================================= . . .

Services added for the Debian GNU/Linux distribution

. . .

Local services

These are not the only comments in the file.

From this I see a section of ports assigned by IANA. A section that are documented by IANA (but not assigned by), a section assigned by Debian (I am running Debian Gnu/Linux), and a section for me to add locally used ports.

See these pages for more information

The second link above has information on how to register a port. You can also register just a name (ports can be looked up for a particular end-point using DNS).

How would you go about getting a port registered for your software

Step one

Get popular: You won't convince anyone until your software is popular.

What to do now.

Choose a port that is not in use. Chose a default, but make it configurable.

Low numbered ports (reserved for root, or capability CAP_NET_BIND_SERVICE)

You can use these if you have control over the machine. The advantage on a multi user machine, is other users can not use the port: steal the port (DOS), use the port (fake site), etc.

  • Probably more important to choose a unique service name (but also to keep that configurable as much as possible in case of future clashes). As long as you are developing, you can put any port number into /etc/services that follows the conventions and does not conflict with anything else. Restricted applications (like a bespoke system sold to a few hundred customers) don't really need IANA approval because you can fix conflicts easily. When your app is going to conquer the world, you need to plan for IANA approval. – Paul_Pedant Jul 21 '20 at 17:00
  • There’s no popularity requirement for IANA assignments, it’s possible to request a port number for a new service which isn’t widely used yet. – Stephen Kitt Jul 21 '20 at 17:18
  • @StephenKitt Agreed, but it looks like the ultimate namespace in respect of pollution. I'm surprised Apple and Google have not claimed every slot already. – Paul_Pedant Jul 22 '20 at 08:46