How to Set Prefix for Caller ID of Incoming Calls

To set the prefix before the caller ID number when incoming call arrives in extension, it’s possible to set it for ISDN trunk (BRI/E1) on MyPBX’s web interface directly. While for other trunks, like SIP trunk or PSTN trunk, we need to customize configuration file to make it work. Here is a simple manual to guide you how to do that.
In this example, we will show you how to add the prefix of 0 before the caller ID number when the call comes from an SIP trunk.

Step1. Create the inbound route with the wanted destination you want. For example:

Step2. Login MyPBX via SSH access. We need to enable it in ‘LAN settings’ page first, you may need to restart MyPBX to take effect if the firmware version is lower than X.19.0.43.

Try to access MyPBX by using terminal software like putty.exe, you can try this link to download directly:

Open it, input MyPBX IP address in this example, and the port is 8022.

Username: root
Password: ys123456

Step3. Find the configuration file and modify it.
Try command “vi /etc/asterisk/extensions.conf ” and find the configuration file of inbound route “voip_in”.


Add the content: exten = s,n,Set(CALLERID(num)=0${CALLERID(num)})
Like the following picture shows.

Step4. Copy the whole configuration content of this inbound route, then save it to folder /persistent/custom-cfg/extensions_custom.conf

exten = s,1,Set(CDR(userfield)=Inbound)
exten = s,n,GotoIf(${DB_EXISTS(blacklist/${CALLERID(num)})}?Blacklist-Handle,s,1)
exten = s,n,FindForMobile(${CALLERID(num)})
exten = s,n,GotoIf($[${LEN(${MobileToExten})}>1]?mobile-exten-match,${MobileToExten},1)
exten = s,n,Set(TRUNKDID=${IF($[${ARG2}=s]?${CALLERID(name)}:${ARG2})})
exten = s,n,Set(CALLERID(num)=0${CALLERID(num)})
exten = s,n,GotoByTimeCondition(default,voicemenu-custom-welcome,660,1,,voicemenu-custom-welcome,660,1,,Always-Hangup,s,1)
exten = s,102,Goto(Blacklist-Handle,s,1)

vi /persistent/custom-cfg/extensions_custom.conf

Paste the above configuration content, then save it.

You can execute these two commands (mypbxconf; asterisk –rx “module reload” or click ‘apply changes’ on web to take effect.

With these modification, the caller ID of incoming call through the inbound route voip_in will be added with prefix 0.
For example, the original caller ID is 9999, the new caller ID number will be 09999, which is needed for some customers when they need to call back directly.

Have more questions? Submit a request


Article is closed for comments.