Trunk PJSIP entre deux serveurs Asterisk : SRV-A ↔ SRV-B
Trunk PJSIP entre deux serveurs Asterisk
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.
/image%2F7223427%2F20260412%2Fob_547e0b_chatgpt-image-12-avr-2026-05-01-20.png)
- 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.
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
/image%2F7223427%2F20260412%2Fob_797624_capture-1.png)
# 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()
/image%2F7223427%2F20260412%2Fob_fd23a6_capture-2.png)
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
/image%2F7223427%2F20260412%2Fob_740b5b_capture-3.png)
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()
/image%2F7223427%2F20260412%2Fob_dc796c_capture-7-cisvb.png)
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
...
/image%2F7223427%2F20260412%2Fob_b9f543_capture-8-utilisateur.png)
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
/image%2F7223427%2F20260412%2Fob_416460_capture-5.png)
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
/image%2F7223427%2F20260412%2Fob_a70c5c_capture-6.png)
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...).
/image%2F7223427%2F20260412%2Fob_ebfb15_capture-9.png)
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.
/image%2F7223427%2F20260412%2Fob_7175ff_capture-10.png)
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.
/image%2F7223427%2F20260412%2Fob_c03066_capture-11.png)
/image%2F7223427%2F20260412%2Fob_6b5adf_whatsapp-image-2026-04-12-at-05-09-35.jpeg)
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=identifypour 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=yesetforce_rport=yespour la compatibilité NAT
Cette configuration est idéale pour les architectures distribuées, les redondances géographiques ou les interconnexions entre filiales.
test