SIP user and IAX Trunk

Hi, I’m new working with asterisk…

I have 2 virtual machines with CentOS and Asterisk, I have to configure 2 SIP users in each PBX.
At that point I’m Ok… Now the problem is that i have to connect those two PBX with an IAX trunk.

I did a SIP trunk and it works but i dont know how to do it to work with IAX.

Sorry for my bad english.

Here is the configuration

PBX1

sip.conf

[201]
secret=123456
type=friend
host=dynamic
context=extensiones

[202]
secret=123456
type=friend
host=dynamic
context=extensiones

extensions.conf

[extensiones]
exten =>_2xx,2,Dial(SIP/${EXTEN})
exten =>_2xx,3,Hangup()
exten =>_2xx,1,PlayBack(hello-world)
include => pbx2

[pbx2]
exten =>_3xx,1,Set(CALLERID(num)=PBX1${CALLERID(num)})
exten =>_3xx,2,Dial(IAX2/troncal/${EXTEN},15,rt)
include => extensiones

iax,conf

[troncal]
type=friend
qualify=yes
host=192.168.242.143
trunk=yes
disallow=all
allow=ulaw
allow=alaw
allow=g729
context=pbx2

PBX2

sip.conf

[301]
secret=123456
type=friend
host=dynamic
context=extensiones

[302]
secret=123456
type=friend
host=dynamic
context=extensiones

extensions.conf

[extensiones]
exten =>_3xx,2,Dial(SIP/${EXTEN})
exten =>_3xx,3,Hangup()
exten =>_3xx,1,Playback(hello-world)
include => pbx1

[pbx1]
exten =>_2xx,1,Set(CALLERID(num)=PBX2${CALLERID(num)})
exten =>_2xx,2,Dial(IAX2/troncal/${EXTEN},15,rt)
include => extensiones

iax.conf

[troncal]
type=friend
qualify=yes
trunk=yes
host=192.168.242.142
disallow=all
allow=ulaw
allow=alaw
allow=g729
context=pbx1

Without any logs to me it looks like the problem is likely the context your IAX accounts are using.

If you call from PBX1 to PBX2 the call ends up in the context ‘pbx1’ on pbx2 where it will not match the extension dialed by PBX1.

Sorry, here is the log

from pbx1 to pbx2

Connected to Asterisk certified/13.8-cert2 currently running on localhost (pid = 7783)
== Using SIP RTP CoS mark 5
– Executing [302@extensiones:1] Set(“SIP/202-00000042”, “CALLERID(num)=PBX1202”) in new stack
– Executing [302@extensiones:2] Dial(“SIP/202-00000042”, “IAX2/troncal/302,15,rt”) in new stack
– Called IAX2/troncal/302
– Hungup ‘IAX2/troncal-32352’
== Everyone is busy/congested at this time (1:0/0/1)
– Auto fallthrough, channel ‘SIP/202-00000042’ status is ‘CHANUNAVAIL’

what do the logs show on the other PBX that is receiving the call?

It shows nothing. But let me do you a question, the extensions.conf file is it ok?

Turn on IAX debugging and try your cal again.

I see no obvious fault with your extensions.conf

<— SIP read from UDP:192.168.242.1:33658 —>
SUBSCRIBE sip:301@192.168.242.143;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 190.166.50.142:33658;branch=z9hG4bK-524287-1—b0214fb51c75dc57
Max-Forwards: 70
Contact: sip:301@190.166.50.142:33658;transport=UDP
To: sip:301@192.168.242.143;transport=UDP
From: sip:301@192.168.242.143;transport=UDP;tag=d337c94f
Call-ID: C4h3IO0RtXo7WMJ8VVsC5Q…
CSeq: 1 SUBSCRIBE
Expires: 600
Accept: application/watcherinfo+xml
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Z 3.9.32144 r32121
Event: presence.winfo
Allow-Events: presence, kpml
Content-Length: 0

<------------->
— (16 headers 0 lines) —
Sending to 192.168.242.1:33658 (NAT)
Creating new subscription
Sending to 192.168.242.1:33658 (NAT)
sip_route_dump: route/path hop: sip:301@190.166.50.142:33658;transport=UDP
Found peer ‘301’ for ‘301’ from 192.168.242.1:33658

<— Transmitting (NAT) to 192.168.242.1:33658 —>
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 190.166.50.142:33658;branch=z9hG4bK-524287-1—b0214fb51c75dc57;received=192.168.242.1;rport=33658
From: sip:301@192.168.242.143;transport=UDP;tag=d337c94f
To: sip:301@192.168.242.143;transport=UDP;tag=as42c1a6df
Call-ID: C4h3IO0RtXo7WMJ8VVsC5Q…
CSeq: 1 SUBSCRIBE
Server: Asterisk PBX certified/13.8-cert2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce="06545972"
Content-Length: 0

<------------>
Scheduling destruction of SIP dialog ‘C4h3IO0RtXo7WMJ8VVsC5Q…’ in 32000 ms (Method: SUBSCRIBE)
Really destroying SIP dialog ‘mByuko5sMlViFT64vXnM0w…’ Method: PUBLISH

<— SIP read from UDP:192.168.242.1:33658 —>
SUBSCRIBE sip:301@192.168.242.143;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 190.166.50.142:33658;branch=z9hG4bK-524287-1—c474054e49a9db95
Max-Forwards: 70
Contact: sip:301@190.166.50.142:33658;transport=UDP
To: sip:301@192.168.242.143;transport=UDP
From: sip:301@192.168.242.143;transport=UDP;tag=d337c94f
Call-ID: C4h3IO0RtXo7WMJ8VVsC5Q…
CSeq: 2 SUBSCRIBE
Expires: 600
Accept: application/watcherinfo+xml
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Z 3.9.32144 r32121
Authorization: Digest username=“301”,realm=“asterisk”,nonce=“06545972”,uri="sip:301@192.168.242.143;transport=UDP",response=“77e732c446e1a463af14c1e303391a47”,algorithm=MD5
Event: presence.winfo
Allow-Events: presence, kpml
Content-Length: 0

<------------->
— (17 headers 0 lines) —
Creating new subscription
Sending to 192.168.242.1:33658 (NAT)
Found peer ‘301’ for ‘301’ from 192.168.242.1:33658

<— Transmitting (NAT) to 192.168.242.1:33658 —>
SIP/2.0 489 Bad Event
Via: SIP/2.0/UDP 190.166.50.142:33658;branch=z9hG4bK-524287-1—c474054e49a9db95;received=192.168.242.1;rport=33658
From: sip:301@192.168.242.143;transport=UDP;tag=d337c94f
To: sip:301@192.168.242.143;transport=UDP;tag=as42c1a6df
Call-ID: C4h3IO0RtXo7WMJ8VVsC5Q…
CSeq: 2 SUBSCRIBE
Server: Asterisk PBX certified/13.8-cert2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0

<------------>
Really destroying SIP dialog ‘C4h3IO0RtXo7WMJ8VVsC5Q…’ Method: SUBSCRIBE
Rx-Frame Retry[ No] – OSeqno: 000 ISeqno: 000 Type: IAX Subclass: POKE
Timestamp: 00004ms SCall: 02418 DCall: 00000 192.168.242.142:4569

Tx-Frame Retry[ No] – OSeqno: 000 ISeqno: 001 Type: IAX Subclass: PONG
Timestamp: 00004ms SCall: 00001 DCall: 02418 192.168.242.142:4569
Rx-Frame Retry[ No] – OSeqno: 001 ISeqno: 001 Type: IAX Subclass: ACK
Timestamp: 00004ms SCall: 02418 DCall: 00001 192.168.242.142:4569

<— SIP read from UDP:192.168.242.1:51831 —>

<------------->
Really destroying SIP dialog ‘1bba48142c5c03243ba3d81c0a605845@192.168.242.142:5060’ Method: OPTIONS
Tx-Frame Retry[000] – OSeqno: 000 ISeqno: 000 Type: IAX Subclass: POKE
Timestamp: 00011ms SCall: 07156 DCall: 00000 192.168.242.142:4569

Rx-Frame Retry[ No] – OSeqno: 000 ISeqno: 001 Type: IAX Subclass: PONG
Timestamp: 00011ms SCall: 00001 DCall: 07156 192.168.242.142:4569
Tx-Frame Retry[-01] – OSeqno: 001 ISeqno: 001 Type: IAX Subclass: ACK
Timestamp: 00011ms SCall: 07156 DCall: 00001 192.168.242.142:4569

<— SIP read from UDP:192.168.242.1:51831 —>

<------------->

<— SIP read from UDP:192.168.242.142:5060 —>
OPTIONS sip:192.168.242.143 SIP/2.0
Via: SIP/2.0/UDP 192.168.242.142:5060;branch=z9hG4bK071fb6de
Max-Forwards: 70
From: “asterisk” sip:asterisk@192.168.242.142;tag=as1f102477
To: sip:192.168.242.143
Contact: sip:asterisk@192.168.242.142:5060
Call-ID: 0770fede77d96deb37a3ff7400791b10@192.168.242.142:5060
CSeq: 102 OPTIONS
User-Agent: Asterisk PBX certified/13.8-cert2
Date: Tue, 15 Nov 2016 18:01:46 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0

<------------->
— (13 headers 0 lines) —
Sending to 192.168.242.142:5060 (no NAT)
Looking for s in public (domain 192.168.242.143)

<— Transmitting (no NAT) to 192.168.242.142:5060 —>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.242.142:5060;branch=z9hG4bK071fb6de;received=192.168.242.142
From: “asterisk” sip:asterisk@192.168.242.142;tag=as1f102477
To: sip:192.168.242.143;tag=as090b2e56
Call-ID: 0770fede77d96deb37a3ff7400791b10@192.168.242.142:5060
CSeq: 102 OPTIONS
Server: Asterisk PBX certified/13.8-cert2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Contact: sip:192.168.242.143:5060
Accept: application/sdp
Content-Length: 0