How I setup proxy to work with linksys router with ddwrt firmware?
Legend:
router ip: 192.168.1.1
proxy server ip: 192.168.1.100
proxy port: 3128
local lan: 192.168.1.0/24
1. bash script to add to the router;
####### SCRIPTA #####
#!/bin/sh
INTERNAL_NETWORK="192.168.1.0/24"
ROUTER_IP="192.168.1.1"
PROXY_SERVER="192.168.1.100"
PROXY_PORT="3128"
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 "This script has already run!"
echo "If it hasn't, unset \$TRANSPARENT_PROXY manually via the shell."
fi
#########
2. save the script that will work after reboot:
a) Login to the router as admin (root):
ssh root@192.168.1.1
b) paste the script:
# nvram set rc_firewall=" paste edited script here "
press ENTER
c) save script:
# nvram commit
d) Test if script is saved
# nvram get rc_firewall
8 responses to “linksys router (ddwrt) + proxy server”
Wow, this is very useful.. Thanks for sharing this and hoping I could implement it too.
How can i set login and password? I have a login and password. And i want to connect proxy server with wrt160nl and want to be internet on wrt160nl.
Username and password is part off proxy configuration. So firstly depends on which software you use for proxy.
Hi, I just install a WRT160NL in my lab, I wanted to know if I can configure my proxy settings in my router and allow my network users to access the internet using this credentials.
This is just a script which redirects all users from port 80 to port 3128 on proxy server and then to the internet.
Hey There. I found your blog using msn. This is a really well written article.
I will be sure to bookmark it and return to read
more of your useful information. Thanks for the post. I’ll certainly return.
I blog quite often and I reаlly aρρreciаtе your
contеnt. Thіs great aгticlе hаѕ truly peakеd my іnterest.
I аm going to booκ mark yоur blog
and kееp checkіng for nеω detailѕ about оnce a weеk.
I opteԁ in foг your Feeԁ too.
WOW just what I was looking for. Came here by searching for internet