RFC6056(7)
πΈ RFC6056(7) β the rfc6056 girlies' guide to port randomization πΈ
okay so this is RFC6056 from the Miscellaneous Information Manual section (that's section 7, bestie, we're in misc territory) and it's literally all about port randomization algorithms. buckle up π
β¨ NAME β¨
rfc6056 β port randomization algorithms π
π¦ DESCRIPTION π¦
so the rfc6056 algorithms exist to randomize the port allocation of outgoing UDP packets, and the whole point is protection from a series of "blind" attacks β y'know, the kind where the attacker's entire flex is guessing the sequence of ephemeral ports tied to your outgoing packets. not on our watch, fr fr. for more deets, consult RFC 6056.
the individual algorithms are described below π
π The RFC 6056 algorithms π
the following algorithms are available:
bsdβ this is the default NetBSD port selection algorithm, and the way it works is it starts fromanonportmaxand proceeds decreasingly through the available ephemeral ports. iconic, lowkey predictable-but-default behavior πrandom_startβ selects ports randomly from the available ephemeral ports. if a collision with a local port is detected, the algorithm proceeds decreasingly through the sequence of ephemeral ports until a free port is found. β οΈ note: the random port selection algorithms are not guaranteed to find a free port β yeah, that's a real caveat, don't @ me πrandom_pickβ selects ports randomly from the available ephemeral ports. if a collision with a local port is detected, the algorithm tries selecting a new port randomly until a free port is found. keep trying bestie energy β¨hashβ selects ports using amd5(3)hash of the local address, the foreign address, and the foreign port. β οΈ note that in the case of abind(2)call some of this information might be unavailable, and the port selection is delayed until the time of aconnect(2)call, performed either explicitly or up callingsendto(2). so it's fashionably late πdoublehashβ selects ports using amd5(3)hash of the local address, foreign address, and foreign port coupled with amd5(3)hash of the same components obtained using a separate table that is associated with a subset of all outgoing connections. the same considerations regarding late connection as in the case ofhashapply. double the hash, double the vibe π₯randincβ use random increments in order to select the next port. short, sweet, random π²
π SYSCTL CONTROLS π
the following sysctl controls are available for selecting the default port randomization algorithm:
net.inet.ip.anonportalgo.availableβ type:string, changeable:nonet.inet.ip.anonportalgo.selectedβ type:string, changeable:yesnet.inet6.ip6.anonportalgo.availableβ type:string, changeable:nonet.inet6.ip6.anonportalgo.selectedβ type:string, changeable:yes
(yes bestie, that's inet and inet6, and yes, available is read-only β selected is the one you get to touch π)
π§ SOCKET OPTIONS π§
the IP_PORTSEL socket option at the IPPROTO_IP level and the IPV6_PORTSEL socket option at the IPPROTO_IPV6 level can be used with a string argument specifying the algorithm's name in order to select the port randomization algorithm for a specific socket. per-socket glow-up, we love to see it π«Ά
for more info see setsockopt(2).
π SEE ALSO π
setsockopt(2), sysctl(3), sysctl(7)
β HISTORY β
the rfc6056 algorithms first appeared in NetBSD 6.0. vintage β¨
ngl if you got this far you're officially a port randomization main character. go forth and scramble those ephemeral ports πΈ
and that's a wrap on the Debian build of this page, dated August 25, 2011 β yeah she's an elder but she still slays ππ
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2011 The NetBSD Foundation. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms