Transparent squid proxy not working in OpenWrt repeater

I have to programmatically block websites for a particular IP address for which I can use squid proxy as mentioned here:

I have the below set up to achieve this:

Squid proxy works as expected with the above setup, which I confirmed by configuring proxy manually (repeater_wan_ip:3128) in the machines connected to the main router.

But for the devices connecting to the wifi network created at the repeater, I do not see any packets being forwarded to the proxy as seen from the squid's access.log. I have added the below redirect rule to the firewall configuration in the repeater:

config redirect
        option name 'Allow-transparent-Squid'
        option enabled '1'
        option proto 'tcp'
        option target 'DNAT'
        option src 'lan'
        option src_ip '!'
       	option src_dip '!'
        option src_dport '80'
        option dest 'lan'
        option dest_ip ''
        option dest_port '3128' is the lan IP address of my repeater. I was expecting the repeater to forward the packets matching the above condition to the proxy.
Please help me if I am missing any configuration for this to work.

To make it work, you will need to configure the device according to the guide section Using NAT. More configuration details can be found here. Be aware that it won’t be a “repeater” anymore and there will be some side effects.

If the main router clients' have to see the clients connected to the former repeater, you will have to create a static route in the main router and some additional firewall rules in the second router.

1 Like

You can pretty much forget a transparent proxy in a modern https-everywhere web. Not to say that you'd have much more luck with non-transparent proxying or doing it on a relatively low-end device such as yours.

You can run a (transparent) squid on a 64MB openwrt router with a custom image, assuming some tweaking. Regarding https-traffic, a transparent squid can be used for SNI-inspection, for example.

1 Like

@pavelgl ,
Thanks for your suggestion.
I tried setting up the second router using the instructions you provided and yes as you mentioned the devices on the main router were not able to reach the devices connected to the second router. I do not get UI or SSH access to the main router from my ISP, so was not able to try creating a static route.

As seen in the snapshot above, I want a setup where I can access the second router and also the devices connected to it from a machine (test runner) connected to the main router.
Devices connected to the second router do not have an option to configure a proxy, so I am using a transparent HTTPS proxy in the secondary router to deny traffic to certain domains from the connected devices.

Except for the proxy rest of the things worked for me when the second router was configured as a repeater.

Any suggestions on what is the best way to configure the second router for my needs?

I assume that you have already created a static route in "Test runner" to the second router's LAN (LAN2).

Make the following changes in the firewall configuration of the OpenWrt device, replacing "$Test_runner_IP" with the correct IP address.

  1. Disable masquerading from LAN2 to Test runner (pay attention to the negative "!" operator).
uci set firewall.@zone[1].masq_dest="!$Test_runner_IP"
  1. Open the firewall for SSH connections from Test runner.
uci add firewall rule
uci set firewall.@rule[-1].name="Allow-SSH-from-TR"
uci set firewall.@rule[-1].proto="tcp"
uci set firewall.@rule[-1].family="ipv4"
uci set firewall.@rule[-1].src="wan"
uci set firewall.@rule[-1].src_ip="$Test_runner_IP"
uci set firewall.@rule[-1].dest_port="22"
uci set firewall.@rule[-1].target="ACCEPT"
  1. Open the firewall for connections from Test runner to LAN2 (add some restrictions here if you want).
uci add firewall rule
uci set firewall.@rule[-1].name="Allow-from-TR-to-LAN2"
uci set firewall.@rule[-1].proto="any"
uci set firewall.@rule[-1].family="ipv4"
uci set firewall.@rule[-1].src="wan"
uci set firewall.@rule[-1].src_ip="$Test_runner_IP"
uci set firewall.@rule[-1].dest="lan"
uci set firewall.@rule[-1].target="ACCEPT"
uci commit firewall
/etc/init.d/firewall restart

That should be enough.

There is no need for NAT in this situation, or for a proxy. Set the device up as a wired AP, and then turn on bridge netfiltering and simply block outgoing packets to the IP addresses of interest.

If however you only know the domain names you want blocked, then you will need something extra

@pavelgl ,

Below are the IP and gateway information of the devices in my setup:
Test runner:

Second router:
Lan IP:
Wwan IP:

Device 1:

Added the static route in Test runner as below:

sudo route -n add -net

After adding all the firewall settings to second router as you suggested I was able to ssh second router from Test runner. But was not able to access Device1's web page from Test runner.


I tried setting up the second router as a wired AP using the instructions here:
Enabled bridge firewall using these instructions:

Added the below rule to firewall configuration to reject any traffic from the devices connected to the second router

config rule
	option src 'lan'
	option dest '*'
	option target 'REJECT'
	list src_ip ''
	list src_ip ''
	option name 'Block traffic from devices'
	option enabled '0'

This is not blocking any traffic from the devices. Is there anything else that I should do for this to work?

maybe this disables the rule, so option enabled '1' ?

Yes even when enabled '1' it does not work, I have toggled it multiple times to test.

I'd have to see at what point in the firewall it actually gets called, perhaps there's something ahead of it that is passing the traffic by default and so this rule doesn't get hit? Like LAN->LAN by default forwards automatically?

The next hop address must be the Router2 wwan address.

route del -net
route add -net gw
1 Like


After changing the static route as per your suggestions, the Test runner can now access both the second router and the devices connected to it. Thank you!

But I am still unable to block the domains from the router via a transparent proxy.
I am now using tinyproxy which supports both HTTP and HTTPS as mentioned here

The firewall configuration to redirect all the traffic at ports 80 and 443 to tinyproxy proxy port 8888 is as below:

config redirect
        option src 'lan' 
        option proto 'tcp'   
        option dest_port '8888'
        option src_dip '!'
        option dest_ip ''
        option name 'Transparent Proxy Redirect'
        option src_dport '80'
config redirect              
        option name 'Transparent Proxy HTTPS Redirect'
        option src 'lan'                              
        option proto 'tcp'                            
        option dest_port '8888'                       
        option src_dport '443'                        
        option src_dip '!'
        option dest_ip '' 

tinyproxy configuration:

### SEE /etc/config/tinyproxy INSTEAD

User nobody
Group nogroup
Port 8888
Timeout 600
DefaultErrorFile "/usr/share/tinyproxy/default.html"
StatHost ""
StatFile "/usr/share/tinyproxy/stats.html"
LogFile "/var/log/tinyproxy.log"
Syslog Off
LogLevel Info
XTinyproxy Off
MaxClients 100
MinSpareServers 5
MaxSpareServers 20
StartServers 10
MaxRequestsPerChild 0
ViaProxyName "tinyproxy"
Filter "/etc/tinyproxy.filter"
FilterURLs Off
FilterExtended Off
FilterCaseSensitive Off
FilterDefaultDeny No
ConnectPort 443
ConnectPort 563

The filter file /etc/tinyproxy.filter has the domain names to block, Example:

Whenever I launch any website from a browser in the device connected to the router (device IP: the below logs appear in the router's tinyproxy logs at /var/log/tinyproxy.log

CONNECT   Dec 05 09:51:14 [11188]: Connect (file descriptor 9): macjdhananjaya.lan []
NOTICE    Dec 05 09:51:14 [11188]: Unauthorized connection from "macjdhananjaya.lan" [].
INFO      Dec 05 09:51:14 [11188]: Read request entity of 517 bytes

Below error is displayed in the browser:

Lan IP of the second router:
Wwan IP:

Am I missing any configuration related to SSL, that is causing this issue?

After commenting ' Allow' line in tinyproxy configuration, different error appears in the tinyproxy logs, but the same error in the browser as before.

CONNECT   Dec 05 20:18:49 [12303]: Connect (file descriptor 9): macjdhananjaya.lan []
CONNECT   Dec 05 20:18:49 [12303]: Request (file descriptor 9): 
WARNING   Dec 05 20:18:49 [12303]: Could not retrieve all the headers from the client
INFO      Dec 05 20:18:49 [12303]: Read request entity of 361 bytes

I tried configuring redsocks as per the instructions here
Added the proxy IP (router's lan IP: and port (tinyproxy port :8888) to redsocks configuration as below. Started the redsocks service.

redsocks {                                                                        
        /* `local_ip' defaults to for security reasons,                 
         * use if you want to listen on every interface.                  
         * `local_*' are used as port to redirect to.                             
        local_ip =;                                                     
        local_port = 12345;                                                       
        // listen() queue length. Default value is SOMAXCONN and it should be     
        // good enough for most of us.                                       
        // listenq = 128; // SOMAXCONN equals 128 on my Linux box.           
        // `max_accept_backoff` is a delay to retry `accept()` after accept  
        // failure (e.g. due to lack of file descriptors). It's measured in  
        // milliseconds and maximal value is 65535. `min_accept_backoff` is  
        // used as initial backoff value and as a damper for `accept() after 
        // close()` logic.                                                   
        // min_accept_backoff = 100;                                         
        // max_accept_backoff = 60000;                                       
        // `ip' and `port' are IP and tcp-port of proxy-server               
        // You can also use hostname instead of IP, only one (random)        
        // address of multihomed host will be used.                          
        ip =;                                                    
        port = 8888;                                                         
        // known types: socks4, socks5, http-connect, http-relay             
        type = http-connect;                                                 
        // login = "foobar";                                                 
        // password = "baz";                                                 

Added the below rule to redirect traffic from 443 to redsocks port 12345:

iptables -A PREROUTING -t nat -p tcp --dport 443 -j REDIRECT --to-port 12345 -m comment --comment "443 redirection to redsocks"

Reloaded and restarted firewall,tinyproxy and redsocks services. But it did not fix the issue.
I still see the same errors in tinyproxy logs and the browser.
Am I missing anything here? Will transparent proxy work for https?

Change this to local_ip =; and restart the redsocks service.

I seriously doubt you can make tinyproxy work in transparent mode for https traffic, even using redsocks.

@pavelgl ,
Even after changing the local_ip to and restarting redsocks, I see the same errors in tinyproxy logs.

I have also tried using adblock package to block the domains, even that is not working in the second router for https requests from the devices connected to it.
I am not finding instructions on how to configure squid proxy in transparent mode in a OpenWRT router, any help?
If not using a proxy, what is the best way to block traffic to a specific domain from the second router (OpenWRT)?

You need to dig into squids docs, when trying to intercept https.
I.e. here:
You then need to adapt these ipt rules to openwrt. OR, like I do, just get rid of the openwrt firewall completely, and replace with plain iptables. Makes advanced setups much easier.
I advise, first to set up intercept squid on vanilla LINUX, i.e. ubuntu, and to port to openwrt, when success.
tinyproxy is not able to intercept https. squid can do it.
Also, get rid of squids config using UCI on openwrt, when porting. Just copy squid.conf from LINUX (ubuntu) test env to openwrt.

If you want to block certain domains for all LAN clients, you could use this approach.

If you stick to the requirements from your OP

you can use custom firewall rules.

Create a file, named domains in the root directory. Enter the domain name you want to block and the client's IP address, separated by semicolon.;;

Insert this script in /etc/firewall.user


while IFS= read -r string
domain=$(echo "$string" | sed 's/\;.*//')
bannedip=$(echo "$string" | sed 's/.*\;//')
for domainip in $(nslookup "$domain" | grep Address | grep -v \# | grep -v \:: | sed 's/^.*: //')
 iptables -A forwarding_rule -s "$bannedip"/32 -d "$domainip"/32 -p tcp -m multiport --dports 80,443 -j REJECT
done < "$domainfile"

Enable the reload option in the firewall include section.

uci set firewall.@include[0].reload='1'
uci commit firewall
fw3 restart

Keep in mind that this will only work for ipv4 addresses.