Phone to dialplan?

SIMPLE newbie question:

How does a physical phone enter the dialplan? I’ve set up various contexts in my extensions.conf, tried numerous ‘recipies’ to get me going quickly, read the Asterisk book through and through and this just isnt obvious to me.

Although I only have one phone right now what if I had multiple - let’s say 3. When I dial some random number it talks to my asterisk server and, I presume, interrogates the extensions.conf file. Fine. But how does it know which context to enter in order to call out ?

Maybe understanding of this piece of data will enable me to move forward.

thx.

When you setup a device, let say a sip device the in the sip.conf when you define a new user, you must add the line context=[theconextextyouwantthephonetobepart]

Then, when you dial something, Asterisk know that is phone is part of which context then it loof for the extension you just dialed in this context.

and conversely, if you’re using a zap channel (analog phone tied directly to a TDM port), then the context that is defined in zapata.conf for that channel or group is the one that the phone uses.

so, basically, for the technology you are using (zap, sip, iax, etc), whatever context is defined (either globally or per-device) is the one the device defaults to.

the beautiful thing about this is you have have two identical devices sitting right next to each other that have completely different ‘personalities’ on the PBX, and can do completely different things based on your dialplan - you’re not locked down to one single set of rules for all your phones.

hope this helps.

I got that part. I should have been clearer on my question. Sorry. how to keep this simple?

Let’s say I have two phones [I suppose ‘extensions’ is the proper telephony terminology?] that I’ll call ‘alpha’ and ‘beta’.

I want to be able to dial the same number on each phone but have the phone use a different service to connect: (ie alpha use fwd and beta use voipjet). maybe the phones are with different companies or maybe I just want redundant service providers.

Now, if I dial 55555 on alpha, how does the call get routed to the section of the dialplan for alpha instead of the dialplan for beta?

In other words, what binds phone alpha to it’s particular section of the dialplan?

Im not certain if my confusion is clear. hope that this is comprehensible.

thx

Ok, I reread your answers and now I’m changing my postulate of how this all works.

When the asterisk server recieves the incoming traffic from the phone it first interrogates the sip.conf file and not the extensions.conf. Somehow - and that’s still unclear to me - it figures out which sip.conf entry is the match for the phone data and then uses that to determine which part of the dialplan to interrogate via the ‘context’ lines you mentioned.

Is that it?

If so, what is my asterisk server matching on in order to choose which entry to use ? The name of the phone I entered into it when I set the phone up? Does the sip.conf entry have to match that exactly?

[quote=“jameschaucer”]

When the asterisk server recieves the incoming traffic from the phone it first interrogates the sip.conf file and not the extensions.conf. Somehow - and that’s still unclear to me - it figures out which sip.conf entry is the match for the phone data and then uses that to determine which part of the dialplan to interrogate via the ‘context’ lines you mentioned.

Is that it?

If so, what is my asterisk server matching on in order to choose which entry to use ? The name of the phone I entered into it when I set the phone up? Does the sip.conf entry have to match that exactly?[/quote]

If you want both phones to be on the same ‘wave length (i.e. to have all the same rules etc.)’ then you should have them in the same context. In sip.conf where you put in entires for your diffrent phones under your phones one of the entries is context. You should have in there context=NameOfContextForPHones (where NameOfContextForPHones is the context that you want for the phones). Next in extensions.conf you have to create a context and tell asterisk what to do when some one calls from the phone. For exaple you may have this:

Exten => 1,1,Dial(SIP/phone1) ; If user dials 1 will call phone 1
Exten => 2,1,Dial(SIP/phone2) ; If user dials 2 will go to phone2

Exten => _XXXXXXXXXX,1,Dial(SIP/${EXTEN}@SipProvider) ; For external dialing this is asuming that you are using sip. Also replace SipProvider with your providers name in sip.conf

Exten => 6666,1,Answer ;Answers when some one calls extension 6666
Exten => 6666,MusicOnHold ; And then comes here and plays music for them

Yes, I understand how calls coming in from the outside world get routed to my phones.

What I dont understand is how calls from my phones - the phones in my house - gets routed out to the outside world.

When I pick up my phone and dial a number it - my grandstream gxp2000 - looks at it’s own personal configuration and sees the ip address of my asterisk server. It contacts the asterisk server and the asterisk server then uses some information from my phone to match to some information inside the asterisk configuration files in order to determine how to route the call out to the outside world. I dont understand what it is matching on to make the outgoing calls happen. I totally understand how incoming calls happen.

When I place a call the debug messages appear to tell me that the call is being routed right back to the phone Im calling from. So I started this question off just attempting to understand the data flow. I thought that would help me to work out my configuration problem on my own.

I have configured the phone to make calls directly out to fwd and that seems to work. But I need my asterisk server to handle the calls for me so that I can use all of its nifty features. Now that I’ve reconfigured my phone to point to my asterisk server I cant get out anymore.

Wrong !!

What happens is your phone is programed with a user ID and pass. The info is stored in asterisk and in your phone. When your phone gets turned on it try’s to register with asterisk. If the user id and pass that the phone gives match what asterisk has then the phone becomes registerd. In sip.conf you specify what contexct this sip extension should be in. Next when you place a call, asterisk gets the call from the phone and handles it based on what you have specified in the context that you have for that phone. If you can please post your sip.conf as well as extensions.conf so I can see what you have going on.

Dovid, thanks for clearing that up. I’m so close now -at least I think I am- I can taste the success.

If you can put up with my stupid questions for another round or two I think I’ll be ‘dialing’.

I fiddled with my setting a bit more and I can see that I’m closer now. It’s looking in the correct section of my dialplan for a rule matching the number I dialed. But then it doesnt go out. SO CLOSE!!!

So, I’m attaching my files and a bit of my debug output for you -in case you need it.

Oh, also FYI:

asterisk 1.2.7.1
freebsd 6.1
ports 1000-20000 on my dsl router/firewall forwarded to my asterisk server
dsl is also natting addresses outbound
asterisk server and phone on same local non-routable network

sip.conf

[general]

register => 785413:Zendar1a@fwd.pulver.com
bandwidth = low
disallow = lpc10
jitterbuffer = no
forcejitterbuffer= no
tos = lowdelay
externip = 74.226.83.67
localnet = 192.168.0.0/255.255.0.0

qualify = yes
diallow = all
allow = ulaw
allow = alaw
allow = gsm

;--------------------------------------

[out-fwd-785413]

type = peer
host = dynamic
username = 785413
secret = Zendar1a

auth = md5,plaintext
callerid = Cameron Walker
nat = no
canreinvite = no
insecure = very

context = outgoing

[Grandstream1]

type = friend
host = dynamic
username = testlogin
secret = testpassword

auth = md5,plaintext
callerid = Cameron Walker
nat = no
canreinvite = no
insecure = very

context = default

extensions.conf

[general]
static = yes
writeprotect = no
autofallthrough = yes
clearglobalvars = no
priorityjumping = no
qualify = yes

[default]
exten => s,1,Dial(SIP/Grandstream1,10,r)
exten => 55555,1,Dial(SIP/out-fwd-785413/${EXTEN})

[outgoing]
exten => 613,1,Dial(SIP/out-fwd-785413)
exten => 612,1,Dial(SIP/out-fwd-785413/612)

exten => 55555,1,Dial(SIP/out-fwd-785413/613)

debug output

<-- SIP read from 192.168.1.96:5060:
INVITE sip:55555@192.168.1.97 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.96;branch=z9hG4bK358592d6ee58c8ea
From: sip:testlogin@192.168.1.97;tag=75d7b25052177f43
To: sip:55555@192.168.1.97
Contact: sip:testlogin@192.168.1.96
Supported: replaces, timer
Call-ID: 51cc2d8e7341ca87@192.168.1.96
CSeq: 63426 INVITE
User-Agent: Grandstream GXP2000 1.1.0.5
Max-Forwards: 70
Allow: INVITE,ACK,CANCEL,BYE,NOTIFY,REFER,OPTIONS,INFO,SUBSCRIBE,UPDATE,PRACK
Content-Type: application/sdp
Content-Length: 257
v=0
o=testlogin 8000 8000 IN IP4 192.168.1.96
s=SIP Call
c=IN IP4 192.168.1.96
t=0 0
m=audio 5004 RTP/AVP 0 8 4 18 3
a=sendrecv
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:4 G723/8000
a=rtpmap:18 G729/8000
a=rtpmap:3 GSM/8000
a=ptime:20

— (13 headers 13 lines)—
Using INVITE request as basis request - 51cc2d8e7341ca87@192.168.1.96
Sending to 192.168.1.96 : 5060 (non-NAT)
Found no matching peer or user for '192.168.1.96:5060’
Found RTP audio format 0
Found RTP audio format 8
Found RTP audio format 4
Found RTP audio format 18
Found RTP audio format 3
Peer audio RTP is at port 192.168.1.96:5004
Found description format PCMU
Found description format PCMA
Found description format G723
Found description format G729
Found description format GSM
Capabilities: us - 0x8000e (gsm|ulaw|alaw|h263), peer - audio=0x10f (g723|gsm|ulaw|alaw|g729)/video=0x0 (nothing), combined - (ulaw|alaw|gsm)
Non-codec capabilities: us - 0x1 (telephone-event), peer - 0x0 (nothing), combined - 0x0 (nothing)
Looking for 55555 in default (domain 192.168.1.97)
list_route: hop: sip:testlogin@192.168.1.96
Reliably Transmitting (no NAT) to 192.168.1.96:5060:
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 192.168.1.96;branch=z9hG4bK358592d6ee58c8ea;received=192.168.1.96
From: sip:testlogin@192.168.1.97;tag=75d7b25052177f43
To: sip:55555@192.168.1.97;tag=as072be54f
Call-ID: 51cc2d8e7341ca87@192.168.1.96
CSeq: 63426 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Contact: sip:55555@192.168.1.97
Content-Length: 0


rcw2*CLI>
<-- SIP read from 192.168.1.96:5060:
ACK sip:55555@192.168.1.97 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.96;branch=z9hG4bK358592d6ee58c8ea
From: sip:testlogin@192.168.1.97;tag=75d7b25052177f43
To: sip:55555@192.168.1.97;tag=as072be54f
Contact: sip:testlogin@192.168.1.96
Call-ID: 51cc2d8e7341ca87@192.168.1.96
CSeq: 63426 ACK
User-Agent: Grandstream GXP2000 1.1.0.5
Max-Forwards: 70
Allow: INVITE,ACK,CANCEL,BYE,NOTIFY,REFER,OPTIONS,INFO,SUBSCRIBE,UPDATE,PRACK
Content-Length: 0

— (11 headers 0 lines)—
Destroying call ‘51cc2d8e7341ca87@192.168.1.96’

Ok off the bat here are some issues that I see:

  1. You must also forward ports 5060-5090.
    2)NAT must = yes in all places in sip.conf because you are behind NAT
    3)Canreinvite muxt be set to no because you are behind NAT and asterisk has to sit in tha media path.

There also may be issues with your Dial command. Try these changes first and see what happens.

CLOSE!!!

I made your changes except for the ports - I already have ports 1,000 to 20,000 forwarded.

It actually tried to dial. Unfourtunately it looks like it tried to dial itself. That is, if Im understanding the messages correctly. Still not familiar enough with this to really say for sure.

Using INVITE request as basis request - 370cecb6d49059e4@192.168.1.96
Sending to 192.168.1.96 : 5060 (non-NAT)
Found no matching peer or user for '192.168.1.96:5060’
Found RTP audio format 0
Found RTP audio format 8
Found RTP audio format 4
Found RTP audio format 18
Found RTP audio format 3
Peer audio RTP is at port 192.168.1.96:5004
Found description format PCMU
Found description format PCMA
Found description format G723
Found description format G729
Found description format GSM
Capabilities: us - 0x8000e (gsm|ulaw|alaw|h263), peer - audio=0x10f (g723|gsm|ulaw|alaw|g729)/video=0x0 (nothing), combined - (ulaw|alaw|gsm)
Non-codec capabilities: us - 0x1 (telephone-event), peer - 0x0 (nothing), combined - 0x0 (nothing)
Looking for 55555 in default (domain 192.168.1.97)
list_route: hop: sip:testlogin@192.168.1.96
Transmitting (no NAT) to 192.168.1.96:5060:
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.1.96;branch=z9hG4bK6559e40de5a2e6a8;received=192.168.1.96
From: sip:testlogin@192.168.1.97;tag=c1b3c4b5edc506ea
To: sip:55555@192.168.1.97
Call-ID: 370cecb6d49059e4@192.168.1.96
CSeq: 7475 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Contact: sip:55555@192.168.1.97
Content-Length: 0

-- Executing Dial("SIP/192.168.1.97-0869a000", "SIP/out-fwd-785413/55555") in new stack

Destroying call '3d9cff180e2fa04258c254543e2e8452@161.135.204.139’
Aug 7 19:21:31 NOTICE[46528]: app_dial.c:1029 dial_exec_full: Unable to create channel of type ‘SIP’ (cause 3 - No route to destination)
== Everyone is busy/congested at this time (1:0/0/1)
== Auto fallthrough, channel ‘SIP/192.168.1.97-0869a000’ status is 'CHANUNAVAIL’
Transmitting (no NAT) to 192.168.1.96:5060:
SIP/2.0 503 Service Unavailable
Via: SIP/2.0/UDP 192.168.1.96;branch=z9hG4bK6559e40de5a2e6a8;received=192.168.1.96
From: sip:testlogin@192.168.1.97;tag=c1b3c4b5edc506ea
To: sip:55555@192.168.1.97;tag=as2972ddac
Call-ID: 370cecb6d49059e4@192.168.1.96
CSeq: 7475 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Contact: sip:55555@192.168.1.97
Content-Length: 0
X-Asterisk-HangupCause: No route to destination

bump

post result of CLI>sip show peers
Your configs looks a bit strange for me. what does bandwitch=, jitterbuffer=, forcejitterbuffer= and tos= do in sip.conf ? it’s an iax parameters.
doeas anybody ask for debug logs ? You don’t have to turn debug on to see
– Executing Dial(“SIP/192.168.1.97-0869a000”, “SIP/out-fwd-785413/55555”) in new stack
Aug 7 19:21:31 NOTICE[46528]: app_dial.c:1029 dial_exec_full: Unable to create channel of type ‘SIP’ (cause 3 - No route to destination)
You want to make a call using out-fwd-785413 peer, but where You specify ip adress of Your provider (in [out-fwd-785413] ]?
did You read http://voip-info.org/wiki/view/Asterisk+config+sip.conf carefully earlier ?