Dial from Asterisk through Another Asterisk

I have two asterisk servers running on my LAN, one FreeBSD and one Fedora. I call them asterisk1 and asterisk2 two respectively. I have managed to get them to register via iax with each other.

asterisk1 has an X101P card connected to my PSTN. I would like to use a SIP phone connected to asterisk2 to dial out through asterisk1. Can anyone tell me the correct extension to place in my extensions.conf on asterisk2 to connect to the PSTN on asterisk1.

The SIP phone works fine on asterisk2 but I don’t know how to tell it to go to asterisk1 when I want to dial out. I followed a similar setup I once had to make calls through FreeWorld but I don’t think this correct.

exten => _8.,1, SetCallerId,${my_callerid}
exten => _8.,2,Dial(IAX2/:$my_passwd@asterisk1/${EXTEN:1},60,r)
exten => _8.,3,Congestion

OK I read the TFOT some more and hacked my way through this. But I’ve only got the hard part resolved, that is I can dial an outside number from the SIP phone that connects to Asterisk2 and it uses the X101P card in Asterisk1 to get out. That works.

But I have several extensions on Asterisk1, namely 280 which when I dial it from the phones connected to Asterisk1 I can listen to my jazz moh tunes. So it seems that the phones on Asterisk2 can access Asterisk1 and use the outside line but I cannot seem to access the local extensions like the echo test or voicemail on Asterisk1. I get Call rejected by No such context/extension.

Ok, someone wrap your chainsaw around my neck and call me the missing link…persistence pays off. I’ve got a full blown asterisk-2-asterisk connection. All extensions are available. Now my asterisk server in the dining room can connect to the asterisk server in my den and call out or listen to jazz. Now to move the asterisk server in the dining room to my sisters house 1500 miles away.