I'm trying to assign an empty string to a system setting, but it fails:

[root@wc8rh7 ~]# sysctl -w net.ipv4.ip_local_reserved_ports="50000"
net.ipv4.ip_local_reserved_ports = 50000
[root@wc8rh7 ~]# sysctl -w net.ipv4.ip_local_reserved_ports=""
sysctl: malformed setting "net.ipv4.ip_local_reserved_ports="

Using procfs directly succeeds:

[root@wc8rh7 ~]# echo >/proc/sys/net/ipv4/ip_local_reserved_ports
[root@wc8rh7 ~]# sysctl net.ipv4.ip_local_reserved_ports
net.ipv4.ip_local_reserved_ports =

I agree with thrig, this does look like a bug. Writing directly to procfs is an obvious workaround. If you need to use the sysctl utility, another workaround is to add a newline:

sysctl -w net.ipv4.ip_local_reserved_ports="

A trailing newline has no effect on most if not all sysctl settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.