It is much simpler to just set /proc/sys/net/ipv{4,6}/conf/all/forwarding to 1, as that updates all conf/iface/forwarding and /proc/sys/net/ipv4/ip_forward. I. e. we just need
for f in /proc/sys/net/ipv*/conf/all/forwarding; do echo 1 > $f done
It is much simpler to just set /proc/sys/ net/ipv{ 4,6}/conf/ all/forwarding to 1, as that updates all conf/iface/ forwarding and /proc/sys/ net/ipv4/ ip_forward. I. e. we just need
for f in /proc/sys/ net/ipv* /conf/all/ forwarding; do
echo 1 > $f
done