Asterisk as a IAX2 or SIP Router?

I basically want to use Asterisk as a Call router to other asterisk systems.

is this possible?

I have 3 companies I need to provided trunks for, I want to setup asterisk to route calls to the correct freepbx asterisk and have been having a lot of trouble with the IAX2 protocol.

How can I have a call come in on one trunk go to one system then bounce of that system and go to another?

Any help on how the IAX2 protocol works would be welcome also.

Asterisk works great for this task as does IAX.

FreePBX just gets in the way for an application like this.

Build IAX2 peers to each of the boxes then build a simple dial plan that routes the calls by DID to the customer IE: dial(iax2/customer/$exten)

The book is a huge help in understanding how Asterisk works.