CallerID when forwarding via phone?

I’m relatively new to IP-telephony and Asterisk - and I do hope that I don’t ask a question answered before in here.
Short: I managed to have a (as I guess securely) working asterisk config where my phone’s extensions are shown correctly when calling out. But: When forwarding my phone via its own buttons (Snom phones) the number is crippled.

Longer: Lets assume I have the number range 0049401234567-xx. I have ~15 phones registered in my sip.conf:

[310](intern) ; first extension.
callerid="MY NAME" <310>

The extension 310 has the outgoing extension -10, so its number should be 0049401234567-10. To achieve that I have the following snippet in my exensions.conf:

exten => _X.,1,Set(DW=${CALLERID(num):1})
exten => _X.,n,NoOp(${DW})
exten => _X.,n,Set(CALLERID(num)=0049401234567)
exten => _X.,n,Set(CALLERID(name)=0049401234567${DW})
exten => _X.,n,Dial(SIP/${EXTEN}@0049401234567)
exten => _X.,n,Hangup

For my internal extensions that works fine. But: When I push the forward button on my phone (i.e. to my mobile) and I get called by 040987654321 on my mobile’s display it says "called from 004940123456740987654321 - which of course makes perfectly sense as I just take everything for the CallerID (except the first digit) and append it to my trunk’s number. So my question is not what I’m doing wrong but rather: How can I make it right? Have I missed something big?

Of course I could try to see whether the CallerID-Length is 3 digits and then have an if-clause - but something tells me that this is not the right way.

Thanks in advance!

Why not use the setvar option for SIP peers/friends/users to configure a variable that defines the callerid to use on trunk calls, and then update the callerid to that before dialing?

1 Like

Thank you! Sounds good. I added that so my extension.conf looks like this:

exten => _X.,1,Set(CALLERID(name)=${EXTERNAL_CALLERID})
exten => _X.,n,Dial(SIP/${EXTEN}@0049305130444)
exten => _X.,n,Hangup

My sip.conf has now a line more for every peer like this:


That works perfectly when calling out and even works for external calls when forwarding to mobile. But: When I call from inside and forward my phone to mobile I just get the trunk’s number as my EXTERNAL_CALLERID doesn’t seem to be set.

Any ideas?

1 Like