Whilst I do not wish to offend 
@Swinson, in light of his current ongoing forum absence since June 2021, I have created a generic version of his original script that 
should allow you to designate 
any VPN client without the need to edit/hack the script.
You can download/test it from
	
	
		
			
				
			
			
				
				Install and manage unbound (Recursive DNS) on Asus routers - MartineauUK/Unbound-Asuswrt-Merlin
				
					
						
							
						
					
					github.com
				
 
			 
		 
	 
Clearly your previous statement [the script] '
did not provide a reliable solution' needs to be made clearer... i.e. are you absolutely sure that the 
DNS Leak test is 
always 100% accurate?
IMHO, 
x3mrouting shouldn't be necessary  just for your 
DNS routing requirement? - see below
If not using 
x3mrouting then you need to implement the 
RPDB fwmark rules manually...
see 
'/jffs/scripts/nat-start'
Policy based Port routing (manual method) · RMerl/asuswrt-merlin.ng Wiki · GitHub
to ensure that the 
RPDB fwmark rules are 
always available should the firewall be rebuilt whilst the 
VPN Client is 
UP.
(
x3mrouting dynamically adds/deletes the 
RPDB fwmark rules 
only when the 
VPN Client is actually started/stopped!)
EDIT:
If you decide to test my generic 
'/jffs/addons/unbound/unbound_DNS_via_OVPN.sh' script then you should ensure ALL of the 
'vpnclientX-route-*' event scripts contain the appropriate call
e.g. 
VPN Client 5
'/jffs/scripts/vpnclient5-route-up'
	
	
	
		Code:
	
	
		VPN_ID=${dev:4:1}
[ -z "$VPN_ID" ] && { SCR=$(basename $0); VPN_ID=${SCR:9:1}; }    # Allow manual debugging from commandline
if [ -n "$(which unbound-control)" ] && [ -n "$(unbound-control status | grep -E "unbound.*running")" ];then
    Say "Unbound DNS requests via VPN Client $VPN_ID requested....."
    /jffs/addons/unbound/unbound_DNS_via_OVPN.sh "$VPN_ID" start &
fi
	 
 and
'/jffs/scripts/vpnclient5-route-pre-down'
	
	
	
		Code:
	
	
		VPN_ID=${dev:4:1}
[ -z "$VPN_ID" ] && { SCR=$(basename $0); VPN_ID=${SCR:9:1}; }    # Allow manual debugging from commandline
if [ -n "$(which unbound-control)" ] && [ -n "$(unbound-control status | grep -E "unbound.*running")" ];then
    Say "Unbound DNS requests via VPN Client $VPN_ID terminating....."
    /jffs/addons/unbound/unbound_DNS_via_OVPN.sh "$VPN_ID" stop
fi