If you want to connect two Asterisk server you will use IAX2 connection. It means that you should change /etc/asterisk/iax.conf. Following, are some global configuration:

[general]
bindport=4569 port on which IAX listen (must be before address)
bindaddr=0.0.0.0 client can be any address
iaxcompat=yes
bandwidth=high
allow=all same as bandwidth=high
jitterbuffer=no
forcejitterbuffer=no
autokill=yes

On next link you can find all iax options: IAX Options
Add this to end of file on asterisk2 ( this server has IP address 192.168.0.11) In this example asterisk1 is client.

[502];To asterisk1
type=friend
host=192.168.0.10 this is IP address for IAX client
context=numberplan this is dial plan which one will client use ( on asterisk2 side)
username=502 username must be same as number in []
secret=123qwert password for authentication
requirecalltoken=no

On asterisk1 (IP address is 192.168.0.10) you will use [global] section as on asterisk2, and bellow are setup for IAX trunk on his side. In this example asterisk2 is client.

[502];To asterisk2
type=friend
host=192.168.0.11 this is IP address for IAX client
context=numberplan this is dial plan which one will client use ( on asterisk1 side)
username=502 username must be same as number in []
secret=123qwert password for authentication
requirecalltoken=no

How to use IAX and SIP clinet in dial plan you will see in [numberplan] section in /etc/asterisk/extensions.conf file.