Skip to content

Instantly share code, notes, and snippets.

@ppsreejith
Created March 17, 2014 13:13
Show Gist options
  • Save ppsreejith/9598939 to your computer and use it in GitHub Desktop.
Save ppsreejith/9598939 to your computer and use it in GitHub Desktop.
#!/bin/sh
PROXY_IP=144.16.192.247
PROXY_PORT=8080
LAN_IP=`nvram get lan_ipaddr`
LAN_NET=$LAN_IP/`nvram get lan_netmask`
iptables -t nat -A PREROUTING -i br0 -s $LAN_NET -d ! $LAN_IP -p tcp --dport 80 -j DNAT --to $PROXY_IP:$PROXY_PORT
iptables -t nat -A PREROUTING -i br0 -s $LAN_NET -d ! $LAN_IP -p tcp --dport 443 -j DNAT --to $PROXY_IP:$PROXY_PORT
iptables -t nat -A POSTROUTING -o br0 -s $PROXY_IP -p tcp -d $LAN_NET -j SNAT --to $PROXY_IP
iptables -A FORWARD -i vlan1 -o br0 -s $LAN_NET -d $PROXY_IP -p tcp --dport $PROXY_PORT -j ACCEPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment