PSTN-gateway routing across multiple asterisk boxes

Hello… I have 2 asterisk 1.2.12.1 installs on RHEL4 and using the latest freepbx stable release.

One Asterisk box that I will call “gateway” handles the SIP trunk to our PSTN provider (and will eventually digitally trunk to another PBX using T1 modules but that has yet to be implemented.) The 2nd asterisk box we are using as the call agent for all the clients and phones to attach to. eventually this could be a large deployment but right now we’re just testing things…

Anyways, the calls should come in to the gateway box through the SIP trunk from the provider and then route to call agent through an IAX2 trunk where the DIDs are actually owned by the extensions. There is an outbound route that matches the DIDs directing it to the IAX2 trunk that goes to the call agent. Calls outbound work GREAT from the phones attached to the call agent.

If i put a phone directly off of the Gateway and assign one of the inbound DIDs to it, it works great. It just cannot seem to route to the call agent. SIP and IAX debugs don’t seem to point me at anything.

Anybody experience something similar or have any tips? Am i correct in thinking that asterisk should be able to just route a call from the SIP trunk (PSTN) to an outbound route matching an IAX2 trunk? It works great in the other direction.

Any help would be appreciated. Ask any questions if you need me to clarify anything.

Thanks,
K