Updated: new rules at the bottom
Okay so here is what I’ve got. You need to have x3mRouting installed and at least set up a dummy.
You can then go through and configure unbound with the by running
Then you will need to add these lines for the vpnevent script
vpnclientX-route-up
Code:
jffs/addons/unbound/unbound_manager.sh vpn=X delay=9 &
vpnclientX-route-pre-down
Code:
/jffs/addons/unbound/unbound_manager.sh vpn=disable
Finally I added these lines to my services-start file so anything going to port 53 will piggy back off the rules x3mRouting has setup
Code:
iptables -t mangle -D OUTPUT -p tcp --dport 53 -j MARK --set-mark 0x1000/0x1000
iptables -t mangle -D OUTPUT -p udp --dport 53 -j MARK --set-mark 0x1000/0x1000
iptables -t mangle -A OUTPUT -p tcp --dport 53 -j MARK --set-mark 0x1000/0x1000
iptables -t mangle -A OUTPUT -p udp --dport 53 -j MARK --set-mark 0x1000/0x1000
I’m still learning and figuring stuff out so if anything is wrong here feel free to let me know but it looks like all my dns lookup will now be forced through the vpn
(11/22/2020) edit:
Still running into a few issues. I’m working on getting it set up to run in route-up and pre-down rather than services-start because I don’t think it really belongs there and firewall-start won’t work either because I’m pretty sure putting it that early would break the boot up.
(11/23/2020) Rule update:
(1) setup WAN_DNS to go to wan0 and mark all other dns packets to go to vpn
(2) move everything into route-up/route-pre-down
/jffs/scripts/x3mRouting/vpnclientX-route-up
Code:
# WAN DNS requests to Wan0 #
iptables -t mangle -D OUTPUT -d "$( (nvram get wan0_dns) | awk '{print $1}')"/32 -p udp --dport 53 -j MARK --set-mark 0x8000/0x8000
iptables -t mangle -D OUTPUT -d "$( (nvram get wan0_dns) | awk '{print $2}')"/32 -p udp --dport 53 -j MARK --set-mark 0x8000/0x8000
iptables -t mangle -D OUTPUT -d "$( (nvram get wan0_dns) | awk '{print $1}')"/32 -p tcp --dport 53 -j MARK --set-mark 0x8000/0x8000
iptables -t mangle -D OUTPUT -d "$( (nvram get wan0_dns) | awk '{print $2}')"/32 -p tcp --dport 53 -j MARK --set-mark 0x8000/0x8000
iptables -t mangle -A OUTPUT -d "$( (nvram get wan0_dns) | awk '{print $1}')"/32 -p udp --dport 53 -j MARK --set-mark 0x8000/0x8000
iptables -t mangle -A OUTPUT -d "$( (nvram get wan0_dns) | awk '{print $2}')"/32 -p udp --dport 53 -j MARK --set-mark 0x8000/0x8000
iptables -t mangle -A OUTPUT -d "$( (nvram get wan0_dns) | awk '{print $1}')"/32 -p tcp --dport 53 -j MARK --set-mark 0x8000/0x8000
iptables -t mangle -A OUTPUT -d "$( (nvram get wan0_dns) | awk '{print $2}')"/32 -p tcp --dport 53 -j MARK --set-mark 0x8000/0x8000
# WAN DNS requests to Wan0 #
# Default DNS requests to VPN_Client 1 #
iptables -t mangle -D OUTPUT -p tcp --dport 53 -j MARK --set-mark 0x1000/0x1000
iptables -t mangle -D OUTPUT -p udp --dport 53 -j MARK --set-mark 0x1000/0x1000
iptables -t mangle -A OUTPUT -p tcp --dport 53 -j MARK --set-mark 0x1000/0x1000
iptables -t mangle -A OUTPUT -p udp --dport 53 -j MARK --set-mark 0x1000/0x1000
# Default DNS requests to VPN_Client 1 #
jffs/addons/unbound/unbound_manager.sh vpn=X delay=5 &
/jffs/scripts/x3mRouting/vpnclientX-route-pre-down
Code:
iptables -t mangle -D OUTPUT -d "$( (nvram get wan0_dns) | awk '{print $1}')"/32 -p udp --dport 53 -j MARK --set-mark 0x8000/0x8000
iptables -t mangle -D OUTPUT -d "$( (nvram get wan0_dns) | awk '{print $2}')"/32 -p udp --dport 53 -j MARK --set-mark 0x8000/0x8000
iptables -t mangle -D OUTPUT -d "$( (nvram get wan0_dns) | awk '{print $1}')"/32 -p tcp --dport 53 -j MARK --set-mark 0x8000/0x8000
iptables -t mangle -D OUTPUT -d "$( (nvram get wan0_dns) | awk '{print $2}')"/32 -p tcp --dport 53 -j MARK --set-mark 0x8000/0x8000
iptables -t mangle -D OUTPUT -p tcp --dport 53 -j MARK --set-mark 0x1000/0x1000
iptables -t mangle -D OUTPUT -p udp --dport 53 -j MARK --set-mark 0x1000/0x1000
/jffs/addons/unbound/unbound_manager.sh vpn=disable