SIP 404 when using IAX2 on dynamic ip servers

I have a problem trying to dial sip extensions through two asterisk servers using IAX2 as the connection. The IAX2 trunk seems to be working perfectly but dialing extensions from one side to the other, I get a SIP/2.0 404 error. My settings in FreePBX are the following…

IAX Trunks…
ServerA -=- Dial Rules=(5551|XX), Trunk Name=(ServerB.net), Peer Details=(context=from-internal, host=dynamic, secret=5551, type=peer, username=5551), User Context=(5552), User Details=(context=from-internal, host=dynamic, secret=5552, type=user), Register String=(5551:[email protected])
ServerB -=- Dial Rules=(5552|XX), Trunk Name=(ServerA.net), Peer Details=(context=from-internal, host=dynamic, secret=5552, type=peer, username=5552), User Context=(5551), User Details=(context=from-internal, host=dynamic, secret=5551, type=user), Register String=(5552:[email protected])

Outbound Routes…
ServerA -=- Route Name=(ToServerB), Dial Patterns=(5551XX), Trunk Sequence=(0=IAX2/ServerB.net)
ServerB -=- Route Name=(ToServerA), Dial Patterns=(5552XX), Trunk Sequence=(0=IAX2/ServerA.net)

Extensions…
ServerA Extension 1 -=- Type=(IAX), Display Name=(ServerB.net), Secret=(5552), NoTransfer=(yes), Context=(from-internal), Host=(dynamic), Type=(friend), Qualify=(yes), Dial=(IAX2/5552), MailBox=(5552@device)
ServerA Extension 2 -=- Type=(SIP), Display Name=(User1), Secret=(blah), Context=(default), Host=(dynamic), Type=(friend), NAT=(yes), Qualify=(yes), Dial=(SIP/01), MailBox=(01@device)
ServerB Extension 1 -=- Type=(IAX), Display Name=(ServerA.net), Secret=(5551), NoTransfer=(yes), Context=(from-internal), Host=(dynamic), Type=(friend), Qualify=(yes), Dial=(IAX2/5551), MailBox=(5551@device)
ServerB Extension 2 -=- Type=(SIP), Display Name=(User1), Secret=(blah), Context=(default), Host=(dynamic), Type=(friend), NAT=(yes), Qualify=(yes), Dial=(SIP/01), MailBox=(01@device)

The following is what I get when I dial from a workstation using X-Lite connected to ServerA…

<-- SIP read from 192.168.0.4:11200:
INVITE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.0.4:11200;branch=z9hG4bK-d87543-da0212016a343956-1–d87543-;rport
Max-Forwards: 70
Contact: sip:[email protected]:11200
To: "555101"sip:[email protected]
From: "User1"sip:[email protected];tag=76226517
Call-ID: NDVhMjI5MjQ4MDBkMGU1NGY4MDYxNTE1MzM0OGEyMWE.
CSeq: 1 INVITE
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO
Content-Type: application/sdp
User-Agent: X-Lite release 1011s stamp 41150
Content-Length: 518

v=0
o=- 6 2 IN IP4 192.168.0.4
s=CounterPath X-Lite 3.0
c=IN IP4 192.168.0.4
t=0 0
m=audio 53990 RTP/AVP 107 119 100 106 0 105 98 8 101
a=alt:1 3 : f9i9rmiz FKbyuMoq 192.168.0.4 53990
a=alt:2 2 : f92unyQq XFEcYq66 192.168.52.1 53990
a=alt:3 1 : XZV+v11w RT/xysTA 192.168.208.1 53990
a=fmtp:101 0-15
a=rtpmap:107 BV32/16000
a=rtpmap:119 BV32-FEC/16000
a=rtpmap:100 SPEEX/16000
a=rtpmap:106 SPEEX-FEC/16000
a=rtpmap:105 SPEEX-FEC/8000
a=rtpmap:98 iLBC/8000
a=rtpmap:101 telephone-event/8000
a=sendrecv

— (12 headers 18 lines) —
Using INVITE request as basis request - NDVhMjI5MjQ4MDBkMGU1NGY4MDYxNTE1MzM0OGEyMWE.
Sending to 192.168.0.4 : 11200 (NAT)
Reliably Transmitting (NAT) to 192.168.0.4:11200:
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP 192.168.0.4:11200;branch=z9hG4bK-d87543-da0212016a343956-1–d87543-;received=192.168.0.4;rport=11200
From: "User1"sip:[email protected];tag=76226517
To: "555101"sip:[email protected];tag=as4e778b75
Call-ID: NDVhMjI5MjQ4MDBkMGU1NGY4MDYxNTE1MzM0OGEyMWE.
CSeq: 1 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Proxy-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce="3e27b0d2"
Content-Length: 0


Scheduling destruction of call ‘NDVhMjI5MjQ4MDBkMGU1NGY4MDYxNTE1MzM0OGEyMWE.’ in 15000 ms
Found user ‘01’
<-- SIP read from 192.168.0.4:11200:
ACK sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.0.4:11200;branch=z9hG4bK-d87543-da0212016a343956-1–d87543-;rport
To: "555101"sip:[email protected];tag=as4e778b75
From: "User1"sip:[email protected];tag=76226517
Call-ID: NDVhMjI5MjQ4MDBkMGU1NGY4MDYxNTE1MzM0OGEyMWE.
CSeq: 1 ACK
Content-Length: 0

— (7 headers 0 lines) —
<-- SIP read from 192.168.0.4:11200:
INVITE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.0.4:11200;branch=z9hG4bK-d87543-6a607e201504dc32-1–d87543-;rport
Max-Forwards: 70
Contact: sip:[email protected]:11200
To: "555101"sip:[email protected]
From: “User1"sip:[email protected];tag=76226517
Call-ID: NDVhMjI5MjQ4MDBkMGU1NGY4MDYxNTE1MzM0OGEyMWE.
CSeq: 2 INVITE
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO
Content-Type: application/sdp
Proxy-Authorization: Digest username=“01”,realm=“asterisk”,nonce=“3e27b0d2”,uri="sip:[email protected]”,response=“32978aa690dea254e431c93ed947ea95”,algorithm=MD5
User-Agent: X-Lite release 1011s stamp 41150
Content-Length: 518

v=0
o=- 6 2 IN IP4 192.168.0.4
s=CounterPath X-Lite 3.0
c=IN IP4 192.168.0.4
t=0 0
m=audio 53990 RTP/AVP 107 119 100 106 0 105 98 8 101
a=alt:1 3 : f9i9rmiz FKbyuMoq 192.168.0.4 53990
a=alt:2 2 : f92unyQq XFEcYq66 192.168.52.1 53990
a=alt:3 1 : XZV+v11w RT/xysTA 192.168.208.1 53990
a=fmtp:101 0-15
a=rtpmap:107 BV32/16000
a=rtpmap:119 BV32-FEC/16000
a=rtpmap:100 SPEEX/16000
a=rtpmap:106 SPEEX-FEC/16000
a=rtpmap:105 SPEEX-FEC/8000
a=rtpmap:98 iLBC/8000
a=rtpmap:101 telephone-event/8000
a=sendrecv

— (13 headers 18 lines) —
Using INVITE request as basis request - NDVhMjI5MjQ4MDBkMGU1NGY4MDYxNTE1MzM0OGEyMWE.
Sending to 192.168.0.4 : 11200 (NAT)
Found user '01’
Found RTP audio format 107
Found RTP audio format 119
Found RTP audio format 100
Found RTP audio format 106
Found RTP audio format 0
Found RTP audio format 105
Found RTP audio format 98
Found RTP audio format 8
Found RTP audio format 101
Peer audio RTP is at port 192.168.0.4:53990
Found description format BV32
Found description format BV32-FEC
Found description format SPEEX
Found description format SPEEX-FEC
Found description format SPEEX-FEC
Found description format iLBC
Found description format telephone-event
Capabilities: us - 0xc (ulaw|alaw), peer - audio=0x60c (ulaw|alaw|speex|ilbc)/video=0x0 (nothing), combined - 0xc (ulaw|alaw)
Non-codec capabilities: us - 0x1 (telephone-event), peer - 0x1 (telephone-event), combined - 0x1 (telephone-event)
Looking for 555101 in default (domain ServerA.net)
Rx-Frame Retry[ No] – OSeqno: 000 ISeqno: 000 Type: IAX Subclass: POKE
Timestamp: 00005ms SCall: 00005 DCall: 00000 [41.242.133.69:4569]
Tx-Frame Retry[000] – OSeqno: 000 ISeqno: 001 Type: IAX Subclass: PONG
Timestamp: 00005ms SCall: 00006 DCall: 00005 [41.242.133.69:4569]
Rx-Frame Retry[ No] – OSeqno: 001 ISeqno: 001 Type: IAX Subclass: ACK
Timestamp: 00005ms SCall: 00005 DCall: 00006 [41.242.133.69:4569]
Tx-Frame Retry[000] – OSeqno: 000 ISeqno: 000 Type: IAX Subclass: POKE
Reliably Transmitting (NAT) to 192.168.0.4:11200:
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 192.168.0.4:11200;branch=z9hG4bK-d87543-6a607e201504dc32-1–d87543-;received=192.168.0.4;rport=11200
From: "User1"sip:[email protected];tag=76226517
To: "555101"sip:[email protected];tag=as4e778b75
Call-ID: NDVhMjI5MjQ4MDBkMGU1NGY4MDYxNTE1MzM0OGEyMWE.
CSeq: 2 INVITE
User-Agent: Asterisk PBX
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY
Content-Length: 0


<-- SIP read from 192.168.0.4:11200:
INVITE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.0.4:11200;branch=z9hG4bK-d87543-6a607e201504dc32-1–d87543-;rport
Max-Forwards: 70
Contact: sip:[email protected]:11200
To: "555101"sip:[email protected]
From: "User1"sip:[email protected];tag=76226517
Call-ID: NDVhMjI5MjQ4MDBkMGU1NGY4MDYxNTE1MzM0OGEyMWE.
CSeq: 2 INVITE
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO
Content-Type: application/sdp
Proxy-Authorization: Digest username=“01”,realm=“asterisk”,nonce=“3e27b0d2”,uri=“sip:555101@”,response=“32978aa690dea254e431c93ed947ea95”,algorithm=MD5
User-Agent: X-Lite release 1011s stamp 41150
Content-Length: 518

v=0
o=- 6 2 IN IP4 192.168.0.4
s=CounterPath X-Lite 3.0
c=IN IP4 192.168.0.4
t=0 0
m=audio 53990 RTP/AVP 107 119 100 106 0 105 98 8 101
a=alt:1 3 : f9i9rmiz FKbyuMoq 192.168.0.4 53990
a=alt:2 2 : f92unyQq XFEcYq66 192.168.52.1 53990
a=alt:3 1 : XZV+v11w RT/xysTA 192.168.208.1 53990
a=fmtp:101 0-15
a=rtpmap:107 BV32/16000
a=rtpmap:119 BV32-FEC/16000
a=rtpmap:100 SPEEX/16000
a=rtpmap:106 SPEEX-FEC/16000
a=rtpmap:105 SPEEX-FEC/8000
a=rtpmap:98 iLBC/8000
a=rtpmap:101 telephone-event/8000
a=sendrecv

— (13 headers 18 lines) —
Ignoring this INVITE request
<-- SIP read from 192.168.0.4:11200:
ACK sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP 192.168.0.4:11200;branch=z9hG4bK-d87543-6a607e201504dc32-1–d87543-;rport
To: "555101"sip:[email protected];tag=as4e778b75
From: "User1"sip:[email protected];tag=76226517
Call-ID: NDVhMjI5MjQ4MDBkMGU1NGY4MDYxNTE1MzM0OGEyMWE.
CSeq: 2 ACK
Content-Length: 0

— (7 headers 0 lines) —
Destroying call 'NDVhMjI5MjQ4MDBkMGU1NGY4MDYxNTE1MzM0OGEyMWE.'
Timestamp: 00012ms SCall: 00008 DCall: 00000 [41.242.133.69:4569]
Rx-Frame Retry[ No] – OSeqno: 000 ISeqno: 001 Type: IAX Subclass: PONG
Timestamp: 00012ms SCall: 00006 DCall: 00008 [41.242.133.69:4569]
Tx-Frame Retry[-01] – OSeqno: 001 ISeqno: 001 Type: IAX Subclass: ACK
Timestamp: 00012ms SCall: 00008 DCall: 00006 [41.242.133.69:4569]
<-- SIP read from 192.168.0.4:11200:

— (0 headers 1 lines) —
Tx-Frame Retry[000] – OSeqno: 000 ISeqno: 000 Type: IAX Subclass: REGREQ
Timestamp: 00011ms SCall: 00004 DCall: 00000 [41.242.133.69:4569]
USERNAME : 5551
REFRESH : 60

Rx-Frame Retry[ No] – OSeqno: 000 ISeqno: 001 Type: IAX Subclass: REGACK
Timestamp: 00004ms SCall: 00007 DCall: 00004 [41.242.133.69:4569]
USERNAME : 5551
DATE TIME : 2007-11-29 14:16:08
REFRESH : 60
APPARENT ADDRES : IPV4 41.208.249.158:4569
MESSAGE COUNT : 0
CALLING NUMBER : 5551
CALLING NAME : device

Tx-Frame Retry[-01] – OSeqno: 001 ISeqno: 001 Type: IAX Subclass: ACK
Timestamp: 00004ms SCall: 00004 DCall: 00007 [41.242.133.69:4569]

Can someone help me please as I am very new to asterisk and freepbx.

Thanks.

Looks like xlite is not registered with your asterisk box extension.

from above:
Sending to 192.168.0.4 : 11200 (NAT)
Reliably Transmitting (NAT) to 192.168.0.4:11200:
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP

OK. Got that sorted but I am still getting the 404 error. Thanks so far.

Is there anybody else that can help me resolve this problem. I have searched all over the net and checked out all the documents I could find relating to IAX2 and SIP configurations. I have tried to amend the extensions_additional.conf and iax.conf files with no success. I take it that I don’t exactly understand how FreePBX creates its dial plans and the scripts Asterisk executes.

Any help will be greatly appreciated.