Summary

TPC 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! TCP. IANA reserves port 0. (TCP/UDP) Convention is to request port 0 to be assigned an arbitrary port. Exceptions exist in actual implementations. The entire internet is a social construct. This triggered a memory of an odd discovery I found when working on an F5 LTM 3400, where they used a non-standard network space for the internal appliance network. (And no, not the CGNAT space) The system had two subsystems inside the TMM (some x86, Pentium 4 I think?, RHEL5?) and SCCP (MIPS?, some embedded Linux). The TMM had the application control logic, web interface, etc, while the SCCP did the more “low-level” functions. Inside the Appliance it had an internal network that would allow communication between the two components. The part that weirded me out at the time, was they used the 127.0.0.0/8 network space. It was a clever hack to keep from IP address conflicts inside a corporate network. (Which at the time we used it, IP space was a concern, RFC 6598 was still rather new, and we were unaware of VRFs.) While poking around in the LTM 3400 to see how it worked, I looked at the hosts file and saw that the TMM had an IP address of 127.2.0.1, and the SCCP, 127.2.0.2. No, not the 172.16.0.0/16 space, loopback space. I guess the folks working on the F5 were able to patch or tweak the kernels on both subsystems (or some other black magic), to use it as an internal network. While in use, from an application perspective everything functioned as expected, but it’s an interesting trick. Might have to dig it out again to see how they did it. (Just need to do something about the fans) Reference link: https://community.f5.com/t/arp-requests-for-127-2-0-1/7222 New comment system is nice, but doesn’t keep me from making simple mistakes. For anyone who bothers to read, I forgot to add a comma after the first “inside” on the second block. There were two boards in the LTM, the TMM and the SCCP (with the 10 port embedded switch)

By Fenix Guthrie

Original Article