Routing calls from branch to branch via HQ

Branch offices can 4 digit dial in to HQ and HQ can dial branches. Branches can’t 4 digit dial other branches.

Using IAX and traffic has to pass thru HQ.
What am I missing?

So, branch 1 dials 6000 and it should go to HQ and HQ routes to PBX that handles 6000

How do I handle this in FreePBX 211

Added inbound routes for each branch in the HQ pbx and set the iax trunk to the correct location.
Name: ToBranch1
DID Number: _5XXX
Trunk: IAX_Branch1

So when branch2 dials 5000 it comes in to HQ, and HQ sends it out the IAX_Branch1.