tcpiana

Where is IANA (port numbers registry) saved?


I was wondering where can I access the IANA registry?

Is it implemented in the OS?

How do applications know which port to connect to, to be exact where to compare the port numbers?

Some apps have the port numbers hardcoded and some have you input it, but where exactly is the comparison done?

Or is it all human based and is it on the devs to use port 80 when they know they will be connecting to a http server?

I can't get my head around this, because there are well known ports, which you can't use for your apps. Or can you? Is the port free to use when no process binds it? So I could use port 80, 25, 443 or whatever under 1000 and all I would need for that is root privileges?


Solution

  • You really have two big questions here. First, where is IANA. That answer is easy: http://iana.org

    But I think what you are really asking is in the rest of your post. The file that you are looking for on the system is the services file. This is typically in /etc/services on a UNIX style system, though you'll find it in C:\Windows\System32\drivers\etc on Windows systems.

    All that this file really is is a mapping file to allow you to request a service by name (let's say "telnet", for instance) and have the system translate it to the port number (23).

    It is best practice when writing software to use the name, if possible, rather than the number. Not only does this allow the notion of "well known ports" to be applied, but if you have an unusual situation where a service needs to be run on some other port, simply modifying the services file allows the service to be easily remapped.

    You have another question here about privileges to use ports. First, if you're using Windows, there's really no such notion. The idea of "privileged" ports is found on other operating systems (UNIX, VMS, etc.). On those systems you would need to be root or the OPERATOR equivalent. This applies for ports less than 1024, not 1000.

    That said, there's really nothing special about port 80 except that one would expect to find a web server there.