Override caller id with sip

Is it possible to use asterisk and send a sip invite with the from set with the caller id I want exposed?

We were thinking of using asterisk but not sure if it had this feature? We saw that is has other ways to sort of hack the solution where you dial *33, then connect the call, then dial the caller id number then the number you want to call, but this kind of seems like a hack. Is there a way to just set the from in the sip message and change asterisk config to pass that through? We tried on a friends asterisk but it didn’t work so we were thinking we might need to go with a different pbx.

It really depends on how you are initiating the call. Regardless, it is a very simple process.

If dialing from the dial-plan, simply do this before you Dial()

exten => EXTEN,1,Set(CALLERID(number)=5555551212)
exten => EXTEN,n,Dial(SIP/blah)

If dialing from a .call file you would simply include the “CallerID” parameter.

I initiate the call with a sip invite like below(from our server to asterisk) and want the XXXXXXX below in the sip message to be the caller id. I want asterisk to take that and stuff it in to be the caller id. Doesn’t your example make 5555551212 the caller id? I don’t want that. I want the XXXXXXXX below in the sip message to be the caller id. XXXXXXXX is different on every call out. See depending on the customer invoking our callout, we need to change the caller id to that customer’s number.

[code]INVITE sip:13035178902@ SIP/2.0
Call-ID: 01fa1ad952c136e18910a3304e2a9466@fastdragon
From: “unknown” sip:XXXXXXXXXX@;tag=fc831d0c-511f-4bfe-97a9-6d404e0030e1
To: sip:13035178902@
Via: SIP/2.0/UDP;branch=z9hG4bK-5dbc735e-2ed3-4064-aba3-a5157d150e8c;rport
Max-Forwards: 70
Contact: sip:6202@
Content-Type: application/sdp
Proxy-Authorization: Digest username=“6202”,realm=“asterisk”,nonce=“0a23c020”,uri=“sip:”,response=“112138d31cb3e8ffffbb50feab68b65c”,algorithm=MD5


5555551212 can be whatever your heart desires. I was just showing you the syntax for actually setting the callerID. If you want something different just put it in. If you want to use a variable you would do something like:

exten => EXTEN,1,Set(CALLERID(number)=${MYVAR})
exten => EXTEN,n,Dial(SIP/blah)

perfect, so what is the variable to use to take info out of the sip message and stick it as the caller id when the call is made? Is there such a variable?

what variable are you trying to pull out of the call?

I am trying to get the XXXXXX from that sip message in the above post. I don’t know what variable this is? I know nothing about asterisk either. Maybe there is other info I can put in the sip message that will go to a variable you know of? We wrote this sip stack so have complete control over adding stuff to the message if we need to, is there a location where the info will go into some asterisk variable?


it sounds like you are actually talking about the default functionality of asterisk native bridging.

I assume you are attempting to issue an INVITE to the asterisk server which will result in dialing out to a third party… correct?

SIP UA1 --> INVITE --> asterisk --> INVITE --> SIP UA2

And once SIP UA2 answers the phone, asterisk would bridge the calls together.

If that is what you are attempting to do, then you don’t need to do anything with CallerID… asterisk will send “From” value of the first INVITE as the “From” value of the second INVITE.

yes, that is 99% of what I am trying to do.

The exact picture which I think is the same is

SIP UA -> asterisk -> bandwidth.com -> PSTN

hmmmm, then maybe my provider bandwidth.com does not support this. I will have to call their support and try to debug this further then. Right now, all I get on the phone is "no caller id"

I use bandwidth.com and they most certainly support it. I would say the next steps are going to be providing the relevant snippet of your dialplan as well as the output of “sip set debug” (from the asterisk CLI).

I am sure it is something very simple…

really!!! cool…thanks…k…I will have to setup up some traces and debug further then and see what is happening.

I would like to know this too.