Re:Don't tug on that, you never know what it might be attach...
by rxseger on Saturday July 02, 2016 @03:14AM
(#12021723)
FreeBSD has the sysctls you are looking for to control the reserved port range, allowing unprivileged users to bind (curious that Linux doesn't):
$ sudo sysctl net.inet.ip.portrange.reservedlow=10
net.inet.ip.portrange.reservedlow: 0 -> 10
$ nc -vvl 1
^C
$ sudo sysctl net.inet.ip.portrange.reservedlow=0
net.inet.ip.portrange.reservedlow: 10 -> 0
$ nc -vvl 1
nc: Permission denied
I checked for a sysctl controlling the ability to bind to privileged ports before writing my comment. The relevant code in the kernel compares against a hardcoded #define PROT_SOCK 1024, and doesn't have any means to disable that check. See inet_bind in net/ipv4/af_inet.c .