Remove local prefix from caller id on incoming calls on a sip trunk

Currently the caller id on local calls coming in from a trunk show like 015211200
However I want to drop the 01 prefix on these incoming calls. show it would show on the phones as 5211200.

How can I do this?
Currently running freepbx distro 3.211 stable with asterisk 11 - fresh install

For a FreePBX-based solution, you would need two inbound routes: one matching calls starting with 01 and one for other calls. Point your 01 inbound route to the Set CallerID module and set the CallerID Number field to ${CALLERID(num):2}. Then pass it on to wherever.

1 Like

I am assuming your calls are coming in on SIP trunks.

Put the following in /etc/asterisk/extensions_custom.conf

exten => _X.,1,GotoIf($["${CALLERID(number):0:2}"!=“01”]?nochange)
exten => _X.,n,Set(CALLERID(number)=${CALLERID(number):2})
exten => _X.,n(nochange),Goto(from-trunk,${EXTEN},1)

Then when a call comes in send it to context from-trunk-check-caller-id instead of from-trunk and this little piece of dialplan will strip off the first two digits (if they are 01) of the caller id and then send it on to the from-trunk context in the form you want it.

1 Like