After successfully disabling IPv6 using this script :
echo 'net.ipv6.conf.all.disable_ipv6 = 1' >> /etc/sysctl.conf
echo 'net.ipv6.conf.default.disable_ipv6 = 1' >> /etc/sysctl.conf
echo 'net.ipv6.conf.lo.disable_ipv6 = 1' >> /etc/sysctl.conf
sysctl -p
I try to re-enable using this script :
sed -i "/net.ipv6.conf.all.disable_ipv6/d" /etc/sysctl.conf
sed -i "/net.ipv6.conf.default.disable_ipv6/d" /etc/sysctl.conf
sed -i "/net.ipv6.conf.lo.disable_ipv6/d" /etc/sysctl.conf
sysctl -p
I have verified that the enable script removes the disable lines from the sysctl.conf file.
In each case, I check the result with this :
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
where '1' means disabled and '0' means not.
The re-enable piece does not work.
In each case, the sysctl -p command reloads the /etc/sysctl.conf file. However it seems that the reload simply pulls into its buffer rather than over-writing it completely so that the disabling properties are not removed.
Is this analysis correct?
If so, I don't see an option to clear the sysctl.conf cache. Is there one? Or is there a strategy for this requirement?
The entries in
/etc/sysctl.conf
and any files included from it specify what sysctl settings will be applied at boot time, or when you runsudo sysctl -p
. But the absence of an entry in this file means that such a sysctl (of which there are thousands) will not be changed from whatever value it currently holds.You removed the sysctl entries that disabled IPv6 from this file, but it doesn't appear that you actually changed the sysctl settings themselves. Running
sudo sysctl -p
didn't change them, because they were not in/etc/sysctl.conf
.In order to change these entries back to their defaults, you can either reboot your system, or use
sysctl
to set them explicitly. For example: