Skip to main content

LAN_PORT_RANGE

Constant LAN_PORT_RANGE 

Source
pub const LAN_PORT_RANGE: RangeInclusive<u16>;
Expand description

TCP ports srv’s web and ws listeners are taken from.

It must sit below 32768. The OS hands ephemeral ports to outbound connections, and the defaults are 49152-65535 on Windows and macOS but 32768-60999 on Linux. A port in either range can be in use as the local end of an outgoing connection on a LAN address while it is free on loopback, and the startup bind only tests loopback: the LAN listener would then fail to bind that address later and LAN would stay partly off until the connection closed (Codex P2 on #4120; the first draft used 47892-47991, inside Linux’s range). Below 32768 is outside all three defaults.

Within that, the block is chosen away from well-known neighbours: Syncthing (21027, 22000), Synergy (24800), Minecraft (25565), Steam and Source games (27000s), MongoDB (27017) and Kubernetes NodePorts (30000-32767). One hundred ports hold about fifty instances. Another program that happens to listen in the range is not harmed, but a firewall rule on the range would expose it to the local subnet, which is why the block is not larger.