You are on page 1of 8

Tie your Asterisk boxes together

with the use of DUNDi

13XX

Server1
IP: 192.168.150.180
DUNDi Cloud
IAX

IA
X

Server2 Serve3

IP: 192.168.150.181 IAX IP: 192.168.150.182

16XX 10XX
Index
1 Introduction....................................................................................................................3
2 Server1........................................................................................................................3
2.1 dundi.conf..............................................................................................................4
2.2 extensions.conf......................................................................................................4
2.3 iax.conf.................................................................................................................5
3 Server2...........................................................................................................................5
3.1 dundi.conf..............................................................................................................5
3.2 extensionsm.conf...................................................................................................6
3.3 iax.conf...................................................................................................................6
4 Server3............................................................................................................................6
4.1 dundi.conf..............................................................................................................6
4.2 extensions.conf......................................................................................................7
4.3 iax.conf...................................................................................................................8
5 Generating Keys.............................................................................................................8
6 Troubleshooting..............................................................................................................8
1 Introduction
This is what I was trying to realize:
There are 3 Asterisk Servers with a few local extensions registered to them. 13XX for Server1, 16XX
for Server2, and 10XX for Server3.

What I am trying to achieve is that an extension say 1301 can call an extension 1601 that is
registered to another Asterisk. I read about DUNDi and thought this was the most elegant way to
accomplish this.

13XX

Server1
IP: 192.168.150.180

DUNDi Cloud
IAX

IA
X

Server2
IP: 192.168.150.181 Server3
IP: 192.168.150.182
IAX

16XX 10XX

2 Server1
Make sure you have these lines in the following files. I was working with a clean install of Asterisk
so this just can’t go wrong….
2.1 dundi.conf
[general]

port=4520
entityid=00:0C:29:0C:AB:C2 ; This is the mac address of eth0
cachetime=5
ttl=32
autokill=yes

[mappings]

priv => dundi-local


,0,IAX2,priv:password@192.168.150.180/${NUMBER},nounsolicited,nocomunsolicit,nopartial

[00:0C:29:30:77:FA] ; MAC address of Server2 eth0


model = symmetric
host = 192.168.150.181
inkey = dundi
outkey = dundi
include = priv
permit = priv
qualify = yes
dynamic=yes

[00:50:BF:A6:C3:C4] ; MAC address of Server3 eth0


model = symmetric
host = 192.168.150.182
inkey = dundi
outkey = dundi
include = priv
permit = priv
qualify = yes
dynamic=yes

2.2 extensions.conf

[macro-dundi-lookup]
; Goto the extension number. Check the local context first, followed by lookup
; dundi-priv-lookup is a pointer to the switch statement which will look for
; extensions on other machines. This allows the convergence of multiple
; Asterisk servers with different extension number blocks. Very cool!
;
exten => s,1,Goto(${ARG1},1)
include => dundi-local
include => dundi-priv-lookup

[dundi-pstn-local-custom]

[dundi-local]
; we only have extensions 1300 -> 1399 locally
exten => _13XX,1,Macro(dial,${EXTEN})

[dundi-priv-lookup]
; Check our private peers for the exten #. Search 'priv' dundi context
switch => DUNDi/priv

[dundi-priv-incoming]
; when we get an incoming call from a private peer, it gets directed here
include => dundi-local
;------------------------------------------------------------------------------
; Outgoing Calls Contexts
;------------------------------------------------------------------------------

[local]
; For extensions starting with 1000 -> 1099 and 1600 -> 1699 do a dundi-lookup (private
extens)
exten => _1[06]XX,1,Macro(dundi-lookup,${EXTEN})

[from-internal]
include => local

2.3 iax.conf
[priv]
type=user
context=from-internal
disallow=all
allow=ulaw
allow=alaw
allow=gsm

3 Server2
3.1 dundi.conf
[general]
port=4520
entityid=00:0C:29:30:77:FA ; MAC address of Server2 eth0
cachetime=5
ttl=32
autokill=yes

[mappings]
priv => dundi-local
,0,IAX2,priv:password@192.168.150.181/${NUMBER},nounsolicited,nocomunsolicit,nopartial

[00:0C:29:0C:AB:C2] ; MAC address of Server1 eth0


model = symmetric
host = 192.168.150.180
inkey = dundi
outkey = dundi
include = priv
permit = priv
qualify = yes
dynamic=yes

[00:50:BF:A6:C3:C4] ; MAC address of Server3 eth0


model = symmetric
host = 192.168.150.182
inkey = dundi
outkey = dundi
include = priv
permit = priv
qualify = yes
dynamic=yes
3.2 extensions.conf

[macro-dundi-lookup]
; Goto the extension number. Check the local context first, followed by lookup
; dundi-priv-lookup is a pointer to the switch statement which will look for
; extensions on other machines. This allows the convergence of multiple
; Asterisk servers with different extension number blocks. Very cool!
;
exten => s,1,Goto(${ARG1},1)
include => dundi-local
include => dundi-lookup

[dundi-local]
; we only have extensions 1600 -> 1699 locally
exten => _16XX,1,Macro(dial,${EXTEN})

[dundi-lookup]
; Check our private peers for the exten #. Search 'priv' dundi context
switch => DUNDi/priv

[dundi-priv-incoming]
; when we get an incoming call from a private peer, it gets directed here
include => dundi-local

;------------------------------------------------------------------------------
; Outgoing Calls Contexts
;------------------------------------------------------------------------------
[local]
; For extensions starting with 1000 -> 1099 and 1300 -> 1399 do a dundi-lookup (private
extens)
exten => _1[03]XX,1,Macro(dundi-lookup-custom,${EXTEN})

[from-internal]

include => local

3.3 iax.conf
[priv]
type=user
context=from-internal
disallow=all
allow=ulaw
allow=alaw
allow=gsm

4 Server3
4.1 dundi.conf
[general]
port=4520
entityid=00:50:BF:A6:C3:C4 ; MAC address of Server3 eth0
cachetime=5
ttl=32
autokill=yes
[mappings]
priv => dundi-local
,0,IAX2,priv:password@192.168.150.182/${NUMBER},nounsolicited,nocomunsolicit,nopartial

[00:0C:29:0C:AB:C2] ; MAC address of Server1 eth0


model = symmetric
host = 192.168.150.180
inkey = dundi
outkey = dundi
include = priv
permit = priv
qualify = yes
dynamic=yes

[00:0C:29:30:77:FA] ; MAC address of Server2 eth0


model = symmetric
host = 192.168.150.181
inkey = dundi
outkey = dundi
include = priv
permit = priv
qualify = yes
dynamic=yes

4.2 extensions.conf

[macro-dundi-lookup]
; Goto the extension number. Check the local context first, followed by lookup
; dundi-priv-lookup is a pointer to the switch statement which will look for
; extensions on other machines. This allows the convergence of multiple
; Asterisk servers with different extension number blocks. Very cool!
;
exten => s,1,Goto(${ARG1},1)
include => dundi-local
include => dundi-lookup

[dundi-local]
; we only have extensions 1000 -> 1099 locally
exten => _10XX,1,Macro(dial,${EXTEN})

[dundi-lookup]
; Check our private peers for the exten #. Search 'priv' dundi context
switch => DUNDi/priv

[dundi-priv-incoming]
; when we get an incoming call from a private peer, it gets directed here
include => dundi-local

;------------------------------------------------------------------------------
; Outgoing Calls Contexts
;------------------------------------------------------------------------------
[local]
; For extensions starting with 1300 -> 1399 and 1600 -> 1699 do a dundi-lookup (private
extens)
exten => _1[36]XX,1,Macro(dundi-lookup,${EXTEN})

[from-internal]

include => local


4.3 iax_custom.conf
[priv]
type=user
context=from-internal
disallow=all
allow=ulaw
allow=alaw
allow=gsm

5 Generating Keys
On one of the boxes generate the keys and distribute them among the Asterisks.

# cd /var/lib/asterisk/keys
# astgenkey –n dundi

dundi.key and dundi.pub are now generated and need to be copied to the other two Asterisk Servers. I
know this is not the most secure way but hey it’s just me playing at home ;)

After creating the keys you must reload the res_crypto.so and pbx_dundi.so modules.

Server1*CLI> reload res_crypto.so


Server1*CLI> reload pbx_dundi.so

That’s it! You should now be able to call all the extensions you “advertised”.

6 Troubleshooting
I did quite some troubleshooting and these commands came in handy:

Server1*CLI> dundi show peers


EID Host Model AvgTime Status
00:50:bf:a6:c3:c4 192.168.1.10 (S) Symmetric Unavail OK (1 ms)
00:0c:29:30:77:fa 192.168.1.16 (S) Symmetric Unavail OK (1 ms)
2 dundi peers [2 online, 0 offline, 0 unmonitored]

Server1*CLI> dundi lookup 1601@priv


1. 0 IAX2/priv:password@192.168.150.181/1601 (EXISTS|NOUNSLCTD|NOCOMUNSLTD)
from 00:0c:29:30:77:fa, expires in 5 s
DUNDi lookup completed in 35 ms

Note that a DUNDi lookup for a local extensions doesn’t return anything.

Server1*CLI> dundi debug

Server1*CLI> iax2 debug

This is where I noticed that something went wrong with the IAX authentication so I totally
dropped the authentication issue and went on.

You might also like