Link to home
Start Free TrialLog in
Avatar of strobe0
strobe0

asked on

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
Avatar of grblades
grblades
Flag of United Kingdom of Great Britain and Northern Ireland image

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)
Avatar of strobe0
strobe0

ASKER

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)?
ASKER CERTIFIED SOLUTION
Avatar of grblades
grblades
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of strobe0

ASKER

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.
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
Avatar of strobe0

ASKER

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).
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...  :)