FreePBX is not taking the Caller ID from the "From:" field in the INVITE


I’m still trying to interconnect a FreePBX to my main PBX using a SIP trunk. That works so far, but I’m facing an issue.

This is from the SIP INVITE when the main PBX passes a call to FreePBX. The caller ID is the “017212345678” - but FreePBX does not take it and handles the call as anonymous. In the call event list, the caller ID is listed with “COMtrexx2” which is the username for the authentication.

From: "017212345678"<sip:[email protected]>;tag=6f5641d

Moving the Caller ID to the second part (<sip:[email protected]>) does not work as the FreePBX then returns an “401 not authorized”.

Any ideas how to tell FreePBX to take the CID from the right place?

Not tested, but try setting Context for your trunk to fixcid and adding to /etc/asterisk/extensions_custom.conf

exten => _X!,1,Set(CALLERID(num)=${CUT(PJSIP_HEADER(read,From),",2)}) 
exten => _X!,n,Goto(from-trunk,${EXTEN},1)

Replace from-trunk with what you previously had in Context.


And then the COMtrexx does what? If it responds to the challenge, setting Match Inbound Authentication to Auth Username should work.


If the COMtrexx is sending (or can be made to send) a Remote-Party-ID or P-Asserted-Identity header, try setting Trust RPID/PAI for the trunk to Yes.

Hi Steward,

Yes, that can be done (the PAI header). What should be the content of the PAI (I can set this as well)?

You mean the wrong place. You are taking it from the caller name, nut their number. I wonder if Set(CALLERID(num)=${CALLERID(name)}) would do it.

Really, you should be using an IP based trunk, so having the caller ID in the right place. And the cleanest fallback is for the other system to send the real caller ID in Remote-Party-ID or P-Asserted-Identity, which are the standard ways of signalling caller ID when the from user is used as an account name.

Yes, that would be the cleanest way. Generally this works, but unfortunately has a drawback: I want to use the FreePBX as “Spam prevention” using the Privacy and Call Screening feature. Therefore it needs to get the information if the original Caller IS is Anonymous.

Unfortunately the COMtrexx sets the number of the called trunk into the PAI field in this case, so FreePBX can’t detect this as anonymous.

Awesome! That made it work! This single little “Match Inbound Authentication to Auth Username” setting. Thank you! :+1:

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