IAX Method (working for me)
This is a working topology that shows how to connect two (2) Asterisk servers using IAX protocol. For more information see: http://cesar8489.blogspot.com/
Method 1
Receiving Server (iax.conf)
[REC_SERVER]
type=user
host=my.calling.server.ca
secret=mysecret
context=local
trunk=yes
Sending Server (extensions.conf)
[mycontext]
exten => _5XXX,1,Dial(IAX2/REC_SERVER:[email protected]/${EXTEN}@local)
exten => _5XXX,2,Hangup
exten => _5XXX,102,Hangup
Any call in the mycontext context on Calling Server to extensions 5000-5999 (mapped by extension _5XXX) will get sent to receiving server (my.receiving.server.ca) into the local context on the receiving server.
Performing the same configuration in the opposite direction will allow cross-calls between Asterisk systems.
Pros:
Simple, all references in one file per server.
Cons:
Information in dialing string will appear in logs inclusive of user:password. Dial string becomes very long.
Method 2
Receiving Server (iax.conf)
[REC_SERVER]
type=user
host=my.calling.server.ca
secret=mysecret
context=local
trunk=yes
Sending Server (iax.conf)
[REMOTE_SERVER]
type=peer
host=my.receiving.server.ca
secret=mysecret
context=local
Sending Server (extensions.conf)
[mycontext]
exten => 5XXX,1,Dial(IAX2/REMOTE_SERVER/${EXTEN})
exten => _5XXX,2,Hangup
exten => _5XXX,102,Hangup
Pros:
User:Password are stored in the calling server’s iax.conf file and not part of the Dial string. This is more secure in that they are not recorded in log in files.Dial strings much shorter and concise.
Cons:
Calling server now must have iax.conf and extensions.conf coordinated making setup a little more complicated. Must user type= definition correctly: Caller = peer; Receiver = user. type=friend is a bi-directional relationship meaning both peer and user at the same time.
Method 3
Register command
If the calling server does not have a fixed IP address or DNS namespace then the iax.conf file description of the calling server located on the receiving server should specify host=dynamic.
If the calling server host is specified as dynamic, the calling server must register with the receiving server with the register command.
Receiving Server (iax.conf)
[REC_SERVER]
type=user
host=dynamic
secret=mysecret
context=local
trunk=yes
Sending Server (iax.conf)
[general]
register => REC_SERVER:[email protected]
[REMOTE_SERVER]
type=peer
host=dynamic
context=local
Sending Server (Extensions.conf)
[mycontext]
exten => _5XXX,1,Dial(IAX2/REMOTE_SERVER/${EXTEN})
exten => _5XXX,2,Hangup
exten => _5XXX,102,Hangup