[asterisk-users] UA - number assignment
Brian Candler
B.Candler at pobox.com
Wed Oct 25 03:36:08 MST 2006
On Wed, Oct 25, 2006 at 11:11:00AM +0300, Paul Ianas wrote:
> Indeed, this is what I want to know. When somebody wants to make a call
> (using a standard telephone, connected to a media gateway), he doesn't
> know what user is in my Asterisk conf. He only knows that he wants to
> call John, who has the number 102 for example. He dials 102 from his
> phone and the call is routed to the corresponding user (this is
> Asterisk's job).
Which is controlled by the "dial plan" in extensions.conf
> I want to know only the way I can make an UA-number assignment.
Well, the simplest way is to put a new line in extensions.conf for each
phone number: at minimum, this might look like
exten => 101,1,Dial(SIP/john)
exten => 102,1,Dial(SIP/fred)
... etc
However it gets long-winded if you have multiple extensions which all want
the same logic (e.g. forward on no answer to voicemail)
Personally I use macros and sub-contexts to clean this up. An example is
shown below. Each new local user you add just needs a single entry under the
[extensions] section, plus an entry in their specific channel (e.g.
sip.conf). This is reasonably easy to manage.
HTH,
Brian.
----------------- extensions.conf ------------------
; This is the macro for placing a call to a user
[macro-ext]
exten => s,1,Dial(${ARG1},15)
exten => s,2,Playback(vm-nobodyavail)
exten => s,3,Hangup()
exten => s,102,Playback(tt-allbusy)
exten => s,103,Hangup()
; These are mappings of internal extension numbers to destinations
[extensions]
exten => 101,1,Macro(ext,Zap/1)
exten => 102,1,Macro(ext,Zap/2)
exten => 301,1,Macro(ext,SIP/john)
exten => 401,1,Macro(ext,SIP/tulip1)
exten => 402,1,Macro(ext,SIP/tulip2)
; This allows outgoing calls (prefixed with 9) via the Zaptel FXO port
[outbound]
exten => _9.,1,Dial(Zap/4/${EXTEN:1})
exten => _9.,2,Congestion()
exten => _9.,102,Congestion()
; This matches anything else, i.e. invalid numbers
[invalid]
exten => _X!,1,Answer()
exten => _X!,2,Background(pbx-invalid)
; Now you create a context for each class of user, and include whichever
; sub-contexts are permitted for those users. They are tried in sequence.
; Registered SIP clients go in this context - they can place PSTN calls
[from-sip]
include => extensions
include => outbound
include => invalid
; Directly-connected phones on FXS ports
[internal]
include => extensions
include => outbound
include => invalid
; Incoming SIP calls from arbitary hosts on the Internet
[default]
include => extensions
include => invalid
; incoming calls on the FXO port are directed to this context
; from zapata.conf
[incoming]
include => extensions
exten => s,1,Answer()
exten => s,2,Wait(1)
exten => s,3,Background(enter-ext-of-person)
exten => i,1,Background(pbx-invalid)
exten => t,1,Playback(vm-goodbye)
exten => t,2,Hangup()
; Note that people dialling into our system are NOT allowed to access
; the 'outbound' context and place toll calls back out again!
---------------------------------------------------------------
Because the call handling logic is in a macro, if you decide to change it -
e.g. you find that 15 seconds of ringing is too short, and you want to make
it 30 seconds - you only have to do this in one place:
exten => s,1,Dial(${ARG1},30)
and it applies to all users.
Finally, you need to put each device in the correct context.
------------ sip.conf ------------
[general]
context=default ; <<< NOTE
[john]
type=friend
secret=XXXXXX
context=from-sip ; <<< NOTE
callerid=John Smith <301>
nat=no
canreinvite=yes
host=dynamic
;...etc
------------ zapata.conf -----------
; Zap/1=FXS, Zap/2=FXS, Zap/3=not installed, Zap/4=FXO
[channels]
usecallerid=yes
hidecallerid=no
callwaiting=no
threewaycalling=yes
transfer=yes
echocancel=yes
echotraining=yes
immediate=no
context=internal ; <<< NOTE
signalling=fxo_ls
txgain=-6.0
callerid="Red Phone" <101>
channel => 1
context=internal ; <<< NOTE
signalling=fxo_ls
txgain=-6.0
callerid="Blue Phone" <102>
channel => 2
context=incoming ; <<< NOTE
signalling=fxs_ls
channel => 4
More information about the asterisk-users
mailing list