Pangram verdict · v3.3
We believe that this text is a mix of AI and human-written content.
AI likelihood · overall
MixedArticle text · 1,631 words · 46 segments analyzed
ACIDVEGAS most dangerous motherfuck x come get some x blog x 2026-11-06 Port 0 is the port you are not supposed to use, so nobody looks there.
So we put an IRC network on it.
Then I got curious whether anyone else had, and scanned all of IPv4 for port 0. Turns out we weren't alone, and some of our neighbours really shouldn't be there. Ask any program to listen on port 0 and it will hand you a socket on port 47193...or 58037...or whatever the kernel felt like that day. Port 0 is not a port you can have. It is the number you pass when you want the operating system to pick one for you. But a TCP header is just bytes. The destination port field is 16 bits wide, and 0x0000 fits in 16 bits as well as anything else does. Nothing on the wire stops a packet from being addressed to port 0. Your tools will refuse it, your browser will block it, and your scanner's default port list skips it, because everyone agrees it isn't a real port. Which makes it a pretty good place to hide things, whether anyone meant to or not.
So we did some TCP cowboy shit & port scanned the entire fucking internet for open ports on port 0, which uncovered some interesting unexpected findings.
What Port 0 Actually Is The standards are thin on this.
RFC 9293, the 2022 consolidation of the TCP spec, defines the source and destination port as "16 bits" and leaves it there. It has no rule against zero. IANA lists 0/tcp and 0/udp as Reserved, pointing at RFC 6335.
That RFC splits the port space into System (0–1023), User (1024–49151) and Dynamic (49152–65535) ranges, and explains what "Reserved" means: Reserved port numbers include values at the edges of each range, e.g., 0, 1023, 1024, etc., which may be used to extend these ranges or the overall port number space in the future.
So port 0 is not forbidden. It is set aside.
The only place zero has a defined protocol meaning is UDP: RFC 768 makes the source port optional, and "if not used, a value of zero is inserted."
TCP has nothing like that.
Why You Can't Listen On It Port 0's reputation comes from the sockets API, not the wire. When you call bind() with sin_port = 0, you are not asking for port 0. You are asking for any port. The ip(7) man page lists every case where Linux hands out an ephemeral port: bind() with port 0, listen() on an unbound socket, connect() on an unbound socket, and sendto() on an unbound datagram socket. The range comes from net.ipv4.ip_local_port_range, which defaults to 32768 60999 on Linux, not the 49152–65535 that IANA calls Dynamic. And asking for port 0 needs no privileges. __inet_bind() only checks CAP_NET_BIND_SERVICE when the requested port is non-zero. How the kernel picks is more interesting than I expected.
In net/ipv4/inet_connection_sock.c (v6.8), inet_csk_find_open_port() starts at a random offset and then does this: offset = get_random_u32_below(remaining); /* __inet_hash_connect() favors ports having @low parity * We do the opposite to not pollute connect() users.
*/ offset |= 1U; It walks the range in steps of two.
The function above it says it outright: "We try to allocate an odd port (and leave even ports for connect())."
Outgoing connections go through __inet_hash_connect() in inet_hashtables.c, which implements RFC 6056 Algorithm 4 (double-hash port selection) and takes the even ports first. The kernel splits the range by parity so servers asking for "any port" and clients making outbound connections don't fight over the same numbers. If SO_REUSEADDR is set, bind() also tries the lower half of the range before the upper half.
That is easy to test.
On a stock Ubuntu box running Linux 6.8: TestResult 2,000 × bind(("127.0.0.1", 0))ports 32777–60997, 2,000 / 2,000 odd same, with SO_REUSEADDRports 32773–46835 (lower half only), all odd listen() with no bind()port 58037 300 × connect() with no bind()source ports 32772–60998, 300 / 300 even So when your program says "listen on port 0", the kernel hears "give me an odd number between 32768 and 61000."
No normal program can listen on port 0.
So We Did It Anyways You can bypass all of this with raw sockets, but if you just want to cheat, you can simply forward the port to another with iptables/nftables. As a fun proof of concept, I set up my IRC network at irc.supernets.org to accept plaintext connections on port 0 and SSL connections on port 1. JUST TO FLEX. 😎 -A PREROUTING -p tcp -m tcp --dport 0 -j REDIRECT --to-ports 6667 -A PREROUTING -p tcp -m tcp --dport 1 -j REDIRECT --to-ports 6697 A SYN arrives for port 0, netfilter rewrites the destination to 6667 where the ircd is actually listening, and the reply is rewritten back on the way out.
The ircd never knows.
Port 1 does the same for TLS on 6697. Talking To Port 0 Is Its Own Problem Getting a server onto port 0 was the easy part.
Getting a client there is where tools give up.
I pointed everything I had at our own server on port 0: ClientResult OpenBSD ncnc: port number too small: 0 telnet (inetutils)Port number 0 is out of range. Chromiumnet::ERR_UNSAFE_PORT (port 1 too) socatconnects, works Python asyncioconnects, works Python ssl on a blocking socketBlockingIOError That last one is strange, because the TCP connection underneath it is fine.
The problem is that the kernel says it isn't, and it does that on purpose.
Here is inet_getname() in net/ipv4/af_inet.c, which backs getpeername(): if (peer) { if (!inet->inet_dport || (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)) && peer == 1)) { release_sock(sk); return -ENOTCONN; } Linux uses "destination port is 0" as its internal marker for "this socket isn't connected to anything."
A socket that really is connected to port 0 trips that check, so getpeername() returns ENOTCONN on a working connection. Python's ssl.wrap_socket() calls getpeername() to decide whether the socket is connected, gets ENOTCONN, decides it isn't, switches to non-blocking and tries a recv(1), gets EAGAIN, and raises BlockingIOError.
The TCP connection is fine.
It just reports that it doesn't exist. Python's asyncio does TLS through memory buffers instead of wrap_socket(), never asks, and works.
Scanning The Internet For Port 0 You can't scan port 0 with connect()-based tools for all the reasons above, but masscan doesn't use the kernel's TCP stack.
It builds its own SYN packets, so port 0 is just another number.
1,173,626 addresses answered with a SYN-ACK.
That sounds like a lot of people using port 0.
It isn't.
Grouped by /24, the responses are packed into a few thousand dense blocks: Hosts answering per /24/24sIPs 128,37028,370 2 – 1010,25334,654 11 – 1001,74753,022 101 – 200865138,300 201 – 2563,751919,280 8% of those /24s hold 78% of the responding IPs.
Whole blocks answer on every address: 172.65.0.0/16 returned 65,534 of 65,536. That isn't 65,534 servers. It's a firewall or router at the edge answering the SYN for everything behind it. 1,116,675 addresses completed the handshake and never sent a single byte. 94% Of The Banners Are A Load Balancer Complaining 56,951 addresses did send something.
Almost all of it looked like this: BIG-IP: [0x31dbae9:14718] {peer} TCP retransmit timeout BIG-IP: [0x31dbae9:4992] {peer} TCP RST from remote system BIG-IP: [0x2bd2afd:5226] SYN timeout (server not responding) F5 BIG-IP load balancers write the reason for a reset into the RST packet, and masscan saved it as a banner.
That's 53,741 of the 56,951 (94%), and 46,583 of them are in 132.246.0.0/16 alone. Drop those, plus 305 hosts returning the same fixed (Ref.Id: ?...?) token, and 2,905 addresses are left. That's about 0.25% of everything that answered. What's Actually On Port 0 ServiceIPsNotes SSH748653 OpenSSH (9 of them OpenSSH_for_Windows), 72 dropbear, one SSH-1.99-OpenSSH_3.9p1 MySQL / MariaDB215versions 3.23 through 11.8, mostly 5.x Telnet211router logins, power switches, rack PDUs HTTP159router admin pages, micro_httpd, building controllers FTP105FileZilla, Microsoft FTP, ProFTPD, GNU inetutils, vsFTPd, Serv-U, lots of NAS boxes SMTP80Postfix, Exchange, Stalwart, spam gateways (masscan called them FTP) DVR / camera protocols44binary recorder protocols sshd refusing43Exceeded MaxStartups instead of a banner VNC39RFB 3.3 through 4.1, one with no authentication OpenVPN21TCP mode, server hard-reset packets Phone system call logs21Avaya IP Office SMDR, more on this below Nobody is running anything exotic on port 0. It's the same stuff that's on every other port: SSH, databases, telnet, FTP. What stands out is how much of it is embedded gear. dropbear, micro_httpd, NAS certificates from QNAP, Synology and Buffalo, DVRs, power switches. Some of it clearly comes from one device model rolled out across an ISP: VERO S.A (Brazil): 145 addresses across six ASNs, all registered as "America-NET Ltda."
132 show the identical telnet login: prompt. The other 13 print a CLI or shell error instead.
ALFANET (Azerbaijan): 32 addresses, every one SSH-2.0-dropbear_0.48.
Great Plains Communications (US): 20 of the 23 "Residential Gateway" login pages.
INVITECH (Hungary): 17 FTP servers announcing AMG1001-T10A FTP version 1.0, with clocks set to early 2000 or 2036. Telekom Srbija: 13 identical MySQL 4.1.22-community-nt, an ancient Windows MySQL build. My guess is that nobody at those ISPs picked port 0 on purpose: a port-forward or NAT rule shipped in a CPE config with the external port left at zero, and the device honored it.
Then there are the hosting providers.
GigaCloud (Ukraine), VDCBY (Belarus) and SiS Distribution (Thailand) have SSH on port 0 with 18, 13 and 10 different SSH version strings.
Different builds means different machines, so these are individual customers, not one firmware image.
GigaCloud also accounts for 16 of the 80 mail servers on port 0, mostly Ukrainian organisations: mail.dtek-kem.com.ua (DTEK, the Ukrainian energy company), smtp01.health24.ua, mx.eastenergy.com.ua, mail.citrus.com.ua, and two government servers, mail.depfin.dn.gov.ua and mail.sed-rada.gov.ua.
Why they all share this setup, I don't know.