From af7db8bfe1b2bdbaba40e5deb5ff8967fba54a63 Mon Sep 17 00:00:00 2001 From: "Michael K. Johnson" Date: Thu, 6 Nov 1997 21:44:49 +0000 Subject: only enable/disable forwarding on start, always disable on stop. --- rc.d/init.d/network | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) (limited to 'rc.d/init.d/network') diff --git a/rc.d/init.d/network b/rc.d/init.d/network index 45346aba..8d90bad8 100755 --- a/rc.d/init.d/network +++ b/rc.d/init.d/network @@ -19,27 +19,6 @@ if [ -f /etc/sysconfig/pcmcia ]; then . /etc/sysconfig/pcmcia fi -# Turn IP forwarding on or off. We do this before bringing up the interfaces -# to make sure we don't forward when we shouldn't, and we do it even if -# networking isn't configured (why not?). -if [ -d /proc/sys/net/ipv4 ]; then - # people could have left this out of their kernel, which isn't - # exactly an error - if [ ! -f /proc/sys/net/ipv4/ip_forward ] ; then - echo "/proc/sys/net/ipv4/ip_forward is missing --" \ - "cannot control IP forwarding" >&2 - else - if [ "$FORWARD_IPV4" = "no" -o "$FORWARD_IPV4" = "false" ]; then - value=0 - echo "Disabling IPv4 packet forwarding." - else - value=1 - echo "Enabling IPv4 packet forwarding." - fi - - echo "$value" > /proc/sys/net/ipv4/ip_forward - fi -fi # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 @@ -55,6 +34,31 @@ interfaces=`ls ifcfg* | egrep -v '(ifcfg-lo|:)' | egrep 'ifcfg-[a-z0-9]+$'` # See how we were called. case "$1" in start) + # Turn IP forwarding on or off. We do this before bringing up the + # interfaces to make sure we don't forward when we shouldn't, and + # we do it even if networking isn't configured (why not?). + if [ -d /proc/sys/net/ipv4 ]; then + # people could have left this out of their kernel, which isn't + # exactly an error + if [ ! -f /proc/sys/net/ipv4/ip_forward ] ; then + echo "/proc/sys/net/ipv4/ip_forward is missing --" \ + "cannot control IP forwarding" >&2 + else + if [ "$FORWARD_IPV4" = "no" -o "$FORWARD_IPV4" = "false" ]; then + value=0 + message="Disabling IPv4 packet forwarding." + else + value=1 + message="Enabling IPv4 packet forwarding." + fi + + if [ $value != `cat /proc/sys/net/ipv4/ip_forward` ]; + echo $message + echo "$value" > /proc/sys/net/ipv4/ip_forward + fi + fi + fi + ./ifup ifcfg-lo for i in $interfaces; do ./ifup $i boot @@ -67,6 +71,8 @@ case "$1" in ./ifdown $i boot done ./ifdown ifcfg-lo + echo "Disabling IPv4 packet forwarding." + echo 0 > /proc/sys/net/ipv4/ip_forward rm -f /var/lock/subsys/network ;; status) -- cgit v1.2.1