OpenVPN via TOR on OpenWrt

Hello guys, I would like to access a remote OpenVPN server via the TOR network
(I do know the pros and cons and the implications of doing so).
I.e.: I would like to run an OpenVPN client on my OpenWrt router, and all traffic coming in from the internal side (wlan or lan) should go via the OpenVPN tunnel, including DNS lookups. But the connection from my OpenVPN client to the remote OpenVPN server endpoint should not be directly, but via the TOR network.
TOR is described on the OpenWrt pages, and OpenVPN client, but not both combined.
I searched a bit, and this sounds exactly like what I am trying to do: VPN over TOR using OpenWRT - #15 by 0xfreebit
But I was not able to get things running based on that information, lots of info seems to be missing.
Can someone provide me some info on how to get this up and running?
Best, Tom

in openvpn.conf client add socks-proxy
and that should be it

....Somewhere in that post....

Tor should be running as a socks proxy on

Indeed I did exactly that.
But I'm also running into the same problem as the guy in that post.
As soon as the VPN comes up, it seems it is loosing connection to the socks port:

daemon.notice openvpn(client)[2656]: TCP/UDP: Preserving recently used remote address: [AF_INET]
daemon.notice openvpn(client)[2656]: Attempting to establish TCP connection with [AF_INET] [nonblock]
daemon.notice openvpn(client)[2656]: TCP connection established with [AF_INET]
daemon.err openvpn(client)[2656]: recv_socks_reply: TCP port read timeout expired: Operation in progress (errno=115)
daemon.notice openvpn(client)[2656]: SIGUSR1[soft,init_instance] received, process restarting

Also tried socks IP but this did not chance anything.

The Whonix link explains how to setup OpenVPN via Tor.

I've seen these pages, but they don't explain how to do the setup on Openwrt. I understand how this works in principle, but I can't get it running on openwrt.

My setup so far:
I followed the TOR setup here
then I setup OpenVPN like described here
In addition, I did the steps "Support OpenVPN" and "Route LAN to VPN" from here:

After that, I run into the problem as described in my first message.

Also, when doing a "service pbr restart", I see messages like these:

Creating TOR redirects [✗] is unset and defaults to string Untitled
pbr.cfg066ff5.enabled is unset and defaults to bool 1
pbr.cfg066ff5.interface=tun validates as or("ignore", "tor", uci("network", "@interface")) with false
pbr.cfg066ff5.proto is unset and defaults to or(string) (null)
pbr.cfg066ff5.chain is unset and defaults to or("", "forward", "input", "output", "prerouting", "postrouting", "FORWARD", "INPUT", "OUTPUT", "PREROUTING", "POSTROUTING") prerouting
pbr.cfg066ff5.src_addr= validates as list(neg(or(host,network,macaddr,string))) with true
pbr.cfg066ff5.src_port is unset and defaults to list(neg(or(portrange,string))) (null)
pbr.cfg066ff5.dest_addr is unset and defaults to list(neg(or(host,network,string))) (null)
pbr.cfg066ff5.dest_port is unset and defaults to list(neg(or(portrange,string))) (null)
Routing 'Untitled' via  [✗]

This seems to indicate that something goes wrong with the routing setup.

Best, Tom

Does no one have any suggestions or experiences how to fix this? I'm still stuck. :cold_sweat:

I don't use PBR (I make manual routes and rules).

Can you post yoir PBR config so we can see it?

If you have a good solution without PBR, that is just as fine - I'm not set on using PBR. Grateful for whatever works.

My PBR config at the moment in /etc/config/pbr:

config pbr 'config'
	option enabled '1'
	option verbosity '2'
	option strict_enforcement '1'
	option resolver_set 'none'
	option ipv6_enabled '0'
	list ignored_interface 'vpnserver'
	list ignored_interface 'wgserver'
	option boot_timeout '30'
	option rule_create_option 'add'
	option procd_reload_delay '1'
	option webui_show_ignore_target '0'
	list webui_supported_protocol 'all'
	list webui_supported_protocol 'tcp'
	list webui_supported_protocol 'udp'
	list webui_supported_protocol 'tcp udp'
	list webui_supported_protocol 'icmp'
	list supported_interface 'tun*'

config policy
	option src_addr ''
	option interface 'vpn'

The /etc/config/firewall seems standard, except for the following additions:

config redirect 'tcp_int'
	option name 'Intercept-TCP'
	option src 'lan'
	option src_dport '0-65535'
	option dest_port '9040'
	option proto 'tcp'
	option family 'any'
	option target 'DNAT'

config include 'pbr'
	option fw4_compatible '1'
	option type 'script'
	option path '/usr/share/pbr/pbr.firewall.include'

and /etc/tor/custom:

AutomapHostsOnResolve 1
AutomapHostsSuffixes .
VirtualAddrNetworkIPv6 [fc00::]/8
DNSPort [::]:9053
TransPort [::]:9040

To /etc/openvpn/client.conf I've added

dev tun
proto tcp
socks-proxy 9050

Does anyone have any hints or suggestions, or even a working config? With or without PBR. Still stuck here unfortunately.