2 ms·
> I'm somewhat surprised that there isn't a sysctl to disable the reservation of ports 0-1023. There is: /proc/sys/net/ipv4/ip_local_port_range
by ars 10y ago
> I'm somewhat surprised that there isn't a sysctl to disable the reservation of ports 0-1023.
There is: /proc/sys/net/ipv4/ip_local_port_range
- JoshTriplett 10y agoThat does something entirely different; see Documentation/networking/ip-sysctl.txt (online version at https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt https://www.kernel.org/doc/Documentation/networking/ip-sysct...). ip_local_port_range sets the range of ports used as source ports for outbound connections that don't bind to a specific port. 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 .
- rxseger 10y agoFreeBSD 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