How to get provider CallerID, not mine?

Hi all! Such situation.

I have next structure. SIP Provider - Asterisk <-IAX2-> Asterisk - Abonent

And when I calling asterisk CALLERID presented callerid from caller. I need get callerid from provider. How Can I do it?

Why are you setting caller ID? If you don’t need to set it, don’t. If you are setting it on the first system, you will need to capture the original ID and, probably, encode it into the number dialled over IAX.

Obviously because I need to. When a call is received from this number to an internal number. I need to do
exten => 2972,1,GotoIf($[“${CALLERID(num)}” = “311727828”]?2:3)
exten => 2972,2,Dial(${EXTEN})
exten => 2972,3,Dial(${TRUNK1}555-555-555)
Where 311727828 is provider callerID, not a caller people.

I would appreciate an example.

Nowhere does that code set the caller ID! Where are you changing the caller ID?

Is the real problem that the SIP provider is not actually sending you the caller ID, which you can’t solve, or is sending it, but not in the From: header, which you probably can solve, by having Asterisk use the proper caller ID.

I recieved callerID provider in Sip_header

Executing [s@incoming-callcentric:3] NoOp(“SIP/callcentricB5-0000014c”, “”) in new stack
– Executing [s@incoming-callcentric:4] NoOp(“SIP/callcentricB5-0000014c”, “sip:MYCALLERID@ip;tag=m2X4y90er2gBc”) in new stack


exten => s,3,NoOP(${SIP_HEADER(TO)})
exten => s,4,NoOP(${SIP_HEADER(FROM)})

It sounds like you didn’t write the dialplan, in which case you really need to ask the person who did write it.

Without the actual dialplan, I have to assume that two different pieces of data are being displayed, but I don’t know what those pieces of data are.

Bro, I wrote this dialplan.
From first asterisk, where accepted calls from providers.
I have two NoOp
exten => s,3,NoOP(${SIP_HEADER(TO)})
exten => s,4,NoOP(${SIP_HEADER(FROM)})

and I see provider callerID and callerid callers.
3 NoOp(“SIP/callcentricB5-0000014c”, “”) in new stack
4 NoOp(“SIP/callcentricB5-0000014c”, “sip:MYCALLERID@ip;tag=m2X4y90er2gBc”) in new stack

But I dont know how to sent Provider Caller ID from this SIp Header to next Asterisk connected by IAX2.

This is point why I created this question

In SIP trunk for this connection I have some parameters, such as fromuser= and defaultuser=

Maybe I can use this? but how?

If a caller ID is being sent in the To header, that is a misuse of the To header.

To set the caller ID in the outgoing leg, you change it for the call, using Set(CALLERID(num)=…) where … is the string you actually want. If that string is present in the the To or From header above, you can use string functions, like CUT, to extract the user part, or you can use the regular expression operator.

To see how FreePBX does this for the more conventional case where To contains the original called number, rather than the caller ID, see:

I have reservations about a missing ${} on one of the CUTs, but I presume it works, as it is in their code.

The callerID values sent to you in the from and to headers of the SIP message, will be saved in the asterisk channel, and if not changed, usually used by the Dial application, on outbound calls.

As such, the only thing you should need to do, is call Dial. No need to change the caller ID at all.

It is possible you’ve setup your IAX trunk with a callerID that overrides the original, in that case you should remove this caller ID from the iax config file.

This is not my point, this is callcentric.

Why should I do set callerid on the first server if this whole task is needed for one of the hundreds of subscribers on the second server? What you propose will affect all all subscribers. In my opinion, you do not understand the meaning of the question.


I think there’s a misunderstanding of terms here. I think by “provider callerid” they mean the DID that was called for the incoming call.

You seem to be expecting us to read your mind. You might want to note that chano’s reply makes the same assumption I did in my original reply, namely that you have changed the caller ID yourself. That should indicate to you you are failing to explain your unusual system adequately.

In the description of the question, below the title, I described what I mean. People just don’t want to read the description.

I read the description and still am uncertain. That’s 3 people who don’t really understand what you mean.

I was wondering that. That’s partly why I gave the FreePBX example and certainly why I bolded called number.

It seems that the Western education system is really in crisis.

Okay, I’ll walk away from this thread then. Other people may respond or not.