Connect two asterisk servers over IAX protocol with client connected with SIP

Hi, I am newbie in asterisk world, I have two asterisk servers working in the same network, I want to connect them with each other in following way

  1. First server redirects all four digit number calls to second server, but handles all three digit numbers locally
  2. Second server vice versa. Redirects three digit numbers and handles four digit numbers.

I followed this tutorial

http://www.asteriskdocs.org/en/2nd_Edition/asterisk-book-html-chunk/I_sect14_tt670.html

Here is configuration for First Server it has IP - 192.168.0.111

File /etc/asterisk/iax.conf

[general]
autokill=yes
register => asterfirst:welcomefirst@192.168.0.112
bandwidth=low
disallow=lpc10
jitterbuffer=no

[astersecond]
type=friend
host=dynamic
trunk=yes
secret=welcomesecond
context=incoming_second
deny=0.0.0.0/0.0.0.0
permit=192.168.0.112/255.255.255.255

File /etc/asterisk/extensions.conf

[general]
static=yes
writeprotect=no
[globals]
[default]
include => confrence


[managers-context]
include => crosp-main

[support-context]
include => crosp-main

[crosp-main]
exten => _XXX,1,Dial(SIP/${EXTEN})
include => conference
include => remote-second

[remote-second]
exten => _XXXX,1,NoOp()
exten => _XXXX,n,Dial(IAX2/astersecond/${EXTEN})
exten => _XXXX,n,Hangup()

And second server

Here is configuration for Second Server it has IP - 192.168.0.112

File /etc/asterisk/iax.conf

[general]

register => astersecond:welcomesecond@192.168.0.111

bandwidth=low
;
disallow=lpc10
;

jitterbuffer=no
autokill=yes


[asterfirst]
type=friend
host=dynamic
trunk=yes
secret=welcomefirst
context=incoming_first
deny=0.0.0.0/0.0.0.0
permit=192.168.0.111/255.255.255.255


[guest]
type=user
context=public
callerid="Guest IAX User"

File /etc/asterisk/extensions.conf

[general]
static=yes
writeprotect=no
[globals]
[default]


[developers-context]
include => crosp-main

[remote-first]
exten => _XXX,1,NoOp()
exten => _XXX,n,Dial(IAX2/asterfirst/${EXTEN})
exten => _XXX,n,Hangup()

[crosp-main]
exten => _XXXX,1,Dial(IAX2/${EXTEN})
include => remote-first

Is it possible to have such configuration. So all clients connected over SIP protocol but communication between two servers is done via IAX ?
Or in this case all clients have to connect over IAX protocol as well ?

I would be grateful for any help.

As a back to back user agent, mixing channel technologies is a perfectly normal thing to do.

1 Like

Thanks for answer, I have following problem when trying to connect I got following message

 == Using SIP RTP CoS mark 5
    -- Executing [4444@managers-context:1] NoOp("SIP/100-00000001", "") in new stack
    -- Executing [4444@managers-context:2] Dial("SIP/100-00000001", "IAX2/astersecond/4444") in new stack
    -- Called IAX2/astersecond/4444
    -- Hungup 'IAX2/astersecond-30837'
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [4444@managers-context:3] Hangup("SIP/100-00000001", "") in new stack
  == Spawn extension (managers-context, 4444, 3) exited non-zero on 'SIP/100-00000001'

Maybe something is wrong with my config file ?

There is no evidence of anything wrong on the calling side, and, as you screen scraped, rather than using the log file, I can’t tell how long it lasted.

1 Like

Thanks for answer, could you suggest please how can I solve this problem, what should I check at first if my configuration files are correct ?
Should I provide log file ? There is nothing other than I posted in the Asterisk terminal.
So I enabled verbose mode.
Here is output

  -- Executing [4444@managers-context:2] Dial("SIP/100-00000001", "IAX2/astersecond/4444") in new stack
Tx-Frame Retry[000] -- OSeqno: 000 ISeqno: 000 Type: IAX     Subclass: NEW
   Timestamp: 00002ms  SCall: 27932  DCall: 00000 192.168.0.112:4569
   VERSION         : 2
   CALLED NUMBER   : 4444
   CODEC_PREFS     : (gsm|ilbc|speex|g729|g723)
   CALLING NUMBER  : 100
   CALLING PRESNTN : 0
   CALLING TYPEOFN : 0
   CALLING TRANSIT : 0
   CALLING NAME    : Number 100
   LANGUAGE        : en
   FORMAT          : 2
   FORMAT2         : gsm
   CAPABILITY      : 1795
   CAPABILITY2     : Unknown
   ADSICPE         : 2
   DATE TIME       : 2016-10-21  13:17:48

Rx-Frame Retry[ No] -- OSeqno: 000 ISeqno: 001 Type: IAX     Subclass: CTOKEN
   Timestamp: 00002ms  SCall: 00001  DCall: 27932 192.168.0.112:4569
   CALLTOKEN       : 51 bytes

Tx-Frame Retry[000] -- OSeqno: 000 ISeqno: 000 Type: IAX     Subclass: NEW
   Timestamp: 00003ms  SCall: 27932  DCall: 00000 192.168.0.112:4569
   VERSION         : 2
   CALLED NUMBER   : 4444
   CODEC_PREFS     : (gsm|ilbc|speex|g729|g723)
   CALLING NUMBER  : 100
   CALLING PRESNTN : 0
   CALLING TYPEOFN : 0
   CALLING TRANSIT : 0
   CALLING NAME    : Number 100
   LANGUAGE        : en
   FORMAT          : 2
   FORMAT2         : gsm
   CAPABILITY      : 1795
   CAPABILITY2     : Unknown
   ADSICPE         : 2
   DATE TIME       : 2016-10-21  13:17:48
   CALLTOKEN       : 51 bytes

    -- Called IAX2/astersecond/4444
Rx-Frame Retry[ No] -- OSeqno: 000 ISeqno: 001 Type: IAX     Subclass: REJECT
   Timestamp: 00010ms  SCall: 10333  DCall: 27932 192.168.0.112:4569
   CAUSE           : No such context/extension
   CAUSE CODE      : 3

Tx-Frame Retry[-01] -- OSeqno: 001 ISeqno: 001 Type: IAX     Subclass: ACK
   Timestamp: 00010ms  SCall: 27932  DCall: 10333 192.168.0.112:4569
    -- Hungup 'IAX2/astersecond-27932'
  == Everyone is busy/congested at this time (1:0/0/1)

I’m not familiar with IAX, but if this were SIP I would say you should have host=address on at least one, and preferably both ends.

(WIth SIP, at least one end needs to know the others address, otherwise it cannot even register.)

1 Like

According to the IAX2 signaling: “No such context/extension”

You appear to be sending the call to a context that doesn’t exist. That is both the “incoming_first” and “incoming_second” context on each side is not in the dialplan you have provided.

1 Like

And it is actually looking in the public context because of my point!

1 Like

I really appreciate your help. But I am newbie, it seems for me that I specified context correctly for users

Here is my full content of the file /etc/asterisk/sip.con for First server

[general]
context=crosp-main                  ; Default context for incoming calls. Defaults to 'default'
allowguest=no                  ; Allow or reject guest calls (default is yes)
allowoverlap=no                 ; Disable overlap dialing support. (Default is yes)
udpbindaddr=0.0.0.0             ; IP address to bind UDP listen socket to (0.0.0.0 binds to all)
limitonpeers=yes
tcpenable=no                    ; Enable server for incoming TCP connections (default is no)
tcpbindaddr=0.0.0.0             ; IP address for TCP server to bind to (0.0.0.0 binds to all interfaces)
transport=udp                   ; Set the default transports.  The order determines the primary default transport.
srvlookup=yes                   ; Enable DNS SRV lookups on outbound calls
                                ; in SRV records
externaddr = my external ip; use this address.
limitonpeers=yes; may override the address/port information specified in the SIP/SDP messages,
directmedia=no

[authentication]

[managers-phones](!)
type=friend
context=managers-context
secret=123
host=dynamic
nat=yes
qualify=yes
directmedia=no
canreinvite=no
callgroup=1
pickupgroup=1
call-limit=1
dtmfmode=auto
disallow=all
allow=alaw
allow=ulaw
allow=g729
allow=g723
allow=g722


[100](managers-phones)
callerid="Number 100" <100>
[101](managers-phones)

And for second server

[general]
context=public                  ; Default context for incoming calls. Defaults to 'default'
allowguest=no                  ; Allow or reject guest calls (default is yes)
allowoverlap=no                 ; Disable overlap dialing support. (Default is yes)
udpbindaddr=0.0.0.0             ; IP address to bind UDP listen socket to (0.0.0.0 binds to all)
limitonpeers=yes
tcpenable=no                    ; Enable server for incoming TCP connections (default is no)
tcpbindaddr=0.0.0.0             ; IP address for TCP server to bind to (0.0.0.0 binds to all interfaces)
transport=udp                   ; Set the default transports.  The order determines the primary default transport.
srvlookup=yes                   ; Enable DNS SRV lookups on outbound calls
                                ; in SRV records
externaddr = my external ip       ; use this address.
limitonpeers=yes; may override the address/port information specified in the SIP/SDP messages,

[authentication]

[developers](!)
type=friend
context=developers-context
secret=666
host=dynamic
qualify=yes
canreinvite=no
callgroup=1
pickupgroup=1
call-limit=1
dtmfmode=auto
disallow=all
allow=alaw
allow=ulaw
allow=g729
allow=g723
allow=g722

[3333](developers)
callerid="Developer 3333" <3333>
[4444](developers)
callerid="Developer 4444" <4444>
[5555](developers)
callerid="Developer 5555" <5555>
[6666](developers)
callerid="Developer 6666" <6666>

What is wrong with my configuration ?

The problems you have encountered so far are not in the SIP configuration.

The problems are:

  • you are using guest access for your IAX, and don’t have a public context.

  • even if you did have IP addresses for your IAX peers, they are using contexts which aren’t in extensions.conf.

(type=peer is almost always better than type=friend.
nat=yes is deprecated and nat= is overused.
canreinvite is a deprecated name for directmedia.)

1 Like

One other thing. The sudden introduction of sip.conf when there is mention of missing extensions, makes me think you don’t understand the Asterisk distinction between devices and extensions. sip.conf defines devices, not extensions. It is extensions.conf that defines extensions and is implicated in that error.

1 Like

I understand difference between configuration files, I have added sip.conf files because I have not posted them earlier, so I thought that maybe I had done something wrong here.
I understand the purpose of each file.

I am a little bit confused about iax.conf file maybe I configured it incorrectly (especially wit IP addresses)

As mentioned by jcolp:

On 192.168.0.111’s extensions.conf, you need to add a new dialplan context (or section) that’s called [incoming_second] and some extensions within that context.

On 192.168.0.112’s extensions.conf, you similarly need to add a new dialplan context that’s called [incoming_first] and some extensions that you expect to land there (or extension patterns.

Hope that helps,

Matthew Fredrickson

1 Like

By the way, two servers are registered successfully as I can see

On first server with IP 192.168.0.111

Host                                           dnsmgr  Username    Perceived                                      Refresh  State
192.168.0.112:4569                             N       asterfirst  192.168.0.112:4569                                  60  Registered

On second server with IP 192.168.0.112

Host                                           dnsmgr  Username    Perceived                                      Refresh  State
192.168.0.111:4569                             N       astersecon  192.168.0.111:4569                                  60  Registered

Yep, see my reply above your post.

1 Like

Thank you for your answer, it was very helpful made me to get better understanding what is going on.

I have revised my config files

And now they look as follows

First server 192.168.0.111

iax.conf

[general]
autokill=yes
register => axfirst:welcomefirst@192.168.0.112
bandwidth=low
disallow=lpc10
jitterbuffer=no

[axsecond]
type=friend
host=dynamic
trunk=yes
secret=welcomesecond
context=remote
deny=0.0.0.0/0.0.0.0
permit=192.168.0.112/255.255.255.255

extensions.conf

[general]
static=yes
writeprotect=no
[globals]

[default]

[main-context]
include => internal
include => remote
include => conference

[internal]
exten => _XXX,1,Dial(SIP/${EXTEN})

[remote]
exten => _XXXX,1,Dial(IAX2/axsecond/${EXTEN})

[conference]
exten => 666,1,Answer
exten => 666,n,ConfBridge(6666)
exten => 666,n,Hangup

But it fails with the same message

    -- Registered IAX2 to '192.168.0.112:4569', who sees us as 192.168.0.111:4569 with no messages waiting
      == Using SIP RTP CoS mark 5
    -- Executing [4444@main-context:1] Dial("SIP/100-00000000", "IAX2/axsecond/4444") in new stack
    -- Called IAX2/axsecond/4444
    -- Hungup 'IAX2/axsecond-25527'
      == Everyone is busy/congested at this time (1:0/0/1)
    -- Auto fallthrough, channel 'SIP/100-00000000' status is 'CHANUNAVAIL'

Second server 192.168.0.112

iax.conf

[general]
register => axsecond:welcomesecond@192.168.0.111
bandwidth=low
disallow=lpc10
jitterbuffer=no
autokill=yes

[axfirst]
type=friend
host=dynamic
trunk=yes
secret=welcomefirst
context=remote
deny=0.0.0.0/0.0.0.0
permit=192.168.0.111/255.255.255.255

extensions.conf

[general]
static=yes
writeprotect=no
[globals]

[default]


[main-context]
include => internal
include => remote

[remote]
exten => _XXX,1,Dial(IAX2/axfirst/${EXTEN})

[internal]
exten => _XXXX,1,Dial(IAX2/${EXTEN})

the same message

 == Using SIP RTP CoS mark 5
    -- Executing [100@main-context:1] Dial("SIP/4444-00000000", "IAX2/axfirst/100") in new stack
    -- Called IAX2/axfirst/100
    -- Hungup 'IAX2/axfirst-17097'
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Auto fallthrough, channel 'SIP/4444-00000000' status is 'CHANUNAVAIL'

I named the context with the same name on both sides,

I also tried to debug IAX

And found interesting message

Rx-Frame Retry[ No] -- OSeqno: 001 ISeqno: 002 Type: IAX     Subclass: ACK
   Timestamp: 00006ms  SCall: 01106  DCall: 21577 192.168.0.112:4569
Rx-Frame Retry[ No] -- OSeqno: 001 ISeqno: 002 Type: IAX     Subclass: REJECT
   Timestamp: 00008ms  SCall: 01106  DCall: 21577 192.168.0.112:4569
   CAUSE           : No authority found
   CAUSE CODE      : 50

What can cause such error ? I guess I missing something essential.

Thanks for help again.

Assuming it works the same as SIP, both secrets must be the same.

Rather than using register, you should directly put:

host = 192.168.0.112 in the axsecond section and:

host = 192.168.0.111 in the axfirst section.

1 Like

Guys thanks a lot for your help, I finally got it working.
But I still confused about how.

Here is my configuration

For first server

extensions.conf

[general]
static=yes
writeprotect=no
[globals]

[default]

[main-context]
include => internal
include => remote
include => conference

[internal]
exten => _XXX,1,Dial(SIP/${EXTEN})

[remote]
exten => _XXXX,1,Dial(IAX2/axsecond/${EXTEN})

[conference]
exten => 666,1,Answer
exten => 666,n,ConfBridge(6666)
exten => 666,n,Hangup

iax.conf

[general]
autokill=yes
register => axfirst:welcome@192.168.0.112
bandwidth=low
disallow=lpc10
jitterbuffer=no

[axsecond]
host = 192.168.0.112
type=friend
host=dynamic
trunk=yes
secret=welcome
context=internal
deny=0.0.0.0/0.0.0.0
permit=192.168.0.112/255.255.255.255

And for second server

extensions.conf

[general]
static=yes
writeprotect=no
[globals]

[default]


[main-context]
include => internal
include => remote

[remote]
exten => _XXX,1,Dial(IAX2/axfirst/${EXTEN})

[internal]
exten => _XXXX,1,Dial(SIP/${EXTEN})

iax.conf

[general]
register => axsecond:welcome@192.168.0.111
bandwidth=low
disallow=lpc10
jitterbuffer=no
autokill=yes

[axfirst]
host = 192.168.0.111
type=friend
host=dynamic
trunk=yes
secret=welcome
context=internal
deny=0.0.0.0/0.0.0.0
permit=192.168.0.111/255.255.255.255

It works, but I have really no idea how, I completely missed understanding of configuration of iax.conf file, especially all this cross connections.

It is completely clear about extensions.conf.

Could someone, explain how does it work.
I want to get understanding and this is just for study purpose, I am not going to create corporate network.

I would be grateful for any explanation.


help me

Help us!

Explain the context of your problem.

Describe your configuration.

Provide more surrounding context in your logs, and provide them as text, not as,unsearchable, and difficult to quote, images (why has there been a crop of screen shots this week?).

Explain why a reasonably self evident error message doesn’t make sense.

It is saying that you have configured the system not to accept requests from that source.