Dialing out via trunk

Hello dear Asterisk gurus!
Please help a newbie to implement the following configuration:
I have two FreePBX boxes, A and B. A has FXO ports and can dial to POTS, while B is just connected to Ethernet. I have to connect A and B with a trunk (either IAX2, or SIP), so that my users could dial to the outside world from B’s extensions using A’s FXO ports.

Thanks a lot in advance!

what does Got SIP response 489 “Bad event” back from 192.168.x.x really means, I have a freePBx server connected to a ASterisk, the both server are connected trough via SIp trunks and the Asterisk is the head master that serves as the one that pass the FreePbx incoming calls, the freepbx registers in the asterisk pretty well but the asterisk always gives me that message.help please