How to figure out whitelist based asterisk dialplan

I m new On Asterisk.
i want to make whitelist based dialplan
my call incoming number like : 723499457865 (12 digit)
in whitelist Database 720503499457865 (the 05 after 72 its random 01-32)
my white list in astdb database.
if whitelist allowed 720503499457865 (number match last 9 digit-499457865)
Dial to iax2peer/05034994557865 ( without 72)

Please help
I m Trying make 1 like this :

include => internal
exten => _9234[0126-9].,1,NoOp(Going Out)
same => n,Macro(whitelist,${EXTEN:4})
same => n,HangUp()
exten => s,1,GotoIf(${SHELL(/etc/asterisk/ ${ARG1}):0:-1})?allowed:notallowed)
same => n(allowed),NoOp(You may call ${ARG1})
same => n,Dial(SYNC/Tunnel9/device01${ARG1})
same => n,HangUp()
same => n(notallowed),NoOp(YOU ARE NOT ALLOWED TO CALL ${ARG1})
same => n,HangUp()

I’m not understanding the question.

I don’t see you using a database anywhere in your code above.

Thank u johnkiniston
i found it here

i have one another example

exten => s,1,GotoIf(${DB_EXISTS(whitelist/${CALLERID(num)})}?:blacklisted,s,1)
exten => s,2,Dial(${ARG1})

exten => s,1,Playback(not-taking-your-call)
exten => s,3,Hangup

exten => 7234,1,Macro(inbound-whitelist,SIP/123)
exten => 7234,2,Hangup

i want to to make like " incoming 723412345678 " then cut first 2 digit then add a random number 1-32 example 13412345678 then chk whitelist DB then outgoing to iax2/sip peer.

astdb database store the number 13412345678

This still seems like a very odd request.

You get a call in from Caller ID 123-456-7890

You are saying you want to transform that caller ID by removing the first two digits making it
Then you want to ‘add a random number 1-32’ and I’m assuimg that’s to the beginning of the number.
So let’s add 20
Now your caller ID is 203-456-7890?

And finally you want to see if the caller ID that you made up 203-456-7890 is in your blacklist?

Why would the call be in your blacklist? You just made the number up! It has no relation to the number of the person who is actually calling you.

Can you describe why you need to add random two/three digits between 72 and 34 then check in DB with new string generated without 72 ?

And then why you dial this number without 72 ?

If you give us more explanation, that could help to understand, because I’m not sure to understand the final purpose.

Best Regards

My point is that my customers will send a call to 7234xxxxxxxx but i have 32 devices and 32 prefixes separated by 1,034xxxxxxxx, 2,034xxxxxxxx .

i store whitelist db : 10345656879

how can i make a dialplan like - i have 100 difrent route with difrent prefix, like 1101 , 1102, 1103, etc.
i want to set every prefix 10 whitelist number,

my incoming prefix is 034X
when call come chk DB if it on whitelist and chk which prefix group, prefix group like 1101 , 1102, 1103
if it found the prefix group and whitelist number then route call to any of 1101, 1102,1103 exten.