В настройках dundi.conf следует иметь ввиду, что строки в mappings, это то что будет передаваться на удаленный dundi peer и именно на этом удаленном пире должны быть нужные настройки (например, context RegisteredDevices и SIP trunk dundi_to_asterisk1)
extensions => RegisteredDevices,0,SIP,dundi_to_asterisk1/${NUMBER},nopartial
Теперь перейдем к context'ам. Я использую конструкцию вида.
Если есть данные в dundi, то берем их. Если нет, то звоним на локальный астериск.
exten => 958898,1,Dial(${IF($[${LEN(${DUNDILOOKUP(1001,extensions,b)})}>0]?${DUNDILOOKUP(1001,extensions,b)}:"SIP/1001")},30)
exten => 1001,1,Dial(${IF($[${LEN(${DUNDILOOKUP(1001,extensions,b)})}>0]?${DUNDILOOKUP(1001,extensions,b)}:"SIP/1001")},30)
для получения направления звонка используется функция DUNDILOOKUP(1001,extensions,b)
она ищет экстеншен 1001 в маппинге extensions dundi.conf. Возвращает SIP/dundi_to_asterisk2
Это прямой аналог команды
aster1*CLI> dundi lookup 1000@extensions
1. 0 SIP/dundi_to_asterisk2/1000 (EXISTS)
from 00:0c:29:de:70:6d, expires in 5 s
DUNDi lookup completed in 64 ms
Если экстеншен зарегистрирован на нескольких астерисках, то dundi lookup вернет несколько значений. Передаст при этом он только первое. Вполне так можно использовать для резервирования :)
aster2*CLI> dundi lookup 1001@extensions
1. 0 SIP/dundi_to_asterisk1/1001 (EXISTS)
from 00:0c:29:c5:d6:e4, expires in 5 s
2. 0 SIP/dundi_to_asterisk4/1001 (EXISTS)
from 00:0c:29:8a:a9:f1, expires in 5 s
DUNDi lookup completed in 89 ms
Вообщем то с этого момента можно плодить астериски с данди. Остальные настройки уже распространяются на диалплан и специфичны для конкретных конфигураций.
Пример моей тестовой конфигурации состоящей из трех астерисков:
aster1:
sip.conf
[general]
context=poumolchaniu
srvlookup=no
disallow=all
allow=ulaw
allow=g729
allow=ilbc
language=ru
trustrpid=yes
sendrpid=yes
registertimeout=20
registerattempts=10
t38pt_udptl=no
allow=h263
videosupport=yes
autocreatepeer=no
minexpiry=60
maxexpirey=3600
rtsavesysname=yes
rtptimeout=60
rtpholdtimeout=300
dtmfmode=auto
directrtpsetup=no
canreinvite=no
sdpsession=Aster1 Server
#include sipuserss.conf
#include sipgw.conf
#include siptrunk.conf
alwaysauthreject=yes
videosupport=yes
defaultexpiry=3600
regcontext=RegisteredDevices
;workaround for asteriks crash
session-timers = refuse
sipgw.conf
[dundi_to_asterisk2]
host=192.168.3.53
type=peer
secret=secret
context=local
disallow=all
allow=ulaw
allow=alaw
qualify=yes
canreinvite=no
nat=yes
defaultuser=dundi_to_asterisk1
[dundi_to_asterisk4]
host=192.168.3.56
type=peer
secret=secret
context=local
disallow=all
allow=ulaw
allow=alaw
qualify=yes
canreinvite=no
nat=yes
defaultuser=dundi_to_asterisk1
sipusers.conf
[1000]
type=friend
accountcode=outgoing
host=dynamic
qualify=yes
callerid=""<958877>
language=ru
username=1000
disallow=all
allow=gsm
allow=g729
allow=ulaw
allow=h263
context=tolkogorod+zona+mezhgorod+mezhdunarodka
nat=yes
busylevel=2
call-limit=1
dtmfmode = rfc2833
[1001]
type=friend
accountcode=outgoing
host=dynamic
qualify=yes
callerid=""<958898>
language=ru
username=1001
disallow=all
allow=gsm
allow=g729
allow=ulaw
allow=h263
context=tolkogorod+zona+mezhgorod+mezhdunarodka
nat=yes
busylevel=2
call-limit=1
dtmfmode = rfc2833
dundi.conf
[general]
department=Your Department
organization=Your Company, Inc.
locality=Your City
stateprov=ST
country=US
email=your@email.com
phone=+12565551212
bindaddr=192.168.3.52
port=4520
entityid=00:0c:29:c5:d6:e4
cachetime=5
ttl=2
autokill=yes
[mappings]
extensions => RegisteredDevices,0,SIP,dundi_to_asterisk1/${NUMBER},nopartial
[00:0c:29:de:70:6d] ; MAC Address of Asterisk2
model = symmetric
host = 192.168.3.53;(this is the IP address of the DUNDi Asterisk2)
inkey = aster1
outkey = aster2
include = extensions
permit = extensions
qualify = yes
order = primary
[00:0c:29:8a:a9:f1] ; MAC Address of Asterisk4
model = symmetric
host = 192.168.3.56;(this is the IP address of the DUNDi Asterisk4)
inkey = aster1
outkey = aster4
include = extensions
permit = extensions
qualify = yes
order = primary
extensions.conf
[RegisteredDevices]
[tolkogorod+zona+mezhgorod+mezhdunarodka]
Include => local
Include => CallerIDoutCiscofon
Include => specslugbi
Include => gorod
Include => zona
Include => mezhgorod
Include => mezhdunarodka
[local]
#include extensionslookup.conf
extensionslookup.conf
exten => 958877,1,Dial(${IF($[${LEN(${DUNDILOOKUP(1000,extensions,b)})}>0]?${DUNDILOOKUP(1000,extensions,b)}:"SIP/1000")},30)
exten => 958898,1,Dial(${IF($[${LEN(${DUNDILOOKUP(1001,extensions,b)})}>0]?${DUNDILOOKUP(1001,extensions,b)}:"SIP/1001")},30)
exten => 1000,1,Dial(${IF($[${LEN(${DUNDILOOKUP(1000,extensions,b)})}>0]?${DUNDILOOKUP(1000,extensions,b)}:"SIP/1000")},30)
exten => 1001,1,Dial(${IF($[${LEN(${DUNDILOOKUP(1001,extensions,b)})}>0]?${DUNDILOOKUP(1001,extensions,b)}:"SIP/1001")},30)
aster2
sip.conf
[general]
srvlookup=no
NAT=yes
bindport=5060
allowguest=no
canreinvite=no
regcontext=RegisteredDevices
[1000]
type=friend
context=LocalSets
host=dynamic
disallow=all
allow=gsm
canreinvite=no
qualify=yes
defaultuser=1000
fromuser=1000
callerid=""<958877>
[dundi_to_asterisk1]
host=192.168.3.52
type=peer
secret=secret
context=LocalSets
disallow=all
allow=ulaw
allow=alaw
qualify=yes
defaultuser=dundi_to_asterisk2
dundi.conf
[general]
department=Your Department
organization=Your Company, Inc.
locality=Your City
stateprov=ST
country=US
email=your@email.com
phone=+12565551212
bindaddr=192.168.3.53
port=4520
entityid=00:0c:29:de:70:6d
cachetime=5
ttl=2
autokill=yes
[mappings]
extensions => RegisteredDevices,0,SIP,dundi_to_asterisk2/${NUMBER},nopartial
[00:0c:29:c5:d6:e4] ; MAC Address of Asterisk1
model = symmetric
host = 192.168.3.52;(this is the IP address of the DUNDi Asterisk1)
inkey = aster2
outkey = aster1
include = extensions
permit = extensions
qualify = yes
order = primary
extensions.conf
[general]
static=yes
writeprotect=no
autofallthrough=no
clearglobalvars=no
priorityjumping=no
[RegisteredDevices]
;exten => 1000,1,NoOp()
[lookup]
exten => 958877,1,Dial(${IF($[${LEN(${DUNDILOOKUP(1000,extensions,b)})}>0]?${DUNDILOOKUP(1000,extensions,b)}:"SIP/1000")},30)
exten => 958898,1,Dial(${IF($[${LEN(${DUNDILOOKUP(1001,extensions,b)})}>0]?${DUNDILOOKUP(1001,extensions,b)}:"SIP/1001")},30)
exten => 1000,1,Dial(${IF($[${LEN(${DUNDILOOKUP(1000,extensions,b)})}>0]?${DUNDILOOKUP(1000,extensions,b)}:"SIP/1000")},30)
exten => 1001,1,Dial(${IF($[${LEN(${DUNDILOOKUP(1001,extensions,b)})}>0]?${DUNDILOOKUP(1001,extensions,b)}:"SIP/1001")},30)
[LocalSets]
include => lookup
aster4
sip.conf
[general]
srvlookup=no
NAT=yes
bindport=5060
allowguest=no
canreinvite=no
regcontext=RegisteredDevices
[1002]
type=friend
context=LocalSets
host=dynamic
disallow=all
allow=gsm
canreinvite=no
qualify=yes
defaultuser=1002
fromuser=1002
callerid=""<958877>
[dundi_to_asterisk1]
host=192.168.3.52
type=peer
secret=secret
context=DUNDi_Incoming
disallow=all
allow=ulaw
allow=alaw
qualify=yes
defaultuser=dundi_to_asterisk4
dundi.conf
[general]
department=Your Department
organization=Your Company, Inc.
locality=Your City
stateprov=ST
country=US
email=your@email.com
phone=+12565551212
bindaddr=192.168.3.56
port=4520
entityid=00:0c:29:8a:a9:f1
cachetime=5
ttl=2
autokill=yes
[mappings]
extensions => RegisteredDevices,0,SIP,dundi_to_asterisk4/${NUMBER},nopartial
[00:0c:29:c5:d6:e4] ; MAC Address of Asterisk1
model = symmetric
host = 192.168.3.52;(this is the IP address of the DUNDi Asterisk1)
inkey = aster4
outkey = aster1
include = extensions
permit = extensions
qualify = yes
order = primary
extensions.conf
[general]
static=yes
writeprotect=no
autofallthrough=no
clearglobalvars=no
priorityjumping=no
[RegisteredDevices]
[DUNDi_Incoming]
exten => 1002,1,Dial(${IF($[${LEN(${DUNDILOOKUP(1002,extensions,b)})}>0]?${DUNDILOOKUP(1002,extensions,b)}:"SIP/1002")},30)