Route incomming call by callee ID

Hello,

I have 2 Asterisk 1.6.2 server with FreePBX 2.9

Site 1:

  • Asterisk + FreePBX
  • 4 SIP Trunk whith a Grandstrem Gateway
  • 2 SIP Truns with a GSM gateway
  • 1 IAX Gateway with Site 2

Site 2:

  • Asterisk + FreePBX
  • 1 IAX Gateway with Site 1

The IAX trunk is Ok, I can make calls from site 1 to site 2 and form site 2 to site 1.

I have some outbound routes on the first Asterisk server (site 1) to route the outgoing calls by operator.

What I need now to do is : Routing Outgoing Calls from Site 2 through IAX trunk then through one of SIP trunk depending of the operator

For example, if the called number begin by 2 so it would be routed to SIP-Trunk-1, but if begin by 5 it should be routed to SIP-Trunk-4.

Can you help me on how to do it ??

Also, which other information you need in order to give me a solution.

Regards,
Rochdi