Asterisk VoIP : Getting your outbound CallerID to show properly

We lately ran into a scenario where our asterisk server is connected via SIP trunk to our DID provider (mydivert.com). Our PABX server opens a single SIP trunk to the provider, however we have multiple DIDs running over this trunk. Having multiple DIDs means we can use multiple phone numbers, in different countries, benefiting from different rates and so on.

Our provider has the following three options when setting outbound caller ID:

  • Automatic
  • User selected DID
  • Set by PBX
  • Anonymous

We are interested in using the third option – Set by PBX. This would allow me to route different customers through different DIDs and have their number on display when they call. However when we set this and tried the normal things such as:

  • setting the trunk CID
  • setting the user extension CID

this still did not work, and the Caller ID would show the username we have with our provider. So we started from scratch and we removed the two items listed above. I next added the following in the trunk definition:

sendrpid=yes

You can see a short description of “send remote party id” here and here. I also have a custom outbound route which sends all 4 digit and above numbers starting with 9 out of this trunk (my_divert_abc), and I added the Caller ID settings there:

exten => _9XXX.,1,Set(DIAL_NUMBER=390784803156)
exten => _9XXX.,2,Set(CALLERID(num)=390784803156)
exten => _9XXX.,3,Set(CALLERID(name)=390784803156)
exten => _9XXX.,4,Set(CALLERID(all)= “390784803156” <390694803156>)
exten => _9XXX.,n,Dial(SIP/my_divert_abc/${EXTEN:1},60)

Lines 1-4 are the lines of interest. With the above settings the outbound CID worked