#!/bin/sh
#Run this on your router such as a WRT54G with dd-wrt installed

INTERNAL_NETWORK="192.168.1.0/24"
ROUTER_IP="192.168.1.1"
#If this is not set correctly, it will not work
PROXY_SERVER="192.168.1.100"
PROXY_PORT="80"
if [ -z $TRANSPARENT_PROXY ]; then
 /usr/sbin/iptables -t nat -A PREROUTING -i br0 -s $INTERNAL_NETWORK \
   -d $INTERNAL_NETWORK -p tcp --dport 80 -j ACCEPT
 /usr/sbin/iptables -t nat -A PREROUTING -i br0 -s ! $PROXY_SERVER -p
tcp --dport 80 \
   -j DNAT --to $PROXY_SERVER:$PROXY_PORT
 /usr/sbin/iptables -t nat -A POSTROUTING -o br0 -s $INTERNAL_NETWORK
-p tcp -d \
   $PROXY_SERVER -j SNAT --to $ROUTER_IP
 /usr/sbin/iptables -t filter -I FORWARD -s $INTERNAL_NETWORK -d
$PROXY_SERVER -i br0 \
   -o br0 -p tcp --dport $PROXY_PORT -j ACCEPT
 export TRANSPARENT_PROXY="1"
else
 echo "You already ran this"
 echo "If I lied then, unset \$TRANSPARENT_PROXY"
fi


