This works pretty well but only for extensions and not for ring groups and queues.
If I understood it correctly the FreePBX way is to add inbound routes for every single extension, this is something I really really want to avoid at 300+ extension.
Is there a way to do it for ring groups and queues too or to do it completely different ?
No, that won’t work. I’m rethinking my previous advice. What you need is a context that includes all the dialplan you need to reference. The context from-internal is such a context, but I’m reluctant to advise sending external calls directly to the from-internal context for security reasons.
I think in your shoes, rather than using from-internal, I would make my own context that looks like this:
[external-includes]
include => ext-group
include => ext-queues
include => from-did-direct
[from-special-trunk]
exten => _+49123433333XX,1,Goto(external-includes,${EXTEN:-2},1)
exten => _+49123433333XXX,1,Goto(external-includes,${EXTEN:-3},1)
exten => _+49123433333XXXX,1,Goto(external-includes,${EXTEN:-4},1)
include => from-pstn