DNIS changing

Hi,

I have registered my Asterisk server to a sip provider and can reach my soft phone from the public telephone network by calling numbers that I have bought. I would now need to get the DNIS number (B-number) from the call to my soft phone so I know how I should answer the call (I have several incoming numbers and they should be answered differently). If I turn on "sip debug" in Asterisk I can see the DNIS in the "To:"-field in the sip header when the call comes in (<sip:"dnis-number"@"sip-provider-ip">). A few "sip conversations" later the "To:"-field changes to my soft phones local number (<sip:200@192.168.1.100:5060>).
Can I somehow get the original DNIS into a variable or is there some other way to change the sip header?

Regards,
strobe0
strobe0Asked:
Who is Participating?
 
grbladesCommented:
The variable ${EXTEN} contains the dialed number aswell.

> How can I get the DNIS 1111 from the line exten => 1111,1,Dial(sip/myphone1) to the client (soft phone)?
I dont quite understand the question. What exactly do you wish to do?
0
 
grbladesCommented:
Normally the DNIS is mapped directly to the extension in asterisk. In your sip.conf you have a context defined for the provider. As an example lets say it is from-provider.

Now in extensions.conf you probably have an entry like :-

[from-provider]
exten => s,1,Dial(sip/myphone)

All you need to do is change it to reference the DNIS number. If your DNIS numbers are 1111, 2222 and 3333 you would have :-

[from-provider]
exten => 1111,1,Dial(sip/myphone1)
exten => 2222,1,Dial(sip/myphone2)
exten => 3333,1,Dial(sip/myphone3)
0
 
strobe0Author Commented:
Ok, at the moment I´m creating an internal number when I´m registering with my sip provider. That maybe the wrong way to do it...
I´m sending the incoming calls to queues. How can I get the DNIS 1111 from the line exten => 1111,1,Dial(sip/myphone1) to the client (soft phone)?
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
strobe0Author Commented:
grblades:

After som testing I found out that this didn´t work for me. Could you please provide some more help even if I already accepted your solution?

When I change extensions.conf to look like this:
exten => 358xxxxxxx,1,Dial(IAX2/400)       //The x´s are real numbers, I just masked them :)

I get the following error message when I call 358xxxxxxx number:

[Oct 11 22:09:09] NOTICE[2013]: chan_sip.c:13664 handle_request_invite: Call from '358xxxxxxx' to extension 's' rejected because extension not found.
0
 
grbladesCommented:
Try adding this as a test. Next run 'asterisk -r -vvv' and monitor the output as you make a call in. You should see the NoOp command appear with the extension that it was given specified. This is the number you need to put in as the proper extension in the dialplan. Sometimes you are given the full number including country code, sometimes just the local number etc... so doing this you can see exactly what format you are being given the called number in.

exten => s,1,NoOp(${EXTEN})
exten => s,n,Hangup
0
 
strobe0Author Commented:
Ok, I just solved it :)

I had to put an extension at the end of the register-"option" in sip.conf and then use that one in extensions.conf to match it.
Like this in sip.conf: register => 358xxxxxxx:password@sip-provider-host/358xxxxxxx
Like this in extensions.conf: exten => 358xxxxxxx,1,Dial(IAX2/400).
0
 
MrYowlerCommented:
Just a quick thought, but you can also establish separate contexts for each incoming line, by adding something like this in sip.conf:

[358xxxxxxx]
.
.
.
context=358xxxxxxx-inbound
.
.
.

This directs inbound calls for this line to the [358xxxxxxx-inbound] context block in your extensions.conf file.  A lot of people seem to think that all inbound traffic has start in a context like [incoming] or [sip], but you can use any context you want, each complete with their own extensions, by simply defining it correctly in sip.conf.

I'm a little late on the draw, here, but I hope it helps somebody...  :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.