Building Linux Virtual Private Networks
(view this code in a separate window)
#!/bin/sh

echo "Setting up IP forwarding rules"
echo 1 > /proc/sys/net/ipv4/ip_forward
echo -n "/proc/sys/net/ipv4/ip_forward: "
cat /proc/sys/net/ipv4/ip_forward

for forwarding in /proc/sys/net/ipv4/conf/*/forwarding
do
      echo -n "$forwarding: ";

      interface=`dirname $forwarding`
      interface=`basename $interface`

      case "$interface" in
            ppp*|eth1)   # list of interfaces through which
                         # forwarding should be enabled
                         echo 1 > $forwarding
                         ;;

            *)           # Turn off forwarding for all other interfaces
                         echo 0 > $forwarding
                         ;;
      esac

      cat $forwarding
done


Home
Contents
Authors
Reviews
Errata
Colophon
Source Code
Sample Chapter
Suggested Reading
Purchase

New Riders Publishing