TCP specifies 2^16 ports, 65536, much more than are typically used. In fact, the port zero is almost never used, or, as [Acid Vegas] found out, about 0.25% of hosts globally (give or take) to be precise. The reason is not technical, in fact TCP supports it quite well, but rather social. If one were to request the Linux kernel provide you with port 0, it would actually provide you with a randomly allocated even port between 32768 and 61000. But, there are, of course, ways around this. Raw sockets or, the route [Acid] takes, IPTables/NFTables port mapping. By this, plain text IRC is bound to irc.supernets.org on port 0, and TLS on port 1.
But, should you go try to connect to this IRC server, you will find most userland programs simply refuse to accept a port of 0. BSD NC and Telnet will simply tell you the port is too small. Chromium and Firefox derived browsers will warn you its unsafe. And Python SSL will give you an IO error. However, Python AsyncIO and socat work just fine. Once again, this is not technical limitation of the port, but rather a reflection of the fact that there really isn’t a reason to use it.
Should you go looking on the internet for hosts using port zero, you will find they mostly appear accidental. Mostly likely a network device defaulted to a strange configuration that no one noticed. Regardless the reasons, some strange services are using the port. SSH, mostly DropBear, suggesting IoT or networking devices like routers. Likewise, Telnet appeared on a number of embedded devices. HTTP router admin pages also appear on the port. But, if you remember, browsers don’t let you use port 0, so you need to set up a local port forwarding rule if you want to connect.
While a handful of other services including RustDesk are on port 0, the most interesting is Station Message Detail Recording. SMDR is a simple TCP protocol which logs the outputs of phone calls in plain text.
If you like Linux networking, make sure to check out this VPN hack next!
Thanks [adistuder] for the tip!








