Sysctl IPv6 disable autoconfig for all interfaces not working

TL;DR

for sInterface in /proc/sys/net/ipv6/conf/*; do sysctl --write $(echo $sInterface.autoconf=0 | sed "s#/#.#g" | sed "s/.proc.sys.//g"); done

should do it.

The long version:

  • sysctl actually changes file contents in /proc/sys
  • net.ipv6.conf.all.autoconf is thus physically located in /proc/sys/net/ipv6/conf/all/autoconf
  • so we iterate over /proc/sys/net/ipv6/conf/
  • we change all / to . using sed using the # separator
  • we remove .proc.sys. from the string again using sed using the standard / separator.
  • we add .autoconf=0 to the interface
  • and apply with sysctl --write $()

Note: If you're not running as root you should do a sudo sysctl --write $() instead...