Match numbers coming from a voip trunk


Ok I have looked for the answer but can’t seem to find it and to be honest I’m not really sure what I’m looking for. But what I want to do is match incoming calls coming from a voip provider so that I can do different things with the incoming numbers. The pattern matching doesn’t work cause the call always comes from the voip provider, however I know the number is getting passed along somewhere because when it rings to a phone the right CID is displayed and also the sip log show call from XXXXXXXXX and the number is correct. So where can I find this info so that I can distribute incoming calls similar to pattern matching?


This depends from Your provider.
What You can do to find out the target, the provider is sending the call to is issuing a sip set debug and trigger an incoming call through the provider after this. The debug output on the cli should give You the answer (TO-Header of the SIP-packet or - if applicable - P-Asserted-Identity or P-Preferred-Identity Headers).


If the phone is displaying the number, ${CALLERID(num)} should be enough. Actually, I would have thought that the / syntax in the dialplan extension field would work if the phone was receiving a valid network caller ID.

There is nothing inevitable about getting the service provider’s number in various fields, which is why you were asked to provide the debug output, to work out how your provider actually works. Some of the rest of that reply seems to have assumed you wanted DNID, but I think you want CLID.

Incidentally, Asterisk doesn’t have concept of a VoIP trunk; only the GUIs do.

Finally, this should have been asked in Asterisk Support.


Sorry for posting in the wrong section, and what is it called if it isn’t a trunk? Just curious I’m just starting out and trying to figure some things out. Here the debug output the numbers 7805555555 is the number that is calling and 7805555556 is the providers DID number.

<--- SIP read from UDP: --->
Via: SIP/2.0/UDP;branch=z9hG4bK0628a649;rport
From: "7805555555" <sip:7805555555@>;tag=as76a4ffee
To: <>
Contact: <sip:78055555@>
Call-ID: 77a38251435926b0480325d90181ef0e@
CSeq: 102 INVITE
Max-Forwards: 70
Remote-Party-ID: "7805555555" <sip:7805555555@>;privacy=off;screen=no
Date: Sat, 03 Sep 2011 15:50:43 GMT
Supported: replaces
Content-Type: application/sdp
Content-Length: 240

o=root 3017 3017 IN IP4
c=IN IP4
t=0 0
m=audio 19048 RTP/AVP 0 101
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -

Anyway thanks the CALLERID(num) works I just implemented it wrong when I tried it the first time. Thanks.


It’s a user agent which supports multiple simultaneous calls, but most phones support more than one simultaneous call.

Setting both To and From to the same think is not very helpful, but they are using Remote-Party-ID, so, as long as you have trustrpid set, you should be OK.