Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an Asterisk open source phone system. My business will have many toll free 800 phone numbers, they all go to the phone system. When a client calls us, is it possible to know which 800 phone number they used? Maybe somewhere in the call logs? I already searched the call logs and I could not see this data.

Thank you

share|improve this question

migrated from stackoverflow.com Dec 9 '10 at 8:06

This question came from our site for professional and enthusiast programmers.

add comment

5 Answers 5

up vote 1 down vote accepted

On our system when we recieve a call I see

VERBOSE[21579] logger.c: -- Executing Set("IAX2/abcdef", "FROM_DID=1234567890") in new stack

in /var/log/asterisk/full, and possibly on the asterisk console too - I forget. Here abcdef is the name of the inbound route you've configured and FROM_DID is our line number. Even if you don't get the FROM_DID, are all you numbers set up for the same incoming IAX2 route - can you distinguish by route?

share|improve this answer
add comment

It depends on how the lines are configured upstream.

If toll-free numbers are mapped to a single incoming number then you're going to have to rely on whether the provider passes the dialled number using CLID - not all of them do. You're paying them for the service - why not ask them?

share|improve this answer
add comment
;Send calls from this DID to IVR 
exten => 18005555555,1,Answer 
exten => 18005555555,2,NoOp(Inbound Call on ${EXTEN} from ${CALLERID(num)}) 
exten => 18005555555,3,Goto(s,1)

I primarily use SIP no IAX. If you add this second line to your inbound dialplan you will be able to see what number it arrived on and where it orginated in the asterisk console.

If you want to log this information you may want to check out the log command rather than noop

http://www.voip-info.org/wiki/view/Asterisk+cmd+Log

If you want something custom you should read up on writing AGI. I've always written my AGI scripts using perl. Here is a link to the cpan module for Asterisk::AGI

I was going to link you to it but I don't have enough rep to post more than one link just google, "perl cpan asterisk agi"

Hope this helps

share|improve this answer
add comment

Are you using FreePBX? Are the 800 numbers coming from SIP/IAX trunks, or are they dahdi? T1? Do you want to route calls based on the DID, or just get stats around what numbers are being dialed? (If you use FreePBX and want to be able to route calls, read on...)

For my setup using FreePBX, I have dahdi and SIP trunks. I used the "Zap Channel DIDs" section in FreePBX to associate each channel with it's DID. For my SIP trunks, my provider had an option I needed to enable called DNIS (Dialed Number Information Service). Without that option, I had no way of seeing what DID an incoming call was using. With my settings as described, I can use FreePBXs Inbound Routes section to route calls based on DID.

share|improve this answer
add comment

The correct answer will depend on how your calls are delivered. You're looking for a service called DNIS or DNID in Asterisk. If your calls are coming in via SIP turn on SIP debug to see if it's getting set.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.