Inbound forwarded calls - inbound CID priority route

a stepping stone to a solution.

Stewart at this thread;

I don’t understand what he means by “context from-trunk”


START OF POST FROM STEWART

Assuming that your incoming trunk context is from-trunk, add or put this code into
/etc/asterisk/extensions_custom.conf

[from-trunk-checkdivert]
exten => _X!,1,Noop(RDNIS=${CALLERID(rdnis)})
exten => _X!,n,Goto(from-trunk,${EXTEN},1)

Change the context for the trunk to from-trunk-checkdivert
Apply config and make a test incoming forwarded call. Look at the Asterisk log for a line with something like
RDNIS=2125551212
showing the number that forwarded the call. If RDNIS is null, either the forwarding carrier doesn’t add a Diversion header, or your trunking provider doesn’t send it. If it is present, note the exact format and modify extensions_custom.conf to look like this

[from-trunk-checkdivert]
exten => _X!,1,Noop(RDNIS=${CALLERID(rdnis)})
exten => _X!,n,GotoIf($["${CALLERID(rdnis)}" = "2125551212"]?from-internal,*1234,1)
exten => _X!,n,Goto(from-trunk,${EXTEN},1)

Apply config and make another test call. The forwarded call should now be sent to voicemail for extension 1234.

Once this is working, add a similar GotoIf statement for each number for which you want to handle forwarding.

If you have trouble, post details including country, trunking provider and forwarding carrier.

END OF POST FROM STEWART