Set outgoing CallerID based on dialed number


i want to set the outgoing callerid based oin the number the user dialed.

What i have to do? I am searching the hole day in the internet, but i found no solution :frowning:

Thanks for help,


As you have not said otherwise we will assume that you are using a vanilla asterisk installation.

and we will also assume the users are sip peers.

what you can do is add a entry in the sip.conf for the users such as


then in the dialplan have

exten => s,n, Set(CALLERID(num)=${call_ID})


Hi Ian,

thanks for your quick reply.

I am using SIP peers, correct.

In your solution a sip peers gets a specific CallerID. What i want is, that when user A is Calling Number 123, it gets Callerid 20. When the same User A is calling number 456, it gets Callerid 30. I have a list of approx 10 external Numbers where another Callerid must be applied.


Ok thats simple

store the calleriD in the astdb then do a look up of that to check if the dialed number matches and then set that caller id


i am not an experienced asterisk-admin, so could you please give more details (exten.conf)? Where do i find the astdb?