{"id":237,"date":"2009-05-14T08:30:58","date_gmt":"2009-05-14T07:30:58","guid":{"rendered":"http:\/\/blog.spanger.org\/?p=237"},"modified":"2011-03-16T13:21:46","modified_gmt":"2011-03-16T12:21:46","slug":"linksys-router-ddwrt-proxy-server","status":"publish","type":"post","link":"https:\/\/blog.spanger.org\/?p=237","title":{"rendered":"linksys router (ddwrt) + proxy server"},"content":{"rendered":"<p><strong>How I setup proxy to work with linksys router with ddwrt firmware?<br \/>\n<\/strong><br \/>\nLegend:<br \/>\nrouter ip: 192.168.1.1<br \/>\nproxy server ip: 192.168.1.100<br \/>\nproxy port: 3128<br \/>\nlocal lan: 192.168.1.0\/24<\/p>\n<p><strong>1. bash script to add to the router;<\/strong><\/p>\n<pre><code>####### SCRIPTA #####\r\n#!\/bin\/sh\r\nINTERNAL_NETWORK=\"192.168.1.0\/24\"\r\nROUTER_IP=\"192.168.1.1\"\r\nPROXY_SERVER=\"192.168.1.100\"\r\nPROXY_PORT=\"3128\"\r\nif [ -z $TRANSPARENT_PROXY ]; then\r\n\/usr\/sbin\/iptables -t nat -A PREROUTING -i br0 -s $INTERNAL_NETWORK -d $INTERNAL_NETWORK -p tcp --dport 80 -j ACCEPT\r\n\/usr\/sbin\/iptables -t nat -A PREROUTING -i br0 -s ! $PROXY_SERVER -p tcp --dport 80 -j DNAT --to $PROXY_SERVER:$PROXY_PORT\r\n\/usr\/sbin\/iptables -t nat -A POSTROUTING -o br0 -s $INTERNAL_NETWORK -p tcp -d $PROXY_SERVER -j SNAT --to $ROUTER_IP\r\n\/usr\/sbin\/iptables -t filter -I FORWARD -s $INTERNAL_NETWORK -d $PROXY_SERVER -i br0 -o br0 -p tcp --dport $PROXY_PORT -j ACCEPT\r\nexport TRANSPARENT_PROXY=\"1\"\r\nelse\r\necho \"This script has already run!\"\r\necho \"If it hasn't, unset \\$TRANSPARENT_PROXY manually via the shell.\"\r\nfi\r\n#########<\/code><\/pre>\n<p><strong>2. save the script that will work after reboot:<\/strong><\/p>\n<p>a) Login to the router as admin (root):<\/p>\n<pre><code>ssh root@192.168.1.1<\/code><\/pre>\n<p>b) paste the script:<\/p>\n<pre><code># nvram set rc_firewall=\" paste edited script here \"<\/code><\/pre>\n<p>press ENTER<\/p>\n<p>c) save script:<\/p>\n<pre><code># nvram commit<\/code><\/pre>\n<p>d) Test if script is saved<\/p>\n<pre><code># nvram get rc_firewall<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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=&#8221;192.168.1.0\/24&#8243; ROUTER_IP=&#8221;192.168.1.1&#8243; PROXY_SERVER=&#8221;192.168.1.100&#8243; PROXY_PORT=&#8221;3128&#8243; if [ -z $TRANSPARENT_PROXY ]; then \/usr\/sbin\/iptables -t nat -A PREROUTING -i br0 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-237","post","type-post","status-publish","format-standard","hentry","category-linux-stuff"],"_links":{"self":[{"href":"https:\/\/blog.spanger.org\/index.php?rest_route=\/wp\/v2\/posts\/237","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.spanger.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.spanger.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.spanger.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.spanger.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=237"}],"version-history":[{"count":7,"href":"https:\/\/blog.spanger.org\/index.php?rest_route=\/wp\/v2\/posts\/237\/revisions"}],"predecessor-version":[{"id":251,"href":"https:\/\/blog.spanger.org\/index.php?rest_route=\/wp\/v2\/posts\/237\/revisions\/251"}],"wp:attachment":[{"href":"https:\/\/blog.spanger.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.spanger.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.spanger.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}