Best way to strip four digit extension number from incoming sip packet with full 10 digit phone no

Hi All,
I’m relatively new to freePBX so this may be really easy to solve.
Our sip provider passes a 10 digit phone number in the sip packet.
We have 4 digit extensions and I need to strip off the first four digits and pass off the correct context.
In our old version of freePBX 12 we used an inbound route to match and pass off to a custom destination.
As I understand it the custom destination stripped off the first 6 digits and passed off the the from-internal context. This is the custom destination - from-internal,${EXTEN:6},1
I have tried to use this same method with freePBX 15 but doesn’t seem to work.
From Logs - [2023-09-28 06:20:00] NOTICE[2680][C-0000001b] chan_sip.c: Call from ‘XXTrunk1’ (X.X.X.X:5060) to extension ‘XXXXXX7500’ rejected because extension not found in context ‘fix-sip-packet’.
Firstly, is this a good way to strip the extension? Is there a better, easier way?
Have I got the syntax incorrect for freePBX 15?
Using FreePBX 15 with all PJSIP extensions.
Thanks in advance for any suggestions.

I think you have a missing ‘-’ in your custom destination. In my case, I have:


Note the dash in front of the 4. This gives me the last four digits of the DID and routes to the extension. I’m not sure what your context “fix-sip-packet” is for.

Thanks for the info Kenn10,
I’ll give that a try, more sure than cropping the first 6.
I’m unsure how I’ve created that context as well, been searching to find where it’s created.

Hi All,
This seems to be my problem.
Looking at the logs, the only entry I get from the incoming call is this one, nothing else.
From Logs - [2023-09-28 06:20:00] NOTICE[2680][C-0000001b] chan_sip.c: Call from ‘XXTrunk1’ (X.X.X.X:5060) to extension ‘XXXXXX7500’ rejected because extension not found in context ‘fix-sip-packet’.
The context is a custom one that I must have created when setting things up as it also includes our providers name that I took out.
Is anyone able to suggest where the incoming call is getting sent to this context before it hits anything else. I’ve searched trunks, incoming routes, config files but can’t seem to find this context??
Any suggestions welcome, thanks, Peter

If you are doing something custom, it might be in extensions_override.conf

What context does your trunk send calls to? Start your tracing from there.

It is likely self inflicted, until you fix your context fix-sip-packet you won’t be able to fix the problem

asterisk -x 'dialplan show *@fixsip-packet'

grep fix-sip-packet /etc/asterisk/exten*

Thanks comtech,

I’ll check out that file. Don’t think I have any real customisation.

yes you do, sip-fix-packet is your own customization

Hi Dicko,

That looks like just what I need to find the context.
Will give it a go as soon as I get back.

True, it’s got to be there:)

Thanks dicko & comtech for your assistance,
Searching dialplan and exten* files gave no joy as the problem was I hadn’t replicated this from the old server.
The only reference to this context was in the SIP Trunk Peer Deatails which I’d just stupidly just copied across.
Created the context with the fix and all working fine now.
Again, thanks you both for help.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.