Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU
Aquila Networks : Sécurité & Réseaux Étudiant en Master SSI à l'ESMT

Trunk PJSIP entre deux serveurs Asterisk : SRV-A ↔ SRV-B

El Hadji Diakhate

 

Trunk PJSIP entre deux serveurs Asterisk

 


Introduction

La mise en place d'un trunk PJSIP entre deux serveurs Asterisk permet d'interconnecter deux systèmes de téléphonie VoIP afin de faire transiter des appels entre eux. Cela peut servir pour étendre un réseau d'entreprise, créer des relais géographiques ou segmenter des services.


Architecture
  • SRV-A (SRV-1) : 192.168.1.191
  • SRV-B (SRV-2) : 192.168.1.192

Chaque serveur utilise le protocole PJSIP pour définir un trunk bidirectionnel.


1. Configuration du serveur SRV-A (pjsip.conf)

# vim /etc/asterisk/pjsip.conf

Appels sortants vers SRV-B :

[trunk-to-b]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
aors=trunk-to-b
auth=trunk-to-b_auth
outbound_auth=trunk-to-b_auth
rewrite_contact=yes
force_rport=yes
rtp_symmetric=yes

[trunk-to-b]
type=aor
contact=sip:192.168.1.192

[trunk-to-b_auth]
type=auth
auth_type=userpass
username=asterisk-a
password=passer

Appels entrants depuis SRV-B :

[trunk-from-b]
type=endpoint
context=from-trunk-b
disallow=all
allow=ulaw
aors=trunk-from-b
auth=trunk-from-b_auth
identify_by=ip

[trunk-from-b]
type=aor
contact=sip:192.168.1.192

[trunk-from-b_auth]
type=auth
auth_type=userpass
username=asterisk-a
password=passer

[trunk-from-b-identify]
type=identify
endpoint=trunk-from-b
match=192.168.1.192

 


2. Extensions.conf SRV-A

# vim /etc/asterisk/extensions.conf

[from-internal]
exten => _2XXX,1,NoOp(Appel de A vers B)
 same => n,Dial(PJSIP/${EXTEN}@trunk-to-b)
 same => n,Hangup()

exten => _1XXX,1,NoOp(Appel interne)
 same => n,Dial(PJSIP/${EXTEN})
 same => n,Hangup()

[from-trunk-b]
exten => _1XXX,1,NoOp(Appel reçu de Serveur B vers A)
 same => n,Dial(PJSIP/${EXTEN},20)
 same => n,Hangup()

 


3. Configuration du serveur SRV-B (pjsip.conf)

# vim /etc/asterisk/pjsip.conf

Appels entrants depuis SRV-A :

[trunk-from-a]
type=endpoint
context=from-trunk-a
disallow=all
allow=ulaw
aors=trunk-from-a
auth=trunk-from-a_auth
identify_by=ip

[trunk-from-a]
type=aor
contact=sip:192.168.1.191

[trunk-from-a_auth]
type=auth
auth_type=userpass
username=asterisk-a
password=passer

[trunk-from-a-identify]
type=identify
endpoint=trunk-from-a
match=192.168.1.191

 

Extensions.conf SRV-B :

# vim /etc/asterisk/extensions.conf

[from-internal]
exten => 2000,1,Dial(PJSIP/2000)
exten => 2001,1,Dial(PJSIP/2001)
exten => _2XXX,1,Dial(PJSIP/${EXTEN})
exten => _1XXX,1,NoOp(Appel de B vers A)
 same => n,Dial(PJSIP/${EXTEN}@trunk-to-a)
 same => n,Hangup()
exten => 5081,1,Goto(ivr-esmt,s,1)
exten => _X.,1,NoOp(Appel sortant GSM : ${EXTEN})
 same => n,Dial(PJSIP/${EXTEN}@goip)
 same => n,Hangup()

[from-trunk-a]
exten => _2XXX,1,NoOp(Appel reçu de Serveur A vers B)
 same => n,Dial(PJSIP/${EXTEN},20)
 same => n,Hangup()

 


4. Configuration des postes SIP sur SRV-B (pjsip.conf

# vim /etc/asterisk/pjsip.conf

voir configuration ici

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060

[2000]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
auth=2000
aors=2000

[2001]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
auth=2001
aors=2001

[2000]
type=aor
max_contacts=1
remove_existing=yes

[2001]
type=aor
...

 


5. Vérification des trunks

Sur SRV-A — pjsip show endpoints :

>pjsip show endpoints

Endpoint:  trunk-from-b                          Not in use   0 of inf
  InAuth:  trunk-from-b_auth/asterisk-a
    Aor:   trunk-from-b                          0
  Contact: trunk-from-b/sip:192.168.1.192        80b5a834cb NonQual   nan
 Identify: trunk-from-b-identify/trunk-from-b
    Match: 192.168.1.192/32

Endpoint:  trunk-to-b                            Not in use   0 of inf
  OutAuth: trunk-to-b_auth/asterisk-a
   InAuth: trunk-to-b_auth/asterisk-a
     Aor:  trunk-to-b                            0
  Contact: trunk-to-b/sip:192.168.1.192          80b5a834cb NonQual   nan

 

Sur SRV-B — pjsip show endpoints :

>pjsip show endpoints

Endpoint:  trunk-from-a                          Not in use   0 of inf
  InAuth:  trunk-from-a_auth/asterisk-a
    Aor:   trunk-from-a                          0
  Contact: trunk-from-a/sip:192.168.1.191        107f2783a7 NonQual   nan
 Identify: trunk-from-a-identify/trunk-from-a
    Match: 192.168.1.191/32

Endpoint:  trunk-to-a                            Not in use   0 of inf
  OutAuth: trunk-to-a_auth/asterisk-a
   InAuth: trunk-to-a_auth/asterisk-a
     Aor:  trunk-to-a                            0
  Contact: trunk-to-a/sip:192.168.1.191          107f2783a7 NonQual   nan
Objects found: 5

 


6. Tests d'appels

Test de B vers A — Extension 2000 (SRV-B, Zoiper) appelle 1000 (SRV-A, MicroSIP) :

MicroSIP sur SRV-A affiche l'appel entrant de 2001 depuis 2000@192.168.1.192. La console Asterisk confirme le routage via from-trunk-a puis le Dial(PJSIP/trunk-from-a...).

 

Test de A vers B — Extension 1000 (SRV-A, MicroSIP) appelle 2000 (SRV-B, Zoiper) :

Zoiper sur SRV-B reçoit l'appel de 1000 depuis 1000@192.168.1.191 (DNID: 2000). MicroSIP sur SRV-A montre l'appel sortant vers 2000 en cours.

 

Console Asterisk SRV-B — Logs des appels reçus depuis SRV-A :

On voit les lignes Appel reçu de Serveur A vers B, Dial(PJSIP/2000,20), PJSIP/2000-XXXXXXXX is ringing. L'extension 1001 sur Zoiper reçoit l'appel de 2000@192.168.1.192.

 

 


Conclusion

Un trunk SIP entre deux serveurs Asterisk permet une communication fluide entre deux systèmes téléphoniques distants. Les points clés de cette configuration sont :

  • Utiliser des sections type=identify pour router les appels par IP sans authentification SIP entrante
  • Définir des contextes dédiés (from-trunk-a, from-trunk-b) pour séparer le trafic inter-serveurs du trafic interne
  • Activer rtp_symmetric=yes et force_rport=yes pour la compatibilité NAT

Cette configuration est idéale pour les architectures distribuées, les redondances géographiques ou les interconnexions entre filiales.

 

test

Pour être informé des derniers articles, inscrivez vous :
Commentaires