#!/bin/sh # chkconfig: 2345 13 89 # description: NAT . /etc/init.d/functions case "$1" in start) echo -n "Starting NAT: " iptables -t nat -A PREROUTING -p tcp -d 0/0 --dport www -i ppp0 -j DNAT --to 192.168.1.14:3128 \ && iptables -t nat -A PREROUTING -p tcp -d 0/0 --dport www -i ppp0 -j DNAT --to 192.168.2.1:3128 \ && echo 1 > /proc/sys/net/ipv4/ip_forward \ && iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -o eth0 -j MASQUERADE \ && success echo ;; stop) echo -n "Stopping NAT: " echo 0 > /proc/sys/net/ipv4/ip_forward && success echo ;; restart) $0 stop $0 start ;; *) echo "Usage: nat {start|stop|restart}" exit 1 ;; esac exit $RETVAL