How to Add P-Asserted-Identity in SIP INVITE Packet


This application is aim at adding a P-Asserted-Identity header in Invite Packet. In some case, when someone want to hide the CallerID from MyPBX, they can use this header to send the Anonymous Information. Please pay attention that, this function needs to be supported by the SIP provider.


How to Set

Step 1. Download a putty in your PC

We can access MyPBX SSH using putty or other terminal tools.

Putty download link:

Step 2. Open putty by SSH 

  • Before we open the putty by ssh,we need check the settings in MyPBX first.

Path:System---Network Settings---LAN Settings


  • Settings in putty




  • Login by ssh




Step 3. Edit by SSH

  • Run this command to check this configuration file extensions.conf

cat  /etc/asterisk/extensions.conf

  • Copy all the content of context [macro-trunkdial-failover-0.3] .


  • Run this command

vi /persistent/custom-cfg/extensions_custom.conf

To edit this extensions_custom.conf file, press “i” to login the edit mode.

Paste whole content of context [macro-trunkdial-failover-0.3] here.

Here is the Whole content for extensions_custom.conf

Please pay attention for the content in red, and make sure the order number is correct.


exten = s,1,NOOP(do call out)

exten = s,2,GotoIf(${DB_EXISTS(oblacklist/${ARG3})}?Blacklist-Handle,s,1)

exten = s,3,Gotoif($[${LEN(${FromSystemAlert})}>0]?6:4)})

exten = s,4,Gotoif($[${LEN(${ARG$[${ARG1}+4]})}>0]?5:6)

exten = s,5,Goto(s,6)

exten = s,6,Set(TCOUNT=4)

exten = s,n,Set(CDR(userfield)=Outbound)

exten = s,n,Set(OldCallerID=${IF($[${LEN(${PINUSER_CONTEXT})} > 0]?${PINUSER_CONTEXT:13}:${GETNAMEBYCALLERID(${CALLERID(num)})})})

exten = s,n,Set(TOUCH_MONITOR=${OldCallerID}-${ARG3})

exten = s,n,NOOP(${DOD_${ARG${TCOUNT}}_${OldCallerID}})

exten = s,n,Set(TIMEOUT(absolute)=${IF($[${LEN(${ABSOLUTE_TIMEOUT_${OldCallerID}})} > 0]?${ABSOLUTE_TIMEOUT_${OldCallerID}}:${ABSOLUTE_TIMEOUT})})

exten = s,n,Set(DLSTAT=UNKNOW})

exten = s,n,SetCktCustom(sendrpid,no,no)

exten = s,n,Gotoif(${ARG1}>0?1-dial,1)

exten = 1-dial,1,Gotoif($[$[${TCOUNT}-3]>${ARG1}]?nextrouter,1)

exten = 1-dial,2,Gotoif($[${LEN(${DOD_${ARG${TCOUNT}}_${OldCallerID}})} > 2]?setdod,1:1-dial,3)

exten = 1-dial,3,Set(CALLERID(name)=${IF($[${LEN(${CID_${ARG${TCOUNT}}})} > 2]?${CID_${ARG${TCOUNT}}}:${CALLERID(name)})})

exten = 1-dial,4,Set(CALLERID(num)=${IF($[${LEN(${CID_${ARG${TCOUNT}}})} > 2]?${CID_${ARG${TCOUNT}}}:${CALLERID(num)})})

exten = 1-dial,5,Set(_SIPSRTP=${SIPPEER(${ARG${TCOUNT}},srtpcapable)})

exten = 1-dial,6,Set(OUTDIALOPT=${IF($[${LEN(${GSM_${ARG${TCOUNT}}})} > 0]?tTkKWwXxr:${DIALOPTIONS})})

exten = 1-dial,7,NOOP(null for std)

exten = 1-dial,8,Gotoif($[${LEN(${FromSystemAlert})}>0]?sys-dial,1)})

exten = 1-dial,9,SIPAddHeader(P-Asserted-Identity: "${CALLERID(name)}" <sip:${CALLERID(num)}@XX.XX.XX.XX>) // XX.XX.XX.XX is the IP address for your SIP provider, sometimes a port is necessary according to the sip provider.

exten = 1-dial,10,Dial(${${ARG${TCOUNT}}}/${ARG2}${PREFIX_${ARG${TCOUNT}}}${ARG3},,${OUTDIALOPT})

exten = 1-dial,n,Goto(1-${DIALSTATUS},1)

exten = sys-dial,1,Macro(sysdial,${${ARG${TCOUNT}}}/${ARG2}${PREFIX_${ARG${TCOUNT}}}${ARG3},,${OUTDIALOPT})

exten = setdod,1,Set(CALLERID(name)=${DOD_${ARG${TCOUNT}}_${OldCallerID}})

exten = setdod,2,Set(CALLERID(num)=${DOD_${ARG${TCOUNT}}_${OldCallerID}})

exten = setdod,3,Goto(1-dial,5)

exten = 1-BUSY,1,Set(DLSTAT=9-${DIALSTATUS})

exten = 1-BUSY,2,Goto(2-dial,1)


exten = 1-CHANUNAVAIL,2,Goto(2-dial,1))


exten = 1-CONGESTION,2,Goto(2-dial,1)

exten = 2-dial,1,Set(TCOUNT=$[${TCOUNT}+1])

exten = 2-dial,2,Goto(1-dial,1)

exten = 1-out,1,playback(all-busy-now-try-call-later)

exten = 1-out,2,Hangup()

exten = 9-BUSY,1,playback(record/BusyLine)

exten = 9-BUSY,2,Hangup()

exten = 9-CHANUNAVAIL,1,playback(record/PinError)

exten = 9-CHANUNAVAIL,2,Hangup()

exten = 9-CONGESTION,1,playback(record/PinError)

exten = 9-CONGESTION,2,Hangup()

exten = nextrouter,1,GotoIf($[${LEN(${NEXTROUTER})} > 0]?${NEXTROUTER},${ORGINEXTEN},1:${DLSTAT},1)

exten = h,1,NOOP(no thing to do)


4)Type <Esc> ,and then type’:wq’ and <Enter> to save the file.


  • Type ‘mypbxconf‘ and ‘ asterisk -rx 'module relaod'  ‘ to make the settings effect.




Have more questions? Submit a request


Please sign in to leave a comment.