ok so just to be clear on the packet flow.
my computer dns request → kresd (port 53) → ipset-dns(port 1919) ->tor dns (port 9053)
---------------------------------------------------------------^ ipset v
my computer tcp request → match ipset firewall mangle mark (0x33) ->routing rule → vpn
so config file should be :
FOR THE DNS FLOW
/etc/config/resolver at section config resolver ‘kresd’
config resolver 'kresd
...
option include_config '/etc/kresd/custom.conf'
...
/etc/kresd/custom.conf where ipset_address should be 127.0.0.1and ipset_portNum the port i should specify running ipset-dns
...
FRTVService = {'france.tv', 'ftv.akamaihd.tld'}
policy.add(policy.suffix(policy.STUB({'ipset_address@ipset_portNum'}), policy.todnames(FRTVService)))
...
I should run ipset-dns for each redirection where my_ipv4_set and my_ipv6_set are ipset names for my firewall match rules (frfbx4, frfbx6).
ipset-dns_portNum the port specified in kresd/custom.conf
dns_forward_ip in my case 127.0.0.1:9053 (tor dns port)
$ ipset-dns my_ipv4_set my_ipv6_set ipset-dns_portNum dns_forward_ip
in my case
$ ipset-dns frfbx4 frfbx6 1919 127.0.0.1:9053
FOR THE TCP FLOW
/etc/firewall.users
iptables -t mangle -A PREROUTING -i br-myi_lan -m set --match-set frfbx4 src,dst -j MARK --set-mark 0x33
iptables6 -t mangle -A PREROUTING -i br-myi_lan -m set --match-set frfbx6 dst,dst -j MARK --set-mark 0x33
/etc/config/firewall
config ipset
option enabled '1'
option name 'frfbx4'
option match 'ip'
option storage 'hash'
option family 'inet'
config ipset
option enabled '1'
option name 'frfbx6'
option match 'ip'
option storage 'hash'
option family 'inet6'
/etc/iproute2/rt_tables add a table in my case :
...
200 vpn_wan
...
/etc/openvpn/tun.up a script on vpn startup
/sbin/ip rule add fwmark 0x33 lookup vpn_wan
/sbin/ip route add default dev tunf table vpn_wan