Digium Voice Gateway registration in FreePBX ( multiple PRI Lines in the same gateway )

Some days ago one of our customers had a problem with his Digium gateway configuration when he wants to use one of his 4port Digium gateways with different PRI lines .The guides I found on the internet was not fully covered how to register and of course no guide how to register when we have multiple PRI lines on the same box . So I decided to write this guide maybe it will be useful for others with the same scenario .

We have tow types of registration in Digium gateways .
  • Digium Gateway registering  in our sip server ( here is FreePBX )
  • Sip server registering in our Digium Gateway 

I could never use the second method and never worked for me . So I'm using the first method to register my gateway as a trunk in my FreePBX and then route the calls . The same method is using when you have same PRI lines with the  same numbering . This is the steps :

 Define a sip trunk on you FreePBX :

Define  sip trunk on Digium gateway :

I have two PRI lines with different numbering . So I disable other E1 ports ( optional )

I need to route incoming calls from my PRI lines to my FreePBX :
so I create a call routing group for tow connected E1 ports :

and send the Send the calls from my PRI lines to my FreePBX via trunk I created :

Next Step is simply define incomming and outgoing route in your FreePBX :

But when you have multiple PRI lines with diffrent numbering you need to specify which PRI lines we should use . We do using diffrent Prefix and sending the Prefix numbers to digium Gateway . Then in Digium Gateway we can decide on the numers comming from our Freepbx to route to diffrent PRI lines . For example if you use Prefix 9 for dialing through First E1 port then you should turn off Single Entry Mode and Set 9 to be omited .