4

the new asterisk versions (>13) use the PJSIP module instead of chan_sip. What I'm missing so far are practical examples how to use the PJSIP lib properly with asterisk.

What I want to do is the following:

  • I have two, three or more asterisk servers on different sites which are all connected by IP
  • end-devices like IP-phones are connected to the asterisk servers on the sides and they use PJSIP (Asterisk<==>IP-Phone works so far)
  • Now I want to connect all the asterisk servers with each other in order to build a communication network with a proper dialplan where every end-device can communicate with another phone on the other sites

like that: [end-device<==>Asterisk1<========>Asterisk2<==>end-device]

Up to now I only found tutorials how to do this with chan_sip or with IAX2, but not with PJSIP. There are also several tutorials availible that bind an asterisk server to an external provider, but thats not what I want to do.

Please help me, at least with a links to rich tutorials or information websites on that topic!

Thank you

Ovomaltine
  • 191
  • 1
  • 8

1 Answers1

3

After fighting with this for the better part of two days, Here is a config that works (at least in one direction (the phones on serverB are remote, so I can't easily test).

I hope it helps someone else avoid the pain I went through :-)

;
; ServerA - pjsip.conf
;

[siptrunk-auth]
type = auth
auth_type = userpass
username = <USER>
password = <ASTRONGPASSWORD>

[siptrunk-aor]
type = aor
contact = sip:serverB.domain.tld

[siptrunk]
type = endpoint
context = from-serverB
allow = !all,g722,ulaw
outbound_auth = siptrunk-auth
aors = siptrunk-aor
direct_media = no

[siptrunk-registration]
type = registration
outbound_auth = siptrunk-auth
server_uri = sip:serverB.domain.tld
client_uri = sip:<USER>@serverB.domain.tld
retry_interval = 60

[siptrunk-identify]
type = identify
match = serverB.domain.tld
endpoint = siptrunk

;
; ServerB - pjsip.conf
;
; <USER> is the same  <USER> as on Server A
;

[<USER>] ;
type = auth
auth_type = userpass
username = <USER>
password = <ASTRONGPASSWORD>

[<USER>]
type = aor
max_contacts = 1

[<USER>]
type = endpoint
context = from-ServerA
allow = !all,ulaw
direct_media = no
auth = <USER>
aors = <USER>

[<USER>]
type = identity
match = ServerA.domain.tld ; sometimes you might need to use the actual IP Address
endpoint = <USER>

;
; ServerA - extensions.conf
;

[to-serverB]
; route extensions starting with 6XXX to Server B
exten => _6XXX,1,Dial(PJSIP/${EXTEN}@siptrunk,,25)
  same => n,Hangup()

;
; ServerB - extensions.conf
;

[to-serverA]
; route extensions starting with 7XXX to Server A
exten => _7XXX,1,Dial(PJSIP/${EXTEN}@<USER>,,25)
  same => n,Hangup()
Neil Johnson
  • 151
  • 7