net.ipv4.ip_forward = 1 in
/etc/sysctl.conf and ran
sysctl -p which caused it to set to
1 as expected in the output of
sysctl -a, but sometime between last night and now something set it back to
0. Any thoughts on what could be doing this? I grepped
forward and for
sysctl and didn't see anything.
Some CentOS versions set
0 again whenever the network service is restarted (with
service restart networking for example).
To be more precise, it is set to zero in the stop section of the
stop) [ "$EUID" != "0" ] && exit 4 # Don't shut the network down if root is on NFS or a network # block device. # [...] action $"Shutting down loopback interface: " ./ifdown ifcfg-lo sysctl -w net.ipv4.ip_forward=0 > /dev/null 2>&1
You can edit that script and remove or change that line.
See Red Hat Bugzilla Bug 552653 for more information.
There is a bug which causes
sysctl values to be loaded before the network is properly initialized. This causes network settings in
/etc/sysctl.conf to be ignored. A solution to this may be to
procps restart to
/etc/local.rc, so the initialization is repeated.
The bug in question: https://bugs.launchpad.net/ubuntu/+source/procps/+bug/50093
I put logging in place to record the value of this setting every minute so then I could check
/var/log/cron and see what might be responsible. It looks like the reverting corresponds to a cron job for APF (Advanced Policy Firewall) running.
Here's my mini logging script in case it's helpful to anyone:
echo `date`" - "`sysctl -a | grep net.ipv4.ip_forward` >> /var/log/ip_forward_setting.log